summaryrefslogtreecommitdiffstats
path: root/support/schema/gendummydata.py
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2012-05-23 19:24:22 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2012-07-06 11:25:43 +0200
commite7f6deeb3340a5e8cd97cfc9321b411b16fce618 (patch)
tree6e71f72b5de1b9cd24e288c06701d4e652e7e7f4 /support/schema/gendummydata.py
parenta4ed3a3b3bd4f47cc842e7f909c34f4e41a4655e (diff)
downloadaur-e7f6deeb3340a5e8cd97cfc9321b411b16fce618.tar.gz
aur-e7f6deeb3340a5e8cd97cfc9321b411b16fce618.tar.xz
gendummydata.py: Add ability to generate dummy trusted user proposals
* Introduce ability to specify number of open and closed dummy trusted user proposals * First step for eventually adding dummy votes for proposals Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'support/schema/gendummydata.py')
-rwxr-xr-xsupport/schema/gendummydata.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index f996e937..160dde5c 100755
--- a/support/schema/gendummydata.py
+++ b/support/schema/gendummydata.py
@@ -34,6 +34,8 @@ 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
VOTING = (0, .30) # percentage range for package voting
+OPEN_PROPOSALS = 5 # number of open trusted user proposals
+CLOSE_PROPOSALS = 15 # number of closed trusted user proposals
RANDOM_TLDS = ("edu", "com", "org", "net", "tw", "ru", "pl", "de", "es")
RANDOM_URL = ("http://www.", "ftp://ftp.", "http://", "ftp://")
RANDOM_LOCS = ("pub", "release", "files", "downloads", "src")
@@ -264,6 +266,30 @@ for p in list(seen_pkgs.keys()):
s = s % (seen_pkgs[p], src)
out.write(s)
+# Create trusted user proposals
+#
+log.debug("Creating SQL statements for trusted user proposals.")
+count=0
+for t in range(0, OPEN_PROPOSALS+CLOSE_PROPOSALS):
+ fortune = subprocess.getoutput(FORTUNE_CMD).replace("'","")
+ now = int(time.time())
+ if count < CLOSE_PROPOSALS:
+ start = now - random.randrange(3600*24*7, 3600*24*21)
+ end = now - random.randrange(0, 3600*24*7)
+ else:
+ start = now
+ end = now + random.randrange(3600*24, 3600*24*7)
+ if count % 5 == 0: # Don't make the vote about anyone once in a while
+ user = ""
+ else:
+ user = user_keys[random.randrange(0,len(user_keys))]
+ suid = trustedusers[random.randrange(0,len(trustedusers))]
+ s = ("INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End,"
+ " SubmitterID) VALUES ('%s', '%s', %d, %d, %d);\n")
+ s = s % (fortune, user, start, end, suid)
+ out.write(s)
+ count += 1
+
# close output file
#
out.write("COMMIT;\n")