<commit_before>
def do_upgrade(env, ver, cursor):
    """Upgrade the reports to better handle the new workflow capabilities"""
    db = env.get_db_cnx()
    owner = db.concat('owner', "' *'")
    reports = list(cursor.execute('SELECT id, query, description FROM report'))
    for report, query, description in reports:
        # All states other than 'closed' are "active".
        query = query.replace("IN ('new', 'assigned', 'reopened')",
                              "<> 'closed'")
        # Add a status column instead of adding an '*' to the owner's name for
        # the 'assigned' state.
        query = query.replace("(CASE status WHEN 'assigned' THEN %s "
                              "ELSE owner END) AS owner" % owner, "owner, status")
        description = description.replace(" * If a ticket has been accepted, "
                                          "a '*' is appended after the "
                                          "owner's name\n",
                                          '')
        cursor.execute("UPDATE report SET query=%s, description=%s "
                       "WHERE id=%s", (query, description, report))<commit_msg>Fix upgrade to schema version 21 for PostgreSQL databases. Closes #5593.<commit_after>
def do_upgrade(env, ver, cursor):
    """Upgrade the reports to better handle the new workflow capabilities"""
    db = env.get_db_cnx()
    owner = db.concat('owner', "' *'")
    cursor.execute('SELECT id, query, description FROM report')
    reports = cursor.fetchall()
    for report, query, description in reports:
        # All states other than 'closed' are "active".
        query = query.replace("IN ('new', 'assigned', 'reopened')",
                              "<> 'closed'")
        # Add a status column instead of adding an '*' to the owner's name for
        # the 'assigned' state.
        query = query.replace("(CASE status WHEN 'assigned' THEN %s "
                              "ELSE owner END) AS owner" % owner, "owner, status")
        description = description.replace(" * If a ticket has been accepted, "
                                          "a '*' is appended after the "
                                          "owner's name\n",
                                          '')
        cursor.execute("UPDATE report SET query=%s, description=%s "
                       "WHERE id=%s", (query, description, report))
{'fraction_non_alphanumeric': 0.11720385098367518, 'fraction_numerical': 0.0025115110925073253, 'mean_word_length': 1.808460634547591, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3061540', 'n_tokens_mistral': 599, 'n_tokens_neox': 569, 'n_words': 212}