summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--support/schema/dummy-data.sql.gzbin74459 -> 78294 bytes
-rwxr-xr-xsupport/schema/gendummydata.py166
-rw-r--r--web/lib/pkgs.inc21
3 files changed, 146 insertions, 41 deletions
diff --git a/support/schema/dummy-data.sql.gz b/support/schema/dummy-data.sql.gz
index 5f50b9a..1a2e8e8 100644
--- a/support/schema/dummy-data.sql.gz
+++ b/support/schema/dummy-data.sql.gz
Binary files differ
diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index 7fe5132..8dfc61f 100755
--- a/support/schema/gendummydata.py
+++ b/support/schema/gendummydata.py
@@ -16,6 +16,8 @@ DB_PASS = "aur"
USER_ID = 5 # Users.ID of first user
PKG_ID = 1 # Packages.ID of first package
MAX_USERS = 100 # how many users to 'register'
+MAX_DEVS = .1 # what percentage of MAX_USERS are Developers
+MAX_TUS = .2 # what percentage of MAX_USERS are Trusted Users
MAX_PKGS = 250 # how many packages to load
PKG_FILES = (8, 30) # min/max number of files in a package
VOTING = (.3, .8) # percentage range for package voting
@@ -160,67 +162,167 @@ location_keys = locations.keys()
dbc.close()
db.close()
+# developer/tu IDs
+#
+developers = []
+trustedusers = []
+has_devs = 0
+has_tus = 0
+
# Begin by creating the User statements
#
if DBUG: print "Creating SQL statements for users.",
count = 0
for u in user_keys:
+ account_type = 1 # default to normal user
+ if not has_devs or not has_tus:
+ account_type = random.randrange(1, 4)
+ if account_type == 3 and not has_devs:
+ # this will be a dev account
+ #
+ developers.append(seen_users[u])
+ if len(developers) >= MAX_DEVS * MAX_USERS:
+ has_devs = 1
+ elif account_type == 2 and not has_tus:
+ # this will be a trusted user account
+ #
+ trustedusers.append(seen_users[u])
+ if len(trustedusers) >= MAX_TUS * MAX_USERS:
+ has_tus = 1
+ else:
+ # a normal user account
+ #
+ pass
+
s = """\
INSERT INTO Users (ID, AccountTypeID, Username, Email, Passwd)
- VALUES (%d, 1, '%s', '%s@example.com', '%s');
- """ % (seen_users[u], u, u, u)
+ VALUES (%d, %d, '%s', '%s@example.com', '%s');
+ """ % (seen_users[u], account_type, u, u, u)
out.write(s)
if count % 10 == 0:
if DBUG: print ".",
count += 1
if DBUG: print "."
+if DBUG:
+ print "Number of developers:", len(developers)
+ print "Number of trusted users:", len(trustedusers)
+ print "Number of users:", (MAX_USERS-len(developers)-len(trustedusers))
+ print "Number of packages:", MAX_PKGS
# Create the package statements
#
if DBUG: print "Creating SQL statements for packages.",
count = 0
for p in seen_pkgs.keys():
+ if count % 2 == 0:
+ muid = developers[random.randrange(0,len(developers))]
+ else:
+ muid = trustedusers[random.randrange(0,len(trustedusers))]
+ 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
+
s = """\
INSERT INTO Packages (ID, Name, Version, CategoryID, LocationID,
SubmittedTS, SubmitterUID, MaintainerUID)
- VALUES (%d, '%s', '%s', %d, %d, %d, %d, 1);
- """ % (seen_pkgs[p], p, genVersion(), genCategory(), genLocation(),
- long(time.time()), genUID())
+ VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d);
+ """ % (seen_pkgs[p], p, genVersion(), genCategory(), location_id,
+ long(time.time()), genUID(), muid)
out.write(s)
if count % 100 == 0:
if DBUG: print ".",
count += 1
- # 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
+ if location_id == 1: # Unsupported - just a PKGBUILD and maybe other stuff
+ others = random.randrange(0,3)
+ s = """\
+INSERT INTO PackageContents (PackageID, FileName, Path, FileSize)
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], "PKGBUILD", "/home/aur/incoming/%s/PKGBUILD" % p,
+ random.randrange(0,999))
+ out.write(s)
+ if others == 0:
+ s = """\
+INSERT INTO PackageContents (PackageID, FileName, Path, FileSize)
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], "%s.patch" % p,
+ "/home/aur/incoming/%s/%s.patch" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
+
+ elif others == 1:
+ s = """\
+INSERT INTO PackageContents (PackageID, FileName, Path, FileSize)
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], "%s.patch" % p,
+ "/home/aur/incoming/%s/%s.patch" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
+ s = """\
+INSERT INTO PackageContents (PackageID, FileName, Path, FileSize)
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], "arch.patch",
+ "/home/aur/incoming/%s/arch.patch" % p,
+ random.randrange(0,999))
+ out.write(s)
+
+ elif others == 2:
+ s = """\
+INSERT INTO PackageContents (PackageID, FileName, Path, FileSize)
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], "%s.patch" % p,
+ "/home/aur/incoming/%s/%s.patch" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
+ s = """\
+INSERT INTO PackageContents (PackageID, FileName, Path, FileSize)
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], "arch.patch",
+ "/home/aur/incoming/%s/arch.patch" % p,
+ random.randrange(0,999))
+ out.write(s)
s = """\
INSERT INTO PackageContents (PackageID, FileName, Path, FileSize)
- VALUES (%d, '%s', '%s', %d);
- """ % (seen_pkgs[p], os.path.basename(path), path,
- random.randrange(0,99999999))
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], "%s.install" % 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, FileName, Path, FileSize)
+ VALUES (%d, '%s', '%s', %d);
+ """ % (seen_pkgs[p], os.path.basename(path), path,
+ random.randrange(0,99999999))
+ out.write(s)
if DBUG: print "."
# Cast votes
diff --git a/web/lib/pkgs.inc b/web/lib/pkgs.inc
index b9d061e..47dd06a 100644
--- a/web/lib/pkgs.inc
+++ b/web/lib/pkgs.inc
@@ -104,16 +104,16 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
print "</span></span><br />\n";
print " <select name='SB'>\n";
print " <option value=n";
- $SB == "n" ? print "selected> " : print "> ";
+ $SB == "n" ? print " selected> " : print "> ";
print __("Name")."\n";
print " <option value=c";
- $SB == "c" ? print "selected> " : print "> ";
+ $SB == "c" ? print " selected> " : print "> ";
print __("Category")."\n";
print " <option value=l";
- $SB == "l" ? print "selected> " : print "> ";
+ $SB == "l" ? print " selected> " : print "> ";
print __("Location")."\n";
- print " <option value=p";
- $SB == "p" ? print "selected> " : print "> ";
+ print " <option value=v";
+ $SB == "v" ? print " selected> " : print "> ";
print __("Votes")."\n";
print " </select>\n";
print "</td>\n";
@@ -123,13 +123,13 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
print "</span></span><br />\n";
print " <select name='PP'>\n";
print " <option value=25";
- $PP == 25 ? print "selected> 25\n" : print "> 25\n";
+ $PP == 25 ? print " selected> 25\n" : print "> 25\n";
print " <option value=50";
- $PP == 50 ? print "selected> 50\n" : print "> 50\n";
+ $PP == 50 ? print " selected> 50\n" : print "> 50\n";
print " <option value=75";
- $PP == 75 ? print "selected> 75\n" : print "> 75\n";
+ $PP == 75 ? print " selected> 75\n" : print "> 75\n";
print " <option value=100";
- $PP == 100 ? print "selected> 100\n" : print "> 100\n";
+ $PP == 100 ? print " selected> 100\n" : print "> 100\n";
print " </select>\n";
print "</td>\n";
@@ -184,6 +184,9 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) {
case 'l':
$q.= "ORDER BY LocationID ASC, Name ASC, CategoryID ASC ";
break;
+ case 'v':
+ $q.= "ORDER BY Votes DESC, Name ASC, CategoryID ASC ";
+ break;
default:
$q.= "ORDER BY Name ASC, LocationID ASC, CategoryID ASC ";
break;