summaryrefslogtreecommitdiffstats
path: root/support/schema/gendummydata.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-31 18:18:15 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2011-02-01 12:41:08 +0100
commit7f5af61c884b53a75a2b7f8b5146465f14a71f6b (patch)
tree52a959e9a9a7e940339906532a1f68a99595b4af /support/schema/gendummydata.py
parent492c8c668f1edb708e49bcafbacb22c58e2877a5 (diff)
downloadaur-7f5af61c884b53a75a2b7f8b5146465f14a71f6b.tar.gz
aur-7f5af61c884b53a75a2b7f8b5146465f14a71f6b.tar.xz
Drop PackageLocations table and references
We don't need this anymore since all packages managed here are well...managed here. Rip out all of the places we were using this field, many of which depended on the magic value '2' anyway. On the display side of things, we had a column that was always showing 'unsupported' that is now gone, and you can no longer sort by this column. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'support/schema/gendummydata.py')
-rwxr-xr-xsupport/schema/gendummydata.py106
1 files changed, 28 insertions, 78 deletions
diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index 99f81955..a03b3e67 100755
--- a/support/schema/gendummydata.py
+++ b/support/schema/gendummydata.py
@@ -85,28 +85,21 @@ esc = db.escape_string
#
seen_users = {}
seen_pkgs = {}
-locations = {}
categories = {}
-location_keys = []
category_keys = []
user_keys = []
# some functions to generate random data
#
-def genVersion(location_id=0):
+def genVersion():
ver = []
ver.append("%d" % random.randrange(0,10))
ver.append("%d" % random.randrange(0,20))
if random.randrange(0,2) == 0:
ver.append("%d" % random.randrange(0,100))
- if location_id == 2: # the package is in the AUR
- return ".".join(ver) + "-u%d" % random.randrange(1,11)
- else:
- return ".".join(ver) + "%d" % random.randrange(1,11)
+ return ".".join(ver) + "-u%d" % random.randrange(1,11)
def genCategory():
return categories[category_keys[random.randrange(0,len(category_keys))]]
-def genLocation():
- return locations[location_keys[random.randrange(0,len(location_keys))]]
def genUID():
return seen_users[user_keys[random.randrange(0,len(user_keys))]]
@@ -162,7 +155,7 @@ contents = None
# Load package categories from database
#
-if DBUG: print "Loading package categories/locations..."
+if DBUG: print "Loading package categories..."
q = "SELECT * FROM PackageCategories"
dbc.execute(q)
row = dbc.fetchone()
@@ -171,16 +164,6 @@ while row:
row = dbc.fetchone()
category_keys = categories.keys()
-# Load package locations from database
-#
-q = "SELECT * FROM PackageLocations"
-dbc.execute(q)
-row = dbc.fetchone()
-while row:
- locations[row[1]] = row[0]
- row = dbc.fetchone()
-location_keys = locations.keys()
-
# done with the database
#
dbc.close()
@@ -243,14 +226,10 @@ for p in seen_pkgs.keys():
if count % 20 == 0: # every so often, there are orphans...
muid = 0
- location_id = genLocation()
- if location_id == 1: # unsupported pkgs don't have a maintainer
- muid = 0
-
uuid = genUID() # the submitter/user
- s = "INSERT INTO Packages (ID, Name, Version, CategoryID, LocationID, SubmittedTS, SubmitterUID, MaintainerUID) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d);\n" % (seen_pkgs[p], p, genVersion(location_id),
- genCategory(), location_id, NOW, uuid, muid)
+ s = "INSERT INTO Packages (ID, Name, Version, CategoryID, SubmittedTS, SubmitterUID, MaintainerUID) VALUES (%d, '%s', '%s', %d, %d, %d, %d);\n" % (seen_pkgs[p], p, genVersion(),
+ genCategory(), NOW, uuid, muid)
out.write(s)
if count % 100 == 0:
if DBUG: print ".",
@@ -265,63 +244,34 @@ for p in seen_pkgs.keys():
s = "INSERT INTO PackageComments (PackageID, UsersID, Comments, CommentTS) VALUES (%d, %d, '%s', %d);\n" % (seen_pkgs[p], genUID(), fortune, now)
out.write(s)
- if location_id == 1: # Unsupported - just a PKGBUILD and maybe other stuff
- others = random.randrange(0,3)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/PKGBUILD" % p,
+ others = random.randrange(0,3)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/PKGBUILD" % p,
+ random.randrange(0,999))
+ out.write(s)
+ if others == 0:
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
random.randrange(0,999))
out.write(s)
- if others == 0:
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
- random.randrange(0,999))
- out.write(s)
- elif others == 1:
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
- random.randrange(0,999))
- out.write(s)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
- random.randrange(0,999))
- out.write(s)
+ elif others == 1:
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
+ random.randrange(0,999))
+ out.write(s)
- elif others == 2:
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
- random.randrange(0,999))
- out.write(s)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
- random.randrange(0,999))
- out.write(s)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.install" % (p,p),
- random.randrange(0,999))
- out.write(s)
+ elif others == 2:
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
+ random.randrange(0,999))
+ out.write(s)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.install" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
- else:
- # Create package contents
- #
- num_files = random.randrange(PKG_FILES[0], PKG_FILES[1])
- files = {}
- for f in range(num_files):
- loc = RANDOM_PATHS[random.randrange(len(RANDOM_PATHS))]
- if "lib" in loc:
- path = loc + "/lib" + p + ".so"
- elif "man" in loc:
- path = loc + "/" + p + "." + loc[-1] + ".gz"
- elif "share" in loc:
- path = loc + "/" + p + "/sounds/" + p + ".wav"
- elif "profile" in loc:
- path = loc + "/" + p + ".sh"
- elif "rc.d" in loc:
- path = loc + "/" + p
- elif "etc" in loc:
- path = loc + "/" + p + ".conf"
- elif "opt" in loc:
- path = loc + "/" + p + "/bin/" + p
- else:
- path = loc + "/" + p
- if not files.has_key(path):
- files[path] = 1
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], path,
- random.randrange(0,99999999))
- out.write(s)
if DBUG: print "."
# Cast votes