summaryrefslogtreecommitdiffstats
path: root/schema/gendummydata.py
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-04-26 10:29:17 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-04-26 13:20:56 +0200
commit92812050a059a651357f772b58e967154ea8428c (patch)
treec7b61560011b3cbe0671c998b4ee0ce19fc40b22 /schema/gendummydata.py
parent34453d32958cc71cf08e932368952f98b46b7020 (diff)
downloadaurweb-92812050a059a651357f772b58e967154ea8428c.tar.xz
Store conflicts, provides and replaces in the DB
Package conflicts, provides and replaces are now stored in the new PackageRelations table. The gendummydata script generates test entries for these relations. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'schema/gendummydata.py')
-rwxr-xr-xschema/gendummydata.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/schema/gendummydata.py b/schema/gendummydata.py
index 18852a2..bb622d1 100755
--- a/schema/gendummydata.py
+++ b/schema/gendummydata.py
@@ -29,6 +29,7 @@ MAX_DEVS = .1 # what percentage of MAX_USERS are Developers
MAX_TUS = .2 # what percentage of MAX_USERS are Trusted Users
MAX_PKGS = 900 # how many packages to load
PKG_DEPS = (1, 15) # min/max depends a package has
+PKG_RELS = (1, 5) # min/max relations a package has
PKG_SRC = (1, 3) # min/max sources a package has
PKG_CMNTS = (1, 5) # min/max number of comments a package has
CATEGORIES_COUNT = 17 # the number of categories from aur-schema
@@ -253,18 +254,22 @@ for p in list(track_votes.keys()):
log.debug("Creating statements for package depends/sources.")
for p in list(seen_pkgs.keys()):
num_deps = random.randrange(PKG_DEPS[0], PKG_DEPS[1])
- this_deps = {}
- i = 0
- while i != num_deps:
+ for i in range(0, num_deps):
dep = random.choice([k for k in seen_pkgs])
- if dep not in this_deps:
- deptype = random.randrange(1, 5)
- if deptype == 4:
- dep += ": for " + random.choice([k for k in seen_pkgs])
- s = "INSERT INTO PackageDepends VALUES (%d, %d, '%s', NULL);\n"
- s = s % (seen_pkgs[p], deptype, dep)
- out.write(s)
- i += 1
+ deptype = random.randrange(1, 5)
+ if deptype == 4:
+ dep += ": for " + random.choice([k for k in seen_pkgs])
+ s = "INSERT INTO PackageDepends VALUES (%d, %d, '%s', NULL);\n"
+ s = s % (seen_pkgs[p], deptype, dep)
+ out.write(s)
+
+ num_rels = random.randrange(PKG_RELS[0], PKG_RELS[1])
+ for i in range(0, num_deps):
+ rel = random.choice([k for k in seen_pkgs])
+ reltype = random.randrange(1, 4)
+ s = "INSERT INTO PackageRelations VALUES (%d, %d, '%s', NULL);\n"
+ s = s % (seen_pkgs[p], reltype, rel)
+ out.write(s)
num_sources = random.randrange(PKG_SRC[0], PKG_SRC[1])
for i in range(num_sources):