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

Update db scripts and updates

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