<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

"""
buildutil.py provides utility functions for querying, editing, and adding
builds to Socorro.
"""
import logging
import psycopg2

logger = logging.getLogger("webapi")


def insert_build(cursor, product_name, version, platform, build_id, build_type,
                 beta_number, repository):
    """ Insert a particular build into the database """
    # As we use beta numbers, we don't want to keep the 'bX' in versions
    if "b" in version:
        version = version[:version.index("b")]

    if beta_number is not None:
        beta_number = int(beta_number)

    params = (str(product_name), version, build_type, int(build_id),
              platform, beta_number, repository)

    logger.info("Trying to insert new release: %s %s %s %s %s %s %s" % params)

    sql = """/* socorro.lib.buildutil.insert_build */
        SELECT add_new_release(%s, %s, %s, %s, %s, %s, %s)
    """

    try:<commit_msg>Fixes bug 762211 - Call update_product_versions after inserting a new release into the DB.<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

"""
buildutil.py provides utility functions for querying, editing, and adding
builds to Socorro.
"""
import logging
import psycopg2

logger = logging.getLogger("webapi")


def insert_build(cursor, product_name, version, platform, build_id, build_type,
                 beta_number, repository):
    """ Insert a particular build into the database """
    # As we use beta numbers, we don't want to keep the 'bX' in versions
    if "b" in version:
        version = version[:version.index("b")]

    if beta_number is not None:
        beta_number = int(beta_number)

    params = (str(product_name), version, build_type, int(build_id),
              platform, beta_number, repository)

    logger.info("Trying to insert new release: %s %s %s %s %s %s %s" % params)

    sql = """/* socorro.lib.buildutil.insert_build */
        SELECT add_new_release(%s, %s, %s, %s, %s, %s, %s, true)
    """

    try:
{'fraction_non_alphanumeric': 0.11292400171747531, 'fraction_numerical': 0.006869901245169601, 'mean_word_length': 3.2752293577981653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3794727', 'n_tokens_mistral': 738, 'n_tokens_neox': 702, 'n_words': 268}