prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Incorrect update alert in Admin panel
  <!--
  If this is a bug report please fill out the template below.
  
  If this is a feature request please describe the behavior that you'd like to see.
  -->
  
  **Environment**:
  
  - CTFd Version/Commit: 3.1.1
  - Operating System: Ubuntu 20.4
  - Web Browser and Version: Chrome 85
  
  **What happened?**
  The admin panel shows an alert: "A new CTFd version is available!", which links to "https://github.com/CTFd/CTFd/releases/tag/2.4.2". I encountered the issue with version 3.0.2. as well. After complete reinstall and upgrade to version 3.1.1 the problem persisted
  
  **What did you expect to happen?**
  I expected no alert, as my CTFd version is the newest, and certainly newer than 2.4.2.
  
  **How to reproduce your issue**
  Go to the admin pages.
  
  **Any associated stack traces or error logs**
  No
  
  </issue>
  <code>
  [start of CTFd/utils/updates/__init__.py]
  1 import sys
  2 import time
  3 from distutils.version import StrictVersion
  4 from platform import python_version
  5 
  6 import requests
  7 from flask import current_app as app
  8 
  9 from CTFd.models import Challenges, Teams, Users, db
  10 from CTFd.utils import get_app_config, get_config, set_config
  11 from CTFd.utils.config import is_setup
  12 from CTFd.utils.crypto import sha256
  13 
  14 
  15 def update_check(force=False):
  16     """
  17     Makes a request to ctfd.io to check if there is a new version of CTFd available. The service is provided in return
  18     for users opting in to anonymous usage data collection. Users can opt-out of update checks by specifying
  19     UPDATE_CHECK = False in config.py
  20 
  21     :param force:
  22     :return:
  23     """
  24     # If UPDATE_CHECK is disabled don't check for updates at all.
  25     if app.config.get("UPDATE_CHECK") is False:
  26         return
  27 
  28     # Don't do an update check if not setup
  29     if is_setup() is False:
  30         return
  31 
  32     # Get when we should check for updates next.
  33     next_update_check = get_config("next_update_check") or 0
  34 
  35     # If we have passed our saved time or we are forcing we should check.
  36     update = (next_update_check < time.time()) or force
  37 
  38     if update:
  39         try:
  40             name = str(get_config("ctf_name")) or ""
  41             params = {
  42                 "ctf_id": sha256(name),
  43                 "current": app.VERSION,
  44                 "python_version_raw": sys.hexversion,
  45                 "python_version": python_version(),
  46                 "db_driver": db.session.bind.dialect.name,
  47                 "challenge_count": Challenges.query.count(),
  48                 "user_mode": get_config("user_mode"),
  49                 "user_count": Users.query.count(),
  50                 "team_count": Teams.query.count(),
  51                 "theme": get_config("ctf_theme"),
  52                 "upload_provider": get_app_config("UPLOAD_PROVIDER"),
  53                 "channel": app.CHANNEL,
  54             }
  55             check = requests.get(
  56                 "https://versioning.ctfd.io/check", params=params, timeout=0.1
  57             ).json()
  58         except requests.exceptions.RequestException:
  59             pass
  60         except ValueError:
  61             pass
  62         else:
  63             try:
  64                 latest = check["resource"]["tag"]
  65                 html_url = check["resource"]["html_url"]
  66                 if StrictVersion(latest) > StrictVersion(app.VERSION):
  67                     set_config("version_latest", html_url)
  68                 elif StrictVersion(latest) <= StrictVersion(app.VERSION):
  69                     set_config("version_latest", None)
  70                 next_update_check_time = check["resource"].get(
  71                     "next", int(time.time() + 43200)
  72                 )
  73                 set_config("next_update_check", next_update_check_time)
  74             except KeyError:
  75                 set_config("version_latest", None)
  76
  [end of CTFd/utils/updates/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/CTFd/utils/updates/__init__.py b/CTFd/utils/updates/__init__.py
  --- a/CTFd/utils/updates/__init__.py
  +++ b/CTFd/utils/updates/__init__.py
  @@ -53,7 +53,7 @@
                   "channel": app.CHANNEL,
               }
               check = requests.get(
  -                "https://versioning.ctfd.io/check", params=params, timeout=0.1
  +                "https://versioning.ctfd.io/check", params=params, timeout=3
               ).json()
           except requests.exceptions.RequestException:
               pass
  
verification_info: {"golden_diff": "diff --git a/CTFd/utils/updates/__init__.py b/CTFd/utils/updates/__init__.py\n--- a/CTFd/utils/updates/__init__.py\n+++ b/CTFd/utils/updates/__init__.py\n@@ -53,7 +53,7 @@\n                 \"channel\": app.CHANNEL,\n             }\n             check = requests.get(\n-                \"https://versioning.ctfd.io/check\", params=params, timeout=0.1\n+                \"https://versioning.ctfd.io/check\", params=params, timeout=3\n             ).json()\n         except requests.exceptions.RequestException:\n             pass\n", "issue": "Incorrect update alert in Admin panel\n<!--\r\nIf this is a bug report please fill out the template below.\r\n\r\nIf this is a feature request please describe the behavior that you'd like to see.\r\n-->\r\n\r\n**Environment**:\r\n\r\n- CTFd Version/Commit: 3.1.1\r\n- Operating System: Ubuntu 20.4\r\n- Web Browser and Version: Chrome 85\r\n\r\n**What happened?**\r\nThe admin panel shows an alert: \"A new CTFd version is available!\", which links to \"https://github.com/CTFd/CTFd/releases/tag/2.4.2\". I encountered the issue with version 3.0.2. as well. After complete reinstall and upgrade to version 3.1.1 the problem persisted\r\n\r\n**What did you expect to happen?**\r\nI expected no alert, as my CTFd version is the newest, and certainly newer than 2.4.2.\r\n\r\n**How to reproduce your issue**\r\nGo to the admin pages.\r\n\r\n**Any associated stack traces or error logs**\r\nNo\n", "before_files": [{"content": "import sys\nimport time\nfrom distutils.version import StrictVersion\nfrom platform import python_version\n\nimport requests\nfrom flask import current_app as app\n\nfrom CTFd.models import Challenges, Teams, Users, db\nfrom CTFd.utils import get_app_config, get_config, set_config\nfrom CTFd.utils.config import is_setup\nfrom CTFd.utils.crypto import sha256\n\n\ndef update_check(force=False):\n    \"\"\"\n    Makes a request to ctfd.io to check if there is a new version of CTFd available. The service is provided in return\n    for users opting in to anonymous usage data collection. Users can opt-out of update checks by specifying\n    UPDATE_CHECK = False in config.py\n\n    :param force:\n    :return:\n    \"\"\"\n    # If UPDATE_CHECK is disabled don't check for updates at all.\n    if app.config.get(\"UPDATE_CHECK\") is False:\n        return\n\n    # Don't do an update check if not setup\n    if is_setup() is False:\n        return\n\n    # Get when we should check for updates next.\n    next_update_check = get_config(\"next_update_check\") or 0\n\n    # If we have passed our saved time or we are forcing we should check.\n    update = (next_update_check < time.time()) or force\n\n    if update:\n        try:\n            name = str(get_config(\"ctf_name\")) or \"\"\n            params = {\n                \"ctf_id\": sha256(name),\n                \"current\": app.VERSION,\n                \"python_version_raw\": sys.hexversion,\n                \"python_version\": python_version(),\n                \"db_driver\": db.session.bind.dialect.name,\n                \"challenge_count\": Challenges.query.count(),\n                \"user_mode\": get_config(\"user_mode\"),\n                \"user_count\": Users.query.count(),\n                \"team_count\": Teams.query.count(),\n                \"theme\": get_config(\"ctf_theme\"),\n                \"upload_provider\": get_app_config(\"UPLOAD_PROVIDER\"),\n                \"channel\": app.CHANNEL,\n            }\n            check = requests.get(\n                \"https://versioning.ctfd.io/check\", params=params, timeout=0.1\n            ).json()\n        except requests.exceptions.RequestException:\n            pass\n        except ValueError:\n            pass\n        else:\n            try:\n                latest = check[\"resource\"][\"tag\"]\n                html_url = check[\"resource\"][\"html_url\"]\n                if StrictVersion(latest) > StrictVersion(app.VERSION):\n                    set_config(\"version_latest\", html_url)\n                elif StrictVersion(latest) <= StrictVersion(app.VERSION):\n                    set_config(\"version_latest\", None)\n                next_update_check_time = check[\"resource\"].get(\n                    \"next\", int(time.time() + 43200)\n                )\n                set_config(\"next_update_check\", next_update_check_time)\n            except KeyError:\n                set_config(\"version_latest\", None)\n", "path": "CTFd/utils/updates/__init__.py"}]}