mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
started working on package comments
This commit is contained in:
parent
93ac7cb91d
commit
aae43d9ad6
5 changed files with 49 additions and 16 deletions
|
@ -180,13 +180,13 @@ CREATE TABLE PackageContents (
|
|||
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Record comments for users submitting packages to AUR/unsupported
|
||||
-- Record comments for packages
|
||||
--
|
||||
CREATE TABLE PackageUploadHistory (
|
||||
CREATE TABLE PackageComments (
|
||||
PackageID INTEGER UNSIGNED NOT NULL,
|
||||
UsersID INTEGER UNSIGNED NOT NULL,
|
||||
Comments TEXT NOT NULl DEFAULT '',
|
||||
UploadTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
CommentTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
INDEX (UsersID),
|
||||
INDEX (PackageID),
|
||||
FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE,
|
||||
|
|
Binary file not shown.
|
@ -1,4 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
"""
|
||||
usage: gendummydata.py outputfilename.sql
|
||||
"""
|
||||
#
|
||||
# This script seeds the AUR database with dummy data for
|
||||
# use during development/testing. It uses random entries
|
||||
|
@ -22,16 +25,25 @@ MAX_PKGS = 2500 # how many packages to load
|
|||
PKG_FILES = (8, 30) # min/max number of files in a package
|
||||
PKG_DEPS = (1, 5) # min/max depends 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
|
||||
VOTING = (0, .30) # percentage range for package voting
|
||||
RANDOM_PATHS = [ # random path locations for package files
|
||||
RANDOM_PATHS = ( # random path locations for package files
|
||||
"/usr/bin", "/usr/lib", "/etc", "/etc/rc.d", "/usr/share", "/lib",
|
||||
"/var/spool", "/var/log", "/usr/sbin", "/opt", "/usr/X11R6/bin",
|
||||
"/usr/X11R6/lib", "/usr/libexec", "/usr/man/man1", "/usr/man/man3",
|
||||
"/usr/man/man5", "/usr/X11R6/man/man1", "/etc/profile.d"
|
||||
]
|
||||
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"]
|
||||
)
|
||||
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")
|
||||
FORTUNE_FILES = ("computers", "fortunes", "literature", "science",
|
||||
"songs-poems", "startrek", "wisdom", "work", "buffy", "calvin",
|
||||
"futurama", "jargon", "matrix", "starwars", "tao", "chalkboard",
|
||||
"dune", "dune-messiah", "children-of-dune", "god-emperor", "definitions",
|
||||
"drugs", "education", "food", "humorists", "kids", "law", "news",
|
||||
"people", "pets", "politics", "platitudes", "zippy", "riddles"
|
||||
)
|
||||
FORTUNE_CMD = "/usr/bin/fortune -l " + " ".join(FORTUNE_FILES)
|
||||
|
||||
|
||||
import random
|
||||
|
@ -39,6 +51,8 @@ import time
|
|||
import os
|
||||
import sys
|
||||
import cStringIO
|
||||
import commands
|
||||
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("Missing output filename argument");
|
||||
|
@ -71,6 +85,8 @@ except:
|
|||
sys.stderr.write("Could not connect to database\n");
|
||||
raise SystemExit
|
||||
|
||||
esc = db.escape_string
|
||||
|
||||
|
||||
# track what users/package names have been used
|
||||
#
|
||||
|
@ -226,6 +242,7 @@ if DBUG:
|
|||
if DBUG: print "Creating SQL statements for packages.",
|
||||
count = 0
|
||||
for p in seen_pkgs.keys():
|
||||
NOW = int(time.time())
|
||||
if count % 2 == 0:
|
||||
muid = developers[random.randrange(0,len(developers))]
|
||||
else:
|
||||
|
@ -240,12 +257,21 @@ for p in seen_pkgs.keys():
|
|||
uuid = genUID() # the submitter/user
|
||||
|
||||
s = "INSERT INTO Packages (ID, Name, Version, CategoryID, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, AURMaintainerUID) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d, %d);\n" % (seen_pkgs[p], p, genVersion(location_id),
|
||||
genCategory(), location_id, long(time.time()), uuid, uuid, muid)
|
||||
genCategory(), location_id, NOW, uuid, uuid, muid)
|
||||
out.write(s)
|
||||
if count % 100 == 0:
|
||||
if DBUG: print ".",
|
||||
count += 1
|
||||
|
||||
# create random comments for this package
|
||||
#
|
||||
num_comments = random.randrange(PKG_CMNTS[0], PKG_CMNTS[1])
|
||||
for i in range(0, num_comments):
|
||||
fortune = esc(commands.getoutput(FORTUNE_CMD).replace("'","").replace("\n"," "))
|
||||
now = NOW + random.randrange(400, 86400*3)
|
||||
s = "INSERT INTO PackageComments (PackageID, UsersID, Comments, CommentTS) VALUES (%d, %d, '%s', %d);\n" % (seen_pkgs[p], uuid, 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, URLPath, FSPath, FileSize) VALUES (%d, '%s', '%s', %d);\n" % (seen_pkgs[p], "PKGBUILD", "/home/aur/incoming/%s/PKGBUILD" % p,
|
||||
|
|
|
@ -209,7 +209,7 @@ if (isset($_REQUEST["do_Flag"])) {
|
|||
}
|
||||
}
|
||||
if (!empty($ids_to_delete)) {
|
||||
# TODO These are the packages that are safe to delete
|
||||
# These are the packages that are safe to delete
|
||||
#
|
||||
foreach ($ids_to_delete as $id) {
|
||||
# 1) delete from PackageVotes
|
||||
|
@ -228,8 +228,8 @@ if (isset($_REQUEST["do_Flag"])) {
|
|||
$q = "DELETE FROM PackageSources WHERE PackageID = " . $id;
|
||||
$result = db_query($q, $dbh);
|
||||
|
||||
# 5) delete from PackageUploadHistory
|
||||
$q = "DELETE FROM PackageUploadHistory WHERE PackageID = " . $id;
|
||||
# 5) delete from PackageComments
|
||||
$q = "DELETE FROM PackageComments WHERE PackageID = " . $id;
|
||||
$result = db_query($q, $dbh);
|
||||
|
||||
# 6) delete from Packages
|
||||
|
@ -239,6 +239,7 @@ if (isset($_REQUEST["do_Flag"])) {
|
|||
# TODO question: Now that the package as been deleted, does
|
||||
# the unsupported repo need to be regenerated?
|
||||
# ANSWER: No, there is no actual repo for unsupported, so no worries! (PJM)
|
||||
# TODO question: What about regenerating the AUR repo? (EJ)
|
||||
|
||||
# Print the success message
|
||||
print "<p>\n";
|
||||
|
@ -355,6 +356,12 @@ if (isset($_REQUEST["do_Flag"])) {
|
|||
$q.= $vote_clauses;
|
||||
db_query($q, $dbh);
|
||||
|
||||
# Update the LastVoted field for this user
|
||||
#
|
||||
$q = "UPDATE Users SET LastVoted = UNIX_TIMESTAMP() ";
|
||||
$q.= "WHERE ID = ".$uid;
|
||||
db_query($q, $dbh);
|
||||
|
||||
print "<p>\n";
|
||||
print __("Your votes have been cast for the selected packages.");
|
||||
print "</p>\n";
|
||||
|
|
|
@ -371,8 +371,8 @@ if ($_COOKIE["AURSID"]) {
|
|||
|
||||
# add upload history
|
||||
#
|
||||
$q = "INSERT INTO PackageUploadHistory ";
|
||||
$q.= "(PackageID, UsersID, Comments, UploadTS) VALUES (";
|
||||
$q = "INSERT INTO PackageComments ";
|
||||
$q.= "(PackageID, UsersID, Comments, CommentTS) VALUES (";
|
||||
$q.= $pdata["ID"] . ", " . uid_from_sid($_COOKIE['AURSID']);
|
||||
$q.= ", '" . mysql_escape_string($_REQUEST["comments"]);
|
||||
$q.= "', UNIX_TIMESTAMP())";
|
||||
|
@ -434,8 +434,8 @@ if ($_COOKIE["AURSID"]) {
|
|||
|
||||
# add upload history
|
||||
#
|
||||
$q = "INSERT INTO PackageUploadHistory ";
|
||||
$q.= "(PackageID, UsersID, Comments, UploadTS) VALUES (";
|
||||
$q = "INSERT INTO PackageComments ";
|
||||
$q.= "(PackageID, UsersID, Comments, CommentTS) VALUES (";
|
||||
$q.= $packageID . ", " . uid_from_sid($_COOKIE["AURSID"]) . ", '";
|
||||
$q.= mysql_escape_string($_REQUEST["comments"]);
|
||||
$q.= "', UNIX_TIMESTAMP())";
|
||||
|
|
Loading…
Add table
Reference in a new issue