diff --git a/CSV_source.py b/CSV_source.py index 2cd0da7..841e5c0 100644 --- a/CSV_source.py +++ b/CSV_source.py @@ -25,7 +25,6 @@ def load_csv(tablename): await loader.employer(load_csv("employer")) await loader.user(load_csv("user")) await loader.instrument(load_csv("instrument")) - await loader.cycle(load_csv("cycle")) await loader.proposal(load_csv("proposal")) await loader.experiment(load_csv("experiment")) await loader.experiment_user(load_csv("experiment_user")) diff --git a/History.md b/History.md index 379509e..5eaa54a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +2.0.2 30/09/2021 +================ + * Remove Cycle table + 2.0.1 16/07/2021 ================ diff --git a/loader.py b/loader.py index 5dca3b3..e1ae139 100644 --- a/loader.py +++ b/loader.py @@ -22,34 +22,11 @@ async def clean(self): await self.conn.execute("delete from experiment_user;") await self.conn.execute("delete from experiment where id not in (select distinct experiment_id from instance_experiment);") await self.conn.execute("delete from proposal where id not in (select distinct proposal_id from experiment);") - await self.conn.execute("delete from cycle where id not in (select distinct cycle_id from experiment)") await self.conn.execute("delete from instrument where id not in (select distinct instrument_id from experiment);") await self.conn.execute("delete from users where id not in (select distinct user_id from instance_command union select distinct user_id from instance_member union select distinct user_id from instance_session_member union select distinct user_id from user_role);") await self.conn.execute("delete from employer where id not in (select distinct affiliation_id from users);") print("everything cleaned") - async def cycle(self, cycles): - async with self.conn.transaction(): - inserted = 0 - updated = 0 - total_lines = 0 - for cycle in cycles: - res = await self.conn.execute( - """INSERT INTO cycle (id, name, start_date, end_date) - VALUES ($1, $2, $3, $4) - ON CONFLICT (id) DO UPDATE - SET name = $2, start_date=$3, end_date=$4""", - int(cycle['id']), - cycle['name'], - cycle['start_date'], - cycle['end_date'] - ) - response_parsed = self.parse_response_reg.match(res) - inserted += int(response_parsed.group(1)) - updated += int(response_parsed.group(2)) - total_lines += 1 - print("Cycle : INSERT {0} UPDATE {1} TOTAL {2}".format(inserted, updated, total_lines)) - async def employer(self, employers): async with self.conn.transaction(): inserted = 0 @@ -79,13 +56,12 @@ async def experiment(self, experiments): total_lines = 0 for experiment in experiments: res = await self.conn.execute( - """INSERT INTO experiment (id, proposal_id, cycle_id, instrument_id) + """INSERT INTO experiment (id, proposal_id, instrument_id) VALUES ($1, $2, $3, $4) ON CONFLICT (id) DO UPDATE - SET proposal_id = $2, cycle_id=$3, instrument_id=$4""", + SET proposal_id = $2, instrument_id=$4""", experiment['id'], int(experiment['proposal_id']), - int(experiment['cycle_id']), int(experiment['instrument_id']) ) response_parsed = self.parse_response_reg.match(res) diff --git a/schema.sql b/schema.sql index 96a8a91..d773abf 100644 --- a/schema.sql +++ b/schema.sql @@ -29,16 +29,6 @@ create table if not exists configuration value varchar(8192) not null ); -create table if not exists cycle -( - id bigint not null - constraint cycle_pkey - primary key, - end_date timestamp not null, - name varchar(100) not null, - start_date timestamp not null -); - create table if not exists employer ( id bigint not null @@ -206,9 +196,6 @@ create table if not exists experiment id varchar(32) not null constraint experiment_pkey primary key, - cycle_id bigint not null - constraint fk_cycle_id - references cycle, instrument_id bigint not null constraint fk_instrument_id references instrument,