<commit_before>import asyncio
import json
import os

import aiohttp
import semver

import virtool.db
import virtool.db.processes
import virtool.db.utils
import virtool.http.proxy
import virtool.http.utils
import virtool.processes
import virtool.software
import virtool.utils

VIRTOOL_RELEASES_URL = "https://www.virtool.ca/releases"


async def fetch_and_update_software_releases(app):
    """
    Get a list of releases, from the Virtool website, published since the current server version.

    :param app: the application object

    :return: a list of releases
    :rtype: Coroutine[list]

    """
    db = app["db"]
    version = app["version"]
    session = app["client"]
    settings = app["settings"]

    if app is None:
        return list()

    try:
        async with virtool.http.proxy.ProxyRequest(settings, session.get, VIRTOOL_RELEASES_URL) as resp:
            data = await resp.text()
            data = json.loads(data)
    except aiohttp.ClientConnectionError:
        # Return any existing release list or `None`.
        return await virtool.db.utils.get_one_field(db.status, "releases", "software")

    data = data["software"]

    channel = settings["software_channel"]

    # Reformat the release dicts to make them more palatable. If the response code was not 200, the releases list
    # will be empty. This is interpreted by the web client as an error.
    if channel == "stable":
        data = [r for r in data if "alpha" not in r["name"] and "beta" not in r["name"]]

    elif channel == "beta":
        data = [r for r in data if "alpha" not in r["name"]]

    releases = list()

    for release in data:
        if semver.compare(release["name"].replace("v", ""), version.replace("v", "")) < 1:
            break

        releases.append(release)

    await db.status.update_one({"_id": "software"}, {
        "$set": {
            "releases": releases
        }
    })

    return releases<commit_msg>Add logging to fetch_and_update_software_releases()<commit_after>import asyncio
import json
import logging
import os

import aiohttp
import semver

import virtool.db
import virtool.db.processes
import virtool.db.utils
import virtool.http.proxy
import virtool.http.utils
import virtool.processes
import virtool.software
import virtool.utils

logger = logging.getLogger(__name__)

VIRTOOL_RELEASES_URL = "https://www.virtool.ca/releases"


async def fetch_and_update_software_releases(app):
    """
    Get a list of releases, from the Virtool website, published since the current server version.

    :param app: the application object

    :return: a list of releases
    :rtype: Coroutine[list]

    """
    db = app["db"]
    version = app["version"]
    session = app["client"]
    settings = app["settings"]

    if app is None:
        return list()

    try:
        async with virtool.http.proxy.ProxyRequest(settings, session.get, VIRTOOL_RELEASES_URL) as resp:
            data = await resp.text()
            data = json.loads(data)

        logger.debug("Retrieved software releases from www.virtool.ca")
    except aiohttp.ClientConnectionError:
        # Return any existing release list or `None`.
        logger.debug("Could not retrieve software releases")
        return await virtool.db.utils.get_one_field(db.status, "releases", "software")

    data = data["software"]

    channel = settings["software_channel"]

    # Reformat the release dicts to make them more palatable. If the response code was not 200, the releases list
    # will be empty. This is interpreted by the web client as an error.
    if channel == "stable":
        data = [r for r in data if "alpha" not in r["name"] and "beta" not in r["name"]]

    elif channel == "beta":
        data = [r for r in data if "alpha" not in r["name"]]

    releases = list()

    for release in data:
        if semver.compare(release["name"].replace("v", ""), version.replace("v", "")) < 1:
            break

        releases.append(release)

    await db.status.update_one({"_id": "software"}, {
        "$set": {
            "releases": releases
        }
    })

    return releases
{'fraction_non_alphanumeric': 0.10636740668455721, 'fraction_numerical': 0.0019516955354964625, 'mean_word_length': 2.9728682170542635, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3791394', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1180, 'n_words': 392}