DASSL / ClassDB

An open-source system to let students experiment with relational data
https://dassl.github.io/ClassDB/
Other
7 stars 2 forks source link

Fix user view #172

Closed smurthys closed 6 years ago

smurthys commented 6 years ago

Commit e673c33 fixes #169.

Commit 6ac9b41 fixes #171. It also:

smurthys commented 6 years ago

Here is a quick test I used (there isn't a proper unit test for this script in the repo):

--create 4 users: students s1, s2; instr i1: dbman d1
SELECT ClassDB.createStudent('s1', 's1 name');
SELECT ClassDB.createStudent('s2', 's2 name');
SELECT ClassDB.createInstructor('i1', 'i1 name');
SELECT ClassDB.createDBManager('d1', 'd1 name');

--create a team t1: should not be in User view
SELECT ClassDB.createRole('t1', 't1 name', TRUE);

--clear the activity tables
TRUNCATE ClassDB.ConnectionActivity;
TRUNCATE ClassDB.DDLActivity;

--add connection activities: 1 for s1, none for s2 and d1, 2 for i1
INSERT INTO ClassDB.ConnectionActivity VALUES
('s1', TIMESTAMP '2018-01-01 10:23:54'),
('i1', TIMESTAMP '2018-01-01 01:10:00'),
('i1', TIMESTAMP '2018-01-05 13:41:56');

--add ddl activies:
-- 4 for s1: two of them with the same timestamp
-- 1 for s2 (not ordinarily possible if s2 has no connections)
-- none for i1 and d1
INSERT INTO ClassDB.DDLActivity VALUES
('s1', TIMESTAMP '2018-01-01 10:25:13', 'CREATE TABLE', 'public.x'),
('s1', TIMESTAMP '2018-01-01 10:32:16', 'DROP TABLE', 'public.x'),
('s1', TIMESTAMP '2018-01-01 10:46:54', 'CREATE SCHEMA', 'why_not'),
('s1', TIMESTAMP '2018-01-01 10:46:54', 'DROP TABLE', 'dupe_activity'),
('s2', TIMESTAMP '2018-01-04 01:22:00', 'CREATE VIEW', 'public.v');

SELECT * FROM ClassDB.User;
SELECT * FROM ClassDB.Instructor;
SELECT * FROM ClassDB.Student;
SELECT * FROM ClassDB.DBManager;
smurthys commented 6 years ago

Thanks all for the prompt review.