From 47a24522b9ed1fd31ef635a068b3f270d3314377 Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:06:01 -0400 Subject: [PATCH 1/8] orbit: db: remove ses_setexpiry_token and query There are no callers for this function. Remove it from db.py --- orbit/db.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/orbit/db.py b/orbit/db.py index 82c16d9b..8d8b267c 100644 --- a/orbit/db.py +++ b/orbit/db.py @@ -43,14 +43,6 @@ def _get(cmd, reps=()): return _do(cmd, reps, get_=True) def ses_getby_token(tok): return _get(SES_GETBY_TOKEN, tok) -SES_SETEXPIRY_TOKEN = """ -UPDATE sessions -SET expiry = ? -WHERE token = ?; -""".strip() -def ses_setexpiry_token(tex): return _set(SES_SETEXPIRY_TOKEN, tex) - - SES_GETBY_USERNAME = """ SELECT token, username, expiry FROM sessions From 4bf79806949cf861d5a5bba8a6a8c0283cbbcc5a Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:09:25 -0400 Subject: [PATCH 2/8] orbit: db: remove unused queries related to submission table none of these queries are being used. Removing them will make it easier to implement the ORM which will make it easier to implement the dashboard. --- orbit/db.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/orbit/db.py b/orbit/db.py index 8d8b267c..79ab03fb 100644 --- a/orbit/db.py +++ b/orbit/db.py @@ -154,48 +154,6 @@ def usr_set_nolfx(usn): return _set(USR_SET_NOLFX, usn) def usr_getif_lfx_username(usn): return _get(USR_GETIF_LFX_USERNAME, usn) -# submission table interface - -SUB_GETFOR_USERNAME_ASN = """ -SELECT (submission_id, student_id, assignment_id, - submission_name, submission_grade, submission_comments) -FROM submissions -WHERE student_id = ? -AND assignment_id = ?; -""".strip() -def sub_getfor_username_asn(dub): return _get(SUB_GETFOR_USERNAME_ASN, dub) - - -SUB_GET = """ -SELECT * -FROM submissions; -""".strip() -def sub_get(): return _get(SUB_GET) - - -SUB_INS = """ -INSERT INTO submissions (sub_id, username, timestamp, _from, _to, email_ids, subjects) -VALUES (?,?,?,?,?,?,?); -""".strip() # NOQA: E501 -def sub_ins(sub): return _set(SUB_INS, sub) - - -SUB_GETBY_SUBID = """ -SELECT sub_id, username, timestamp, _from, _to, email_ids, subjects -FROM submissions -WHERE sub_id = ?; -""".strip() -def sub_getby_subid(sid): return _get(SUB_GETBY_SUBID, sid) - - -SUB_GETBY_USERNAME = """ -SELECT sub_id, username, timestamp, _from, _to, email_ids, subjects -FROM submissions -WHERE user = ?; -""".strip() -def sub_getby_username(usr): return _get(SUB_GETBY_USERNAME, usr) - - # assignment table interface ASN_GETBY_WID = """ From a9cce174a02a00d058d6aabf7afb027bf3819d1f Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:10:28 -0400 Subject: [PATCH 3/8] orbit: init db: submissions: remove submissions table Since there are no queries related to the table. It can be full removed. --- orbit/db.py | 1 - orbit/init-db.sql | 8 -------- 2 files changed, 9 deletions(-) diff --git a/orbit/db.py b/orbit/db.py index 79ab03fb..3e20b15f 100644 --- a/orbit/db.py +++ b/orbit/db.py @@ -3,7 +3,6 @@ # nickname table name # USR => users # ASN => assignments -# SUB => submissions # REG => newusers import sys diff --git a/orbit/init-db.sql b/orbit/init-db.sql index c116341b..22ee7e5b 100644 --- a/orbit/init-db.sql +++ b/orbit/init-db.sql @@ -10,14 +10,6 @@ CREATE TABLE sessions ( token string PRIMARY KEY, username string UNIQUE NOT NULL, expiry string NOT NULL); -CREATE TABLE submissions ( - sub_id string PRIMARY KEY, - username string NOT NULL, - time string NOT NULL, - _to string NOT NULL, - _from string NOT NULL, - email_ids string NOT NULL, - subjects string NOT NULL); CREATE TABLE assignments ( web_id string PRIMARY KEY, email_id string NOT NULL); From 397d29f5aad67b072381a55c8d3b535102e676e9 Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:13:14 -0400 Subject: [PATCH 4/8] orbit: hyperspace: remove -a and -z options for viewing assignments The assignments table is not currently used for anything but viewing. It cannot be updated and no other tables or functionality reference it. --- orbit/hyperspace.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/orbit/hyperspace.py b/orbit/hyperspace.py index db532c6d..ab22cec6 100755 --- a/orbit/hyperspace.py +++ b/orbit/hyperspace.py @@ -238,13 +238,6 @@ def hyperspace_main(raw_args): actions.add_argument('-q', '--queryuser', action='store_const', help='Get information about supplied username if valid', # NOQA: E501 dest='do', const=do_query_username) - actions.add_argument('-a', '--assignments', action='store_const', - help='Get the full assignment list', - dest='do', const=do_list_asn) - - actions.add_argument('-z', '--plaininboxes', action='store_const', - help='Get plain list of local submission inboxes', - dest='do', const=do_list_inbox) args = parser.parse_args(raw_args) if (args.do): From 2f88de0ec58752545f76853811f7ef2944b6773c Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:15:46 -0400 Subject: [PATCH 5/8] orbit: hyperspace: remove do_list_{asn,inbox} functions Since these functions are no longer called they and their format strings can be removed. --- orbit/hyperspace.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/orbit/hyperspace.py b/orbit/hyperspace.py index ab22cec6..c0835c6a 100755 --- a/orbit/hyperspace.py +++ b/orbit/hyperspace.py @@ -166,26 +166,6 @@ def do_list_sessions(args): session[0]) for session in raw_list])) -ASN_FMT = """ -{} submitted to mailbox {} -""".strip() - - -def do_list_asn(args): - raw_list = db.asn_get() - print('\n'.join([ASN_FMT.format(asn[0], asn[1]) for asn in raw_list])) - - -INBOX_FMT = """ -{} submitted to {}@{} -""".strip() - - -def do_list_inbox(args): - raw_list = db.asn_get() - print('\n'.join([asn[1] for asn in raw_list])) - - def hyperspace_main(raw_args): parser = argparse.ArgumentParser(prog='hyperspace', description='Administrate Orbit', From f830d18dcfa554d2fccc614567d98b0c60b9ec3c Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:17:49 -0400 Subject: [PATCH 6/8] orbit: db: remove asn_get{byweb_id,by_email_id,} functions Since these functions are not called from anywhere, they can be removed. --- orbit/db.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/orbit/db.py b/orbit/db.py index 3e20b15f..bd575124 100644 --- a/orbit/db.py +++ b/orbit/db.py @@ -153,31 +153,6 @@ def usr_set_nolfx(usn): return _set(USR_SET_NOLFX, usn) def usr_getif_lfx_username(usn): return _get(USR_GETIF_LFX_USERNAME, usn) -# assignment table interface - -ASN_GETBY_WID = """ -SELECT web_id, email_id -FROM assignments -WHERE web_id = ?; -""".strip() -def asn_getby_webid(wid): return _get(ASN_GETBY_WID, wid) - - -ASN_GETBY_EID = """ -SELECT web_id, email_id -FROM assignments -WHERE email_id = ?; -""".strip() -def asn_getby_email_id(eid): return _get(ASN_GETBY_EID, eid) - - -ASN_GET = """ -SELECT * -FROM assignments; -""".strip() -def asn_get(): return _get(ASN_GET) - - # registration table inferface REG_INS = """ From d1c0803a73a26c03404fb031bd78f0900adef791 Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:20:02 -0400 Subject: [PATCH 7/8] orbit: init db: assignments: remove assignments table Since this table is not reference anywhere, it can be removed. --- orbit/db.py | 1 - orbit/init-db.sql | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/orbit/db.py b/orbit/db.py index bd575124..01a401c1 100644 --- a/orbit/db.py +++ b/orbit/db.py @@ -2,7 +2,6 @@ import config # nickname table name # USR => users -# ASN => assignments # REG => newusers import sys diff --git a/orbit/init-db.sql b/orbit/init-db.sql index 22ee7e5b..d26c47b1 100644 --- a/orbit/init-db.sql +++ b/orbit/init-db.sql @@ -10,21 +10,9 @@ CREATE TABLE sessions ( token string PRIMARY KEY, username string UNIQUE NOT NULL, expiry string NOT NULL); -CREATE TABLE assignments ( - web_id string PRIMARY KEY, - email_id string NOT NULL); CREATE TABLE newusers ( registration_id integer primary key, student_id string UNIQUE NOT NULL, username string UNIQUE NOT NULL, password string NOT NULL); -INSERT INTO assignments (web_id, email_id) VALUES ('setup', 'introductions'); -INSERT INTO assignments (web_id, email_id) VALUES ('E0', 'exercise0'); -INSERT INTO assignments (web_id, email_id) VALUES ('E1', 'exercise1'); -INSERT INTO assignments (web_id, email_id) VALUES ('E2', 'exercise2'); -INSERT INTO assignments (web_id, email_id) VALUES ('P0', 'programming0'); -INSERT INTO assignments (web_id, email_id) VALUES ('P1', 'programming1'); -INSERT INTO assignments (web_id, email_id) VALUES ('P2', 'programming2'); -INSERT INTO assignments (web_id, email_id) VALUES ('F0', 'final0'); -INSERT INTO assignments (web_id, email_id) VALUES ('F1', 'final1'); COMMIT; From 3f67086aff03be6429cfd04e3ef545b863076af5 Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:21:12 -0400 Subject: [PATCH 8/8] orbit: db: nit: introduce missing explanation for SES nickname All the other tables have nicknames that are explained. --- orbit/db.py | 1 + 1 file changed, 1 insertion(+) diff --git a/orbit/db.py b/orbit/db.py index 01a401c1..e5f414a2 100644 --- a/orbit/db.py +++ b/orbit/db.py @@ -2,6 +2,7 @@ import config # nickname table name # USR => users +# SES => sessions # REG => newusers import sys