Commit bef9ab4e authored by Hiro's avatar Hiro 🏄
Browse files

Update db scripts and updates

parent ae37e312
......@@ -209,6 +209,7 @@ class EmailParser(object):
id=request['id'],
command=request['command'],
platform=request['platform'],
language=request['language'],
service=request['service'],
date=now_str,
status="ONHOLD",
......
......@@ -164,7 +164,7 @@ class Sendmail(object):
log.info("Getting links for {}.".format(platform))
links = yield self.conn.get_links(
platform=platform, status="ACTIVE"
platform=platform, language=language, status="ACTIVE"
)
# build message
......
......@@ -41,14 +41,14 @@ class SQLite3(object):
log.msg("Database error: {}".format(error))
return None
def new_request(self, id, command, service, platform, date, status):
def new_request(self, id, command, service, platform, language, date, status):
"""
Perform a new request to the database
"""
query = "INSERT INTO requests VALUES(?, ?, ?, ?, ?, ?)"
return self.dbpool.runQuery(
query, (id, command, platform, service, date, status)
query, (id, command, platform, language, service, date, status)
).addCallback(self.query_callback).addErrback(self.query_errback)
def get_requests(self, status, command, service):
......
......@@ -102,7 +102,7 @@ def main():
for l in languages:
release_link = releases.get(k).replace("en-US", l)
c.execute(
"INSERT INTO links(link, platform, arch, version, provider, status)"
"INSERT INTO links(link, platform, language, arch, version, provider, status)"
"VALUES ('%s', '%s', '64', '%s', '%s', 'ACTIVE')" %(providers.get(p) + release_link, k, version, p))
......
......@@ -83,15 +83,15 @@ def main():
c.execute("DROP TABLE IF EXISTS stats")
c.execute(
"CREATE TABLE requests(id TEXT, command TEXT, platform TEXT,"
" service TEXT, date TEXT, status TEXT)"
" language TEXT, service TEXT, date TEXT, status TEXT)"
)
c.execute(
"CREATE TABLE links(link TEXT, platform TEXT, arch TEXT,"
" version TEXT, provider TEXT, status TEXT)"
"CREATE TABLE links(link TEXT, platform TEXT, language TEXT,"
" arch TEXT, version TEXT, provider TEXT, status TEXT)"
)
c.execute(
"CREATE TABLE stats(num_requests NUMBER, platform TEXT, "
"command TEXT, service TEXT, date TEXT)"
"CREATE TABLE stats(num_requests NUMBER, platform TEXT,"
" language TEXT, command TEXT, service TEXT, date TEXT)"
)
print("Database {} created.".format(abs_filename))
elif args.clear:
......@@ -116,17 +116,17 @@ def main():
c.execute("DROP TABLE IF EXISTS stats")
c.execute(
"CREATE TABLE requests(id TEXT, command TEXT, "
"platform TEXT, service TEXT, date TEXT, status TEXT,"
"platform TEXT, language TEXT, service TEXT, date TEXT, status TEXT,"
"PRIMARY KEY(id, date))"
)
c.execute(
"CREATE TABLE links(link TEXT, platform TEXT, "
"CREATE TABLE links(link TEXT, platform TEXT, language TEXT,"
"arch TEXT, version TEXT, provider TEXT, status TEXT,"
"PRIMARY KEY(platform, arch, version, provider, status))"
)
c.execute(
"CREATE TABLE stats(date TEXT PRIMARY KEY, "
"num_requests INTEGER, platform TEXT, command TEXT, "
"num_requests INTEGER, platform TEXT, language TEXT, command TEXT, "
"service TEXT)"
)
print("New database {} created.".format(abs_filename))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment