From 1b7a0301d8c1dd8c3dc76a4d2039ba65fff1e9b9 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 7 Apr 2017 12:38:29 -0700 Subject: [PATCH 1/9] another function for unit testing: return location for given ag_login_id --- amgut/lib/data_access/ag_data_access.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/amgut/lib/data_access/ag_data_access.py b/amgut/lib/data_access/ag_data_access.py index f0349710..9baa4113 100644 --- a/amgut/lib/data_access/ag_data_access.py +++ b/amgut/lib/data_access/ag_data_access.py @@ -1266,3 +1266,33 @@ def ut_get_ag_login_id_from_barcode(self, barcode): if not info: raise ValueError('Barcode "%s" not in DB' % barcode) return info[0][0] + + def ut_get_location(self, ag_login_id): + """Get kit registration information + + Parameters + ---------- + ag_login_id : str + A valid login ID, that should be a test as a valid UUID + + Returns + ------- + list of dict + A list of registration information associated with a common login + ID. + + Raises + ------ + ValueError + Unknown ag_login_id passed + """ + with TRN: + sql = """SELECT latitude, longitude, elevation, cannot_geocode + FROM ag_login + WHERE ag_login_id = %s""" + TRN.add(sql, [ag_login_id]) + info = TRN.execute_fetchindex() + if not info: + raise ValueError('ag_login_id not in database: %s' % + ag_login_id) + return [dict(row) for row in info][0] From 2bf41e68ba634a8d0d3887434e87b97d43d853e5 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 7 Apr 2017 13:03:26 -0700 Subject: [PATCH 2/9] docstr + skipping None address fields --- amgut/lib/geocode.py | 104 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 amgut/lib/geocode.py diff --git a/amgut/lib/geocode.py b/amgut/lib/geocode.py new file mode 100644 index 00000000..158f77a5 --- /dev/null +++ b/amgut/lib/geocode.py @@ -0,0 +1,104 @@ +# from amgut.lib.data_access.ag_data_access import AGDataAccess +import geocoder +import requests + +from amgut.lib.data_access.sql_connection import TRN + + +def geocode_aglogins(ag_login_ids, force=False): + """ Retriev locations for one or more ag_login_ids and stores results in DB + + Parameters + ---------- + ag_login_ids : str or [str] + A single ag_login_id or a list of ag_login_ids for which locations + should be retrieved. + force : bool + If True, locations are retrieved from the geoservice even if we already + have them in our DB. Useful, if locations needs to be updated. + Default = False. + + Returns + ------- + Stats about location lookups: dict {sucessful, cannot_geocode, checked, + provided}, where + - provided: is the number of passed ag_login_ids + - checked: the number of ag_login_ids for which location retrieval was + executed (sucessful or not). This number might be <= "provided", + since we do not look-up ag_login_ids which already have + latitude, longitude, elevation and cannot_geocode=False + in our DB. + - sucessful: number of successfully retrieved locations, + which is <= "checked" + - cannot_geocode: number of successfully retrieved locations, which is <= + "checked". + """ + # if only one ag_login_id is passed as a string, we convert it to a one + # element list to be compatible with the following code. + if type(ag_login_ids) == str: + ag_login_ids = [ag_login_ids] + + # check with ag_logins are present in our DB for the given list of + # ag_login_ids + sql = """SELECT ag_login_id, address, zip, city, state, country + FROM ag.ag_login + WHERE ag_login_id in %s""" + # skip ag_logins if we already have lat,long,elev in our DB unless we + # enforce an update + if force is False: + sql += """AND (latitude IS NULL + OR longitude IS NULL + OR elevation IS NULL)""" + + sql_update = """UPDATE ag.ag_login + SET latitude = %s, + longitude = %s, + elevation = %s, + cannot_geocode = %s + WHERE ag_login_id = %s""" + + stats = {'successful': 0, + 'cannot_geocode': 0, + 'checked': 0, + 'provided': len(ag_login_ids)} + + with TRN: + TRN.add(sql, [tuple(ag_login_ids)]) + + # FROM: + # In case you have several addresses to encode, to use persistent HTTP + # connection as recommended by the request-library http://docs.python- + # requests.org/en/master/user/advanced/#session-objects you might use + # the following: + with requests.Session() as session: + for address in TRN.execute_fetchindex(): + lat, lng, elev, cannot_geocode = None, None, None, None + # lookup lat,lng by address + address_str = " ".join([x for x in address[1:] + if x is not None]) + g = geocoder.google(address_str, session=session) + # only continue if we got a valid result + if g.error is None: + lat, lng = g.latlng + # lookup elevation in a second call + e = geocoder.elevation(g.latlng, session=session) + # only continue if we got a valid result + if e.error is None: + elev = e.elevation + else: + cannot_geocode = 'Y' + else: + cannot_geocode = 'Y' + + if cannot_geocode == 'Y': + stats['cannot_geocode'] += 1 + else: + stats['successful'] += 1 + stats['checked'] += 1 + + # update the database with results we just obtained + TRN.add(sql_update, + [lat, lng, elev, cannot_geocode, address[0]]) + TRN.execute() + + return stats From 43133bbcfba578e4c2248d4446b7df6b58ff7073 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 7 Apr 2017 13:03:51 -0700 Subject: [PATCH 3/9] made sure to use unique ag_login_ids to avoid execution order conflicts --- amgut/lib/test/test_geocoder.py | 118 ++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 amgut/lib/test/test_geocoder.py diff --git a/amgut/lib/test/test_geocoder.py b/amgut/lib/test/test_geocoder.py new file mode 100644 index 00000000..25290329 --- /dev/null +++ b/amgut/lib/test/test_geocoder.py @@ -0,0 +1,118 @@ +from unittest import TestCase, main +from amgut.lib.util import (rollback) +# from amgut.lib.data_access.ag_data_access import AGDataAccess +from amgut.lib.geocode import geocode_aglogins +from amgut.lib.data_access.ag_data_access import AGDataAccess + + +class TestGeocoder(TestCase): + def setUp(self): + self.ag_data = AGDataAccess() + + def tearDown(self): + del self.ag_data + + @classmethod + def setUpClass(cls): + cls.ag_logins = ["00164c87-73b3-deb2-e050-8a800c5d54e1", + "001b21ee-85a2-457c-adf6-492b42134376", + "0023cc03-3332-eec6-e050-8a800c5d3c04", + "d8592c74-967c-2135-e040-8a80115d6401", + "15370442-313f-452f-bf5b-cd155e3deefe"] + + @rollback + def test_force(self): + # test if force leads to updating existing locations in DB + logins = ["578f5c16-c8e3-40a4-a618-9661605678b0", + "d8592c74-8037-2135-e040-8a80115d6401", + "d8592c74-803a-2135-e040-8a80115d6401", + "884cba01-9d8a-4beb-816f-c74d85fb7227"] + login_id = self.ag_data.addAGLogin('notis2r4ndb@sdjlhsd.dkzdj', + 'kurtasjuergen', + 'skdgaasisdf', '', '', '', '') + logins.append(login_id) + obs = geocode_aglogins(logins, force=True) + exp = {'successful': 4, 'provided': 5, 'cannot_geocode': 1, + 'checked': 5} + self.assertEqual(obs, exp) + + @rollback + def test_multiple(self): + logins = ["00164c87-73b3-deb2-e050-8a800c5d54e1", + "001b21ee-85a2-457c-adf6-492b42134376", + "0023cc03-3332-eec6-e050-8a800c5d3c04", + "d8592c74-967c-2135-e040-8a80115d6401", + "15370442-313f-452f-bf5b-cd155e3deefe"] + login_id = self.ag_data.addAGLogin('notinasdb@sdjlhsd.dkzdj', + 'kurtjsuergen', + 'skdgsssisdf', '', '', '', '') + logins.append(login_id) + obs = geocode_aglogins(logins) + exp = {'successful': 1, 'provided': 6, 'cannot_geocode': 3, + 'checked': 4} + self.assertEqual(obs, exp) + + @rollback + def test_cannot_geocode(self): + # check that a fantasy address cannot be geocoded. + # Therefore we first need to insert a new ag_login_id + login_id = self.ag_data.addAGLogin('notindb@sdjlhsd.dkzdj', + 'kurtjuergen', + 'skdgsisdf', '', '', '', '') + old_loc = self.ag_data.ut_get_location(login_id) + self.assertEqual(old_loc, {'latitude': None, + 'cannot_geocode': None, + 'elevation': None, + 'longitude': None}) + obs = geocode_aglogins(login_id) + exp = {'successful': 0, 'provided': 1, 'cannot_geocode': 1, + 'checked': 1} + self.assertItemsEqual(obs, exp) + new_loc = self.ag_data.ut_get_location(login_id) + self.assertEqual(new_loc, {'latitude': None, + 'cannot_geocode': 'Y', + 'elevation': None, + 'longitude': None}) + + # test that geocoding is re-done + obs = geocode_aglogins(login_id) + self.assertEqual(obs, exp) + + @rollback + def test_update(self): + # an ag_login_id without a location gets a new location assigned + login_id = "000c8c03-54f4-4b21-b1fd-871f745220f9" + old_loc = self.ag_data.ut_get_location(login_id) + self.assertEqual(old_loc, {'latitude': None, + 'cannot_geocode': None, + 'elevation': None, + 'longitude': None}) + obs = geocode_aglogins(login_id) + exp = {'successful': 1, 'provided': 1, 'cannot_geocode': 0, + 'checked': 1} + self.assertItemsEqual(obs, exp) + new_loc = self.ag_data.ut_get_location(login_id) + self.assertEqual(new_loc, {'latitude': 51.6442244, + 'cannot_geocode': None, + 'elevation': 73.0654067993164, + 'longitude': -0.1730126}) + + @rollback + def test_noupdate(self): + # an ag_login_id already with location does not get updated + login_id = "000fc4cd-8fa4-db8b-e050-8a800c5d02b5" + old_loc = self.ag_data.ut_get_location(login_id) + self.assertEqual(old_loc, {'latitude': 30.2118141, + 'cannot_geocode': None, + 'elevation': 288.64208984375, + 'longitude': -97.8909407}) + obs = geocode_aglogins(login_id) + exp = {'successful': 0, 'provided': 1, 'cannot_geocode': 0, + 'checked': 0} + self.assertItemsEqual(obs, exp) + new_loc = self.ag_data.ut_get_location(login_id) + self.assertEqual(new_loc, old_loc) + + +if __name__ == '__main__': + main() From 286152eeee93dfc4f8a1baf2d884f9ba67e6e8a6 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 5 May 2017 09:11:02 -0700 Subject: [PATCH 4/9] since we drop the whole table ag.promoted_survey_ids, there is no longer need to delete individual entries. --- amgut/db/patches/0041.sql | 23 +++++++++++++++++++++++ amgut/lib/data_access/ag_data_access.py | 3 --- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 amgut/db/patches/0041.sql diff --git a/amgut/db/patches/0041.sql b/amgut/db/patches/0041.sql new file mode 100644 index 00000000..7ed3b9f7 --- /dev/null +++ b/amgut/db/patches/0041.sql @@ -0,0 +1,23 @@ +-- May 5th, 2017 +-- Stefan Janssen + +-- remove tables identified as no longer used in our code base. Most likely, they are left overs from the transition from Oracle to Postgres + +-- tables whose names do not show up in codebases of american-gut-web and labadmin (grep name *.py -i) +DROP TABLE ag.ag_animal_survey; +DROP TABLE ag.ag_human_survey; +DROP TABLE ag.ag_import_stats_tmp; +DROP TABLE ag.ag_map_markers; +DROP TABLE ag.ag_participant_exceptions; +DROP TABLE ag.ag_survey_answer; +DROP TABLE ag.ag_survey_multiples; +DROP TABLE ag.ag_survey_multiples_backup; +DROP TABLE barcodes.barcode_exceptions; +DROP TABLE ag.controlled_vocab_values; +DROP TABLE ag.controlled_vocabs; + +-- we only delete information from this table, but never read or write. Can't we simply delete the full table then? +DROP TABLE ag.promoted_survey_ids; + +-- a table we only read from, but never write. Thus, it is static. Can't we correct information elsewhere and get rid of this table? +--DROP TABLE ag.duplicate_consents; diff --git a/amgut/lib/data_access/ag_data_access.py b/amgut/lib/data_access/ag_data_access.py index 9baa4113..1dd9a112 100644 --- a/amgut/lib/data_access/ag_data_access.py +++ b/amgut/lib/data_access/ag_data_access.py @@ -322,9 +322,6 @@ def deleteAGParticipantSurvey(self, ag_login_id, participant_name): participant_name): self.deleteSample(info['barcode'], ag_login_id) - sql = "DELETE FROM promoted_survey_ids WHERE survey_id IN %s" - TRN.add(sql, [tuple(survey_ids)]) - # Delete last due to foreign keys sql = "DELETE FROM ag_kit_barcodes WHERE survey_id IN %s" TRN.add(sql, [tuple(survey_ids)]) From ddf5075052e1a9cea58b22905f524f1aa889d29f Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 5 May 2017 10:23:00 -0700 Subject: [PATCH 5/9] added further doc --- amgut/db/patches/0041.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/amgut/db/patches/0041.sql b/amgut/db/patches/0041.sql index 7ed3b9f7..bc96e237 100644 --- a/amgut/db/patches/0041.sql +++ b/amgut/db/patches/0041.sql @@ -20,4 +20,5 @@ DROP TABLE ag.controlled_vocabs; DROP TABLE ag.promoted_survey_ids; -- a table we only read from, but never write. Thus, it is static. Can't we correct information elsewhere and get rid of this table? +-- see discussion: https://github.com/biocore/american-gut-web/issues/669 --DROP TABLE ag.duplicate_consents; From f17d6b765e8beed35f47b746a0ccf8b8965f7518 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 5 May 2017 10:27:18 -0700 Subject: [PATCH 6/9] removing geocode stuff --- amgut/lib/data_access/ag_data_access.py | 30 ------ amgut/lib/geocode.py | 104 --------------------- amgut/lib/test/test_geocoder.py | 118 ------------------------ 3 files changed, 252 deletions(-) delete mode 100644 amgut/lib/geocode.py delete mode 100644 amgut/lib/test/test_geocoder.py diff --git a/amgut/lib/data_access/ag_data_access.py b/amgut/lib/data_access/ag_data_access.py index 1dd9a112..67101728 100644 --- a/amgut/lib/data_access/ag_data_access.py +++ b/amgut/lib/data_access/ag_data_access.py @@ -1263,33 +1263,3 @@ def ut_get_ag_login_id_from_barcode(self, barcode): if not info: raise ValueError('Barcode "%s" not in DB' % barcode) return info[0][0] - - def ut_get_location(self, ag_login_id): - """Get kit registration information - - Parameters - ---------- - ag_login_id : str - A valid login ID, that should be a test as a valid UUID - - Returns - ------- - list of dict - A list of registration information associated with a common login - ID. - - Raises - ------ - ValueError - Unknown ag_login_id passed - """ - with TRN: - sql = """SELECT latitude, longitude, elevation, cannot_geocode - FROM ag_login - WHERE ag_login_id = %s""" - TRN.add(sql, [ag_login_id]) - info = TRN.execute_fetchindex() - if not info: - raise ValueError('ag_login_id not in database: %s' % - ag_login_id) - return [dict(row) for row in info][0] diff --git a/amgut/lib/geocode.py b/amgut/lib/geocode.py deleted file mode 100644 index 158f77a5..00000000 --- a/amgut/lib/geocode.py +++ /dev/null @@ -1,104 +0,0 @@ -# from amgut.lib.data_access.ag_data_access import AGDataAccess -import geocoder -import requests - -from amgut.lib.data_access.sql_connection import TRN - - -def geocode_aglogins(ag_login_ids, force=False): - """ Retriev locations for one or more ag_login_ids and stores results in DB - - Parameters - ---------- - ag_login_ids : str or [str] - A single ag_login_id or a list of ag_login_ids for which locations - should be retrieved. - force : bool - If True, locations are retrieved from the geoservice even if we already - have them in our DB. Useful, if locations needs to be updated. - Default = False. - - Returns - ------- - Stats about location lookups: dict {sucessful, cannot_geocode, checked, - provided}, where - - provided: is the number of passed ag_login_ids - - checked: the number of ag_login_ids for which location retrieval was - executed (sucessful or not). This number might be <= "provided", - since we do not look-up ag_login_ids which already have - latitude, longitude, elevation and cannot_geocode=False - in our DB. - - sucessful: number of successfully retrieved locations, - which is <= "checked" - - cannot_geocode: number of successfully retrieved locations, which is <= - "checked". - """ - # if only one ag_login_id is passed as a string, we convert it to a one - # element list to be compatible with the following code. - if type(ag_login_ids) == str: - ag_login_ids = [ag_login_ids] - - # check with ag_logins are present in our DB for the given list of - # ag_login_ids - sql = """SELECT ag_login_id, address, zip, city, state, country - FROM ag.ag_login - WHERE ag_login_id in %s""" - # skip ag_logins if we already have lat,long,elev in our DB unless we - # enforce an update - if force is False: - sql += """AND (latitude IS NULL - OR longitude IS NULL - OR elevation IS NULL)""" - - sql_update = """UPDATE ag.ag_login - SET latitude = %s, - longitude = %s, - elevation = %s, - cannot_geocode = %s - WHERE ag_login_id = %s""" - - stats = {'successful': 0, - 'cannot_geocode': 0, - 'checked': 0, - 'provided': len(ag_login_ids)} - - with TRN: - TRN.add(sql, [tuple(ag_login_ids)]) - - # FROM: - # In case you have several addresses to encode, to use persistent HTTP - # connection as recommended by the request-library http://docs.python- - # requests.org/en/master/user/advanced/#session-objects you might use - # the following: - with requests.Session() as session: - for address in TRN.execute_fetchindex(): - lat, lng, elev, cannot_geocode = None, None, None, None - # lookup lat,lng by address - address_str = " ".join([x for x in address[1:] - if x is not None]) - g = geocoder.google(address_str, session=session) - # only continue if we got a valid result - if g.error is None: - lat, lng = g.latlng - # lookup elevation in a second call - e = geocoder.elevation(g.latlng, session=session) - # only continue if we got a valid result - if e.error is None: - elev = e.elevation - else: - cannot_geocode = 'Y' - else: - cannot_geocode = 'Y' - - if cannot_geocode == 'Y': - stats['cannot_geocode'] += 1 - else: - stats['successful'] += 1 - stats['checked'] += 1 - - # update the database with results we just obtained - TRN.add(sql_update, - [lat, lng, elev, cannot_geocode, address[0]]) - TRN.execute() - - return stats diff --git a/amgut/lib/test/test_geocoder.py b/amgut/lib/test/test_geocoder.py deleted file mode 100644 index 25290329..00000000 --- a/amgut/lib/test/test_geocoder.py +++ /dev/null @@ -1,118 +0,0 @@ -from unittest import TestCase, main -from amgut.lib.util import (rollback) -# from amgut.lib.data_access.ag_data_access import AGDataAccess -from amgut.lib.geocode import geocode_aglogins -from amgut.lib.data_access.ag_data_access import AGDataAccess - - -class TestGeocoder(TestCase): - def setUp(self): - self.ag_data = AGDataAccess() - - def tearDown(self): - del self.ag_data - - @classmethod - def setUpClass(cls): - cls.ag_logins = ["00164c87-73b3-deb2-e050-8a800c5d54e1", - "001b21ee-85a2-457c-adf6-492b42134376", - "0023cc03-3332-eec6-e050-8a800c5d3c04", - "d8592c74-967c-2135-e040-8a80115d6401", - "15370442-313f-452f-bf5b-cd155e3deefe"] - - @rollback - def test_force(self): - # test if force leads to updating existing locations in DB - logins = ["578f5c16-c8e3-40a4-a618-9661605678b0", - "d8592c74-8037-2135-e040-8a80115d6401", - "d8592c74-803a-2135-e040-8a80115d6401", - "884cba01-9d8a-4beb-816f-c74d85fb7227"] - login_id = self.ag_data.addAGLogin('notis2r4ndb@sdjlhsd.dkzdj', - 'kurtasjuergen', - 'skdgaasisdf', '', '', '', '') - logins.append(login_id) - obs = geocode_aglogins(logins, force=True) - exp = {'successful': 4, 'provided': 5, 'cannot_geocode': 1, - 'checked': 5} - self.assertEqual(obs, exp) - - @rollback - def test_multiple(self): - logins = ["00164c87-73b3-deb2-e050-8a800c5d54e1", - "001b21ee-85a2-457c-adf6-492b42134376", - "0023cc03-3332-eec6-e050-8a800c5d3c04", - "d8592c74-967c-2135-e040-8a80115d6401", - "15370442-313f-452f-bf5b-cd155e3deefe"] - login_id = self.ag_data.addAGLogin('notinasdb@sdjlhsd.dkzdj', - 'kurtjsuergen', - 'skdgsssisdf', '', '', '', '') - logins.append(login_id) - obs = geocode_aglogins(logins) - exp = {'successful': 1, 'provided': 6, 'cannot_geocode': 3, - 'checked': 4} - self.assertEqual(obs, exp) - - @rollback - def test_cannot_geocode(self): - # check that a fantasy address cannot be geocoded. - # Therefore we first need to insert a new ag_login_id - login_id = self.ag_data.addAGLogin('notindb@sdjlhsd.dkzdj', - 'kurtjuergen', - 'skdgsisdf', '', '', '', '') - old_loc = self.ag_data.ut_get_location(login_id) - self.assertEqual(old_loc, {'latitude': None, - 'cannot_geocode': None, - 'elevation': None, - 'longitude': None}) - obs = geocode_aglogins(login_id) - exp = {'successful': 0, 'provided': 1, 'cannot_geocode': 1, - 'checked': 1} - self.assertItemsEqual(obs, exp) - new_loc = self.ag_data.ut_get_location(login_id) - self.assertEqual(new_loc, {'latitude': None, - 'cannot_geocode': 'Y', - 'elevation': None, - 'longitude': None}) - - # test that geocoding is re-done - obs = geocode_aglogins(login_id) - self.assertEqual(obs, exp) - - @rollback - def test_update(self): - # an ag_login_id without a location gets a new location assigned - login_id = "000c8c03-54f4-4b21-b1fd-871f745220f9" - old_loc = self.ag_data.ut_get_location(login_id) - self.assertEqual(old_loc, {'latitude': None, - 'cannot_geocode': None, - 'elevation': None, - 'longitude': None}) - obs = geocode_aglogins(login_id) - exp = {'successful': 1, 'provided': 1, 'cannot_geocode': 0, - 'checked': 1} - self.assertItemsEqual(obs, exp) - new_loc = self.ag_data.ut_get_location(login_id) - self.assertEqual(new_loc, {'latitude': 51.6442244, - 'cannot_geocode': None, - 'elevation': 73.0654067993164, - 'longitude': -0.1730126}) - - @rollback - def test_noupdate(self): - # an ag_login_id already with location does not get updated - login_id = "000fc4cd-8fa4-db8b-e050-8a800c5d02b5" - old_loc = self.ag_data.ut_get_location(login_id) - self.assertEqual(old_loc, {'latitude': 30.2118141, - 'cannot_geocode': None, - 'elevation': 288.64208984375, - 'longitude': -97.8909407}) - obs = geocode_aglogins(login_id) - exp = {'successful': 0, 'provided': 1, 'cannot_geocode': 0, - 'checked': 0} - self.assertItemsEqual(obs, exp) - new_loc = self.ag_data.ut_get_location(login_id) - self.assertEqual(new_loc, old_loc) - - -if __name__ == '__main__': - main() From 268efbecd8c83c50fb455ce787cb08977a4cc8d2 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 5 May 2017 10:36:48 -0700 Subject: [PATCH 7/9] removed commented code --- amgut/db/patches/0041.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/amgut/db/patches/0041.sql b/amgut/db/patches/0041.sql index bc96e237..640e90d2 100644 --- a/amgut/db/patches/0041.sql +++ b/amgut/db/patches/0041.sql @@ -18,7 +18,3 @@ DROP TABLE ag.controlled_vocabs; -- we only delete information from this table, but never read or write. Can't we simply delete the full table then? DROP TABLE ag.promoted_survey_ids; - --- a table we only read from, but never write. Thus, it is static. Can't we correct information elsewhere and get rid of this table? --- see discussion: https://github.com/biocore/american-gut-web/issues/669 ---DROP TABLE ag.duplicate_consents; From b1274cc276b748baecd92768d4fd0d523f78f753 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 5 May 2017 16:23:49 -0700 Subject: [PATCH 8/9] update of the schema file --- amgut/db/ag.dbs | 344 +++++------------------------------------------- 1 file changed, 35 insertions(+), 309 deletions(-) diff --git a/amgut/db/ag.dbs b/amgut/db/ag.dbs index ab1ab7e7..b5dee3fa 100644 --- a/amgut/db/ag.dbs +++ b/amgut/db/ag.dbs @@ -1,35 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -89,140 +60,6 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
ag.uuid_generate_v4() @@ -356,66 +193,6 @@
- - - - - - -
- - - - - - - - - -
- - - - - - ag.uuid_generate_v4() - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - -
@@ -434,26 +211,6 @@
- - - - - - - - - - - - -
- - - - - - -
@@ -886,15 +643,6 @@
- - - - - - - - -
@@ -22593,72 +22341,53 @@ AS $function$xpath_exists$function$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Used by : american_gut_consent - - - - These tables are not connected to any other table in the database by foreign key or anything else... - - - - @@ -22670,8 +22399,6 @@ AS $function$xpath_exists$function$ Used by : american_gut_consent - - @@ -22696,7 +22423,6 @@ AS $function$xpath_exists$function$ - From 1098860b221989aca8a82cba8979ec365cff4014 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Fri, 5 May 2017 17:00:36 -0700 Subject: [PATCH 9/9] manually re-sync schema with DB --- amgut/db/ag.dbs | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/amgut/db/ag.dbs b/amgut/db/ag.dbs index b5dee3fa..c1b560f2 100644 --- a/amgut/db/ag.dbs +++ b/amgut/db/ag.dbs @@ -27,8 +27,8 @@
- + @@ -110,7 +110,6 @@ - @@ -288,6 +287,7 @@ + @@ -329,16 +329,6 @@
- - Keeps track of the survey_ids that correspond to surveys that were ported from first questionnaire to the second - - - - - - - -
@@ -423,19 +413,19 @@ - - 'F' - - - - - + + + + + 'F' + + @@ -565,6 +555,7 @@ + @@ -22349,33 +22340,32 @@ AS $function$xpath_exists$function$ - - - - - - + + + + + Used by : american_gut_consent @@ -22395,7 +22385,6 @@ AS $function$xpath_exists$function$ - Used by : american_gut_consent