<commit_before>#
# Copyright (c) 2005-2006 rPath, Inc.
#
# All Rights Reserved
#

import md5
import time
import random

from mint import database
from conary import versions
from mint.rmakeconstants import buildjob, buildtrove

class rMakeBuildTable(database.KeyedTable):
    name = "rMakeBuild"
    key = "rMakeBuildId"

    createSQL = """CREATE TABLE rMakeBuild(
                                    rMakeBuildId %(PRIMARYKEY)s,
                                    userId INT,
                                    title VARCHAR(128),
                                    UUID CHAR(32),
                                    jobId INT,
                                    status INT DEFAULT 0,
                                    statusMessage TEXT
                                    )"""

    fields = ['rMakeBuildId', 'userId', 'title', 'UUID', 'jobId', 'status',
              'statusMessage']

    indexes = {'rMakeBuildIdx' : \
               "CREATE INDEX rMakeBuildIdx ON rMakeBuild(userId)",
               'rMakeBuildTitleIdx' : \
               "CREATE UNIQUE INDEX rMakeBuildTitleIdx ON rMakeBuild(title)"}

    def listTrovesById(self, rMakeBuildId):
        cu = self.db.cursor()
        cu.execute("""SELECT rMakeBuildItemId
                          FROM rMakeBuildItems
                          WHERE rMakeBuildId=?""", rMakeBuildId)

        return [x[0] for x in cu.fetchall()]

    def delete(self, rMakeBuildId):
        cu = self.db.cursor()
        cu.execute("DELETE FROM rMakeBuildItems WHERE rMakeBuildId=?",
                   rMakeBuildId)
        cu.execute("DELETE FROM rMakeBuild WHERE rMakeBuildId=?", rMakeBuildId)
        self.db.commit()

    def randomizeUUID(self, rMakeBuildId):
        m = md5.new()
        cu = self.db.cursor()
        cu.execute('SELECT * FROM rMakeBuild WHERE rMakeBuildId=?',
                   rMakeBuildId)
        m.update(str(cu.fetchall()))
        cu.execute('SELECT * FROM rMakeBuildItems WHERE rMakeBuildId=?',
                   rMakeBuildId)<commit_msg>allow duplicate names for different users<commit_after>#
# Copyright (c) 2005-2006 rPath, Inc.
#
# All Rights Reserved
#

import md5
import time
import random

from mint import database
from conary import versions
from mint.rmakeconstants import buildjob, buildtrove

class rMakeBuildTable(database.KeyedTable):
    name = "rMakeBuild"
    key = "rMakeBuildId"

    createSQL = """CREATE TABLE rMakeBuild(
                                    rMakeBuildId %(PRIMARYKEY)s,
                                    userId INT,
                                    title VARCHAR(128),
                                    UUID CHAR(32),
                                    jobId INT,
                                    status INT DEFAULT 0,
                                    statusMessage TEXT
                                    )"""

    fields = ['rMakeBuildId', 'userId', 'title', 'UUID', 'jobId', 'status',
              'statusMessage']

    indexes = {'rMakeBuildIdx' : \
               "CREATE INDEX rMakeBuildIdx ON rMakeBuild(userId)",
               'rMakeBuildTitleIdx' : \
               "CREATE UNIQUE INDEX rMakeBuildTitleIdx ON rMakeBuild(userId, title)"}

    def listTrovesById(self, rMakeBuildId):
        cu = self.db.cursor()
        cu.execute("""SELECT rMakeBuildItemId
                          FROM rMakeBuildItems
                          WHERE rMakeBuildId=?""", rMakeBuildId)

        return [x[0] for x in cu.fetchall()]

    def delete(self, rMakeBuildId):
        cu = self.db.cursor()
        cu.execute("DELETE FROM rMakeBuildItems WHERE rMakeBuildId=?",
                   rMakeBuildId)
        cu.execute("DELETE FROM rMakeBuild WHERE rMakeBuildId=?", rMakeBuildId)
        self.db.commit()

    def randomizeUUID(self, rMakeBuildId):
        m = md5.new()
        cu = self.db.cursor()
        cu.execute('SELECT * FROM rMakeBuild WHERE rMakeBuildId=?',
                   rMakeBuildId)
        m.update(str(cu.fetchall()))
        cu.execute('SELECT * FROM rMakeBuildItems WHERE rMakeBuildId=?',
                   rMakeBuildId)
{'fraction_non_alphanumeric': 0.09142156862745097, 'fraction_numerical': 0.008333333333333333, 'mean_word_length': 1.644847699287103, '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': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6770316', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1089, 'n_words': 269}