Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into master-overhaul via conflict resolution branch #521

Merged
merged 53 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7d3ccf5
Translations and bugfixes for THDMI Japan
cassidysymons Mar 28, 2023
728fbe4
Pin flask-babel
cassidysymons Mar 28, 2023
0312675
Merge pull request #514 from biocore/master-pin-babel
cassidysymons Mar 28, 2023
a546757
Update microsetta_private_api/LEGACY/locale_data/japanese_gut.py
cassidysymons Mar 28, 2023
5ac6128
Merge pull request #513 from biocore/csymons_thdmi_japan
cassidysymons Mar 30, 2023
233270b
Translations and bugfixes for THDMI Japan
cassidysymons Apr 6, 2023
af0de3f
Translations and bugfixes for THDMI Japan
cassidysymons Apr 6, 2023
e19f0cf
Translations and bugfixes for THDMI Japan
cassidysymons Apr 7, 2023
b0c3d4c
Translations and bugfixes for THDMI Japan
cassidysymons Apr 7, 2023
dd8a6fe
Translations and bugfixes for THDMI Japan
cassidysymons Apr 7, 2023
fc4e92d
Translations and bugfixes for THDMI Japan
cassidysymons Apr 7, 2023
b3ed51f
Translations and bugfixes for THDMI Japan
cassidysymons Apr 8, 2023
57b6652
Translations and bugfixes for THDMI Japan
cassidysymons Apr 10, 2023
005058f
Merge pull request #515 from biocore/csymons_japan_revisions
cassidysymons Apr 10, 2023
3584b57
Adjust survey question translations
cassidysymons Apr 11, 2023
a9999f4
Adjust survey response translations
cassidysymons Apr 11, 2023
0868939
Merge pull request #516 from biocore/csymons_japan_revisions_2
cassidysymons Apr 11, 2023
c501f54
Qiita adjustments
cassidysymons May 15, 2023
d1ea47f
Lint + test fixes
cassidysymons May 15, 2023
63ddbc8
Test fixes
cassidysymons May 15, 2023
9ba65f1
Test fixes
cassidysymons May 15, 2023
259ec19
Test fixes
cassidysymons May 15, 2023
26cfedd
Requested changes
cassidysymons May 22, 2023
1516ac9
Requested changes
cassidysymons May 22, 2023
cea20f8
Deal with missing geolocation values
cassidysymons Jun 5, 2023
db3f98e
Fix transforms with UNSPECIFIED
cassidysymons Jun 5, 2023
6df9225
Fix transforms with UNSPECIFIED/Unspecified
cassidysymons Jun 5, 2023
16acb47
Adjust how multiselects report true/false vs not collected
cassidysymons Jun 5, 2023
7772c85
Lint fix
cassidysymons Jun 5, 2023
68640e1
Handle null address fields
cassidysymons Jun 6, 2023
bd51eb2
Geocoding adjustments
cassidysymons Jun 6, 2023
3289285
Lint
cassidysymons Jun 6, 2023
d81ce9a
Add scans for valid samples
cassidysymons Jun 13, 2023
9eb1017
Add scans for valid samples - revised
cassidysymons Jun 13, 2023
1629ff7
Add scans for valid samples - revised
cassidysymons Jun 13, 2023
1c1cf17
Ensure "Unspecified" is not in metadata pulldown
cassidysymons Jun 14, 2023
21a3b35
Add more valid barcodes
cassidysymons Jun 14, 2023
7020e7a
Update microsetta_private_api/util/google_geocoding.py
cassidysymons Jun 16, 2023
c47efd8
Update microsetta_private_api/util/google_geocoding.py
cassidysymons Jun 16, 2023
9677fb7
Requested changes
cassidysymons Jun 16, 2023
664526e
Apply suggestions from code review
cassidysymons Jun 16, 2023
534387a
Fix unit test
cassidysymons Jun 16, 2023
2863746
Merge pull request #517 from biocore/csymons_metadata_updates
cassidysymons Jun 16, 2023
ad0465e
Cast response.status_code to string
cassidysymons Jun 21, 2023
bf07af1
Merge pull request #519 from biocore/csymons_metadata_20230621
cassidysymons Jun 21, 2023
87d0097
Database patch adjustments
cassidysymons Jun 27, 2023
add30ad
Merge remote-tracking branch 'origin/master' into csymons_overhaul_co…
cassidysymons Jun 27, 2023
9b0c63a
Conflict resolution
cassidysymons Jun 27, 2023
6138775
Conflict resolution
cassidysymons Jun 27, 2023
24871ec
Conflict resolution
cassidysymons Jun 27, 2023
2a1b9b2
Conflict resolution
cassidysymons Jun 27, 2023
0718afe
Conflict resolution
cassidysymons Jun 27, 2023
2bff444
Updated PO files
cassidysymons Jun 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
VS_PASSWORD: "${{ secrets.VS_PASSWORD }}"
VS_CRYPTOKEY: "${{ secrets.VS_CRYPTOKEY }}"
VS_REGCODE: "${{ secrets.VS_REGCODE }}"
GOOGLE_GEOCODING_KEY: "${{ secrets.GOOGLE_GEOCODING_KEY }}"
run: |
# pull out the port so we can modify the configuration file easily
pgport=${{ job.services.postgres.ports[5432] }}
Expand Down
2 changes: 1 addition & 1 deletion microsetta_private_api/LEGACY/locale_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


available_locales = set([
'american_gut', 'british_gut', 'spanish_gut', 'spain_spanish_gut'])
'american_gut', 'british_gut', 'spanish_gut', 'spain_spanish_gut', 'japanese_gut'])


media_locale = {
Expand Down
105 changes: 105 additions & 0 deletions microsetta_private_api/LEGACY/locale_data/japanese_gut.py

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion microsetta_private_api/admin/tests/test_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def setup_test_data():
12345,
"US"
),
32.8798916,
-117.2363115,
False,
"en_US",
True)
acct_repo.create_account(acc)
Expand Down Expand Up @@ -904,7 +907,7 @@ def test_metadata_qiita_compatible_two_templates(self):

# confirm that the results for the other survey, attached to a
# different source, did not receive the merged 502/gender_v2 attribute.
self.assertEqual(result['000051101']['gender_v2'], 'Unspecified')
self.assertEqual(result['000051101']['gender_v2'], 'not provided')
self.assertEqual(result['000051101']['birth_year'], '1968')

# clean up by deleting the survey we added for testing.
Expand Down
6 changes: 6 additions & 0 deletions microsetta_private_api/admin/tests/test_admin_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def setup_test_data():
12345,
"US"
),
32.8798916,
-117.2363115,
False,
"en_US",
True)
acct_repo.create_account(acc)
Expand All @@ -107,6 +110,9 @@ def setup_test_data():
12345,
"US"
),
32.8798916,
-117.2363115,
False,
"en_US",
True)
acct_repo.create_account(acc)
Expand Down
27 changes: 27 additions & 0 deletions microsetta_private_api/api/_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from microsetta_private_api.config_manager import SERVER_CONFIG
from microsetta_private_api.repo.perk_fulfillment_repo import\
PerkFulfillmentRepo
from microsetta_private_api.util.google_geocoding import geocode_address


def find_accounts_for_login(token_info):
Expand Down Expand Up @@ -58,6 +59,12 @@ def register_account(body, token_info):
new_acct_id = str(uuid.uuid4())
body["id"] = new_acct_id

# We need these keys to exist to create the account object, but we'll
# update them momentarily
body["latitude"] = None
body["longitude"] = None
body["cannot_geocode"] = False

account_obj = Account.from_dict(body, token_info[JWT_ISS_CLAIM_KEY],
token_info[JWT_SUB_CLAIM_KEY])

Expand All @@ -75,6 +82,15 @@ def register_account(body, token_info):
for sub_id in subscription_ids:
pfr.claim_unclaimed_subscription(sub_id, new_acct_id)

# Now that we've successfully created an account, geocode it
latitude, longitude, _, _, cannot_geocode = geocode_address(
new_acct.address
)
new_acct.latitude = latitude
new_acct.longitude = longitude
new_acct.cannot_geocode = cannot_geocode
acct_repo.update_account(new_acct)

t.commit()

response = jsonify(new_acct.to_api())
Expand Down Expand Up @@ -123,6 +139,17 @@ def update_account(account_id, body, token_info):
)
acc.language = body['language']

# Whenever someone updates their address, we need to update geocoding
# info. We don't need to check if they're actually changing their
# address, as the geocoding code prevents duplicate requests from
# reaching Google's API
latitude, longitude, _, _, cannot_geocode = geocode_address(
acc.address
)
acc.latitude = latitude
acc.longitude = longitude
acc.cannot_geocode = cannot_geocode

# 422 handling is done inside acct_repo
acct_repo.update_account(acc)
t.commit()
Expand Down
25 changes: 25 additions & 0 deletions microsetta_private_api/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
"first_name": "Jane",
"last_name": "Doe",
"language": "en_US",
"latitude": 32.8798916,
"longitude": -117.2363115,
"cannot_geocode": False,
"consent_privacy_terms": True
}
DUMMY_ACCT_INFO_2 = {
Expand All @@ -96,6 +99,9 @@
"first_name": "Obie",
"last_name": "Dobie",
"language": "en_US",
"latitude": 32.8798916,
"longitude": -117.2363115,
"cannot_geocode": False,
"consent_privacy_terms": True
}
DUMMY_ACCT_ADMIN = {
Expand All @@ -110,6 +116,9 @@
"email": TEST_EMAIL_3,
"first_name": "Obie",
"last_name": "Dobie",
"latitude": 32.8798916,
"longitude": -117.2363115,
"cannot_geocode": False,
"consent_privacy_terms": True,
}

Expand Down Expand Up @@ -484,6 +493,9 @@ def _create_dummy_acct_from_t(t, create_dummy_1=True,
input_obj['address']['country_code'],
input_obj['address']['street2']
),
input_obj['latitude'],
input_obj['longitude'],
input_obj['cannot_geocode'],
input_obj['language'],
input_obj['consent_privacy_terms']
)
Expand Down Expand Up @@ -728,6 +740,16 @@ def validate_dummy_acct_response_body(self, response_obj,
expected_dict[ACCT_TYPE_KEY] = ACCT_TYPE_VAL
expected_dict[CREATION_TIME_KEY] = real_creation_time
expected_dict[UPDATE_TIME_KEY] = real_update_time

# the lat, long, and cannot_geocode need to be ignored for the sake of
# comparisons
expected_dict.pop("latitude", None)
expected_dict.pop("longitude", None)
expected_dict.pop("cannot_geocode", None)
response_obj.pop("latitude", None)
response_obj.pop("longitude", None)
response_obj.pop("cannot_geocode", None)

self.assertEqual(expected_dict, response_obj)

return real_acct_id_from_body
Expand Down Expand Up @@ -1249,6 +1271,9 @@ def test_account_update_fail_400_without_required_fields(self):

dummy_acct_id = create_dummy_acct()
changed_acct_dict = self.make_updated_acct_dict()
changed_acct_dict.pop('latitude', None)
changed_acct_dict.pop('longitude', None)
changed_acct_dict.pop('cannot_geocode', None)
changed_acct_dict.pop("consent_privacy_terms")

input_url = "/api/accounts/{0}".format(dummy_acct_id)
Expand Down
32 changes: 32 additions & 0 deletions microsetta_private_api/api/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ def setup_test_data():
"US",
""
),
32.8798916,
-117.2363115,
False,
"en_US",
True)
acct_repo.create_account(acc)
Expand Down Expand Up @@ -849,6 +852,9 @@ def test_edit_account_info(self):
# Hard to guess these two, so let's pop em out
acc.pop("creation_time")
acc.pop("update_time")
acc.pop("latitude")
acc.pop("longitude")
acc.pop("cannot_geocode")
acc.pop('kit_name')
self.assertDictEqual(acc, regular_data, "Check Initial Account Match")

Expand Down Expand Up @@ -892,6 +898,9 @@ def test_edit_account_info(self):
fuzzy_data["account_id"] = "aaaaaaaa-bbbb-cccc-dddd-eeeeffffffff"
acc.pop('creation_time')
acc.pop('update_time')
acc.pop("latitude")
acc.pop("longitude")
acc.pop("cannot_geocode")
acc.pop('kit_name')
acc.pop('consent_privacy_terms')
self.assertDictEqual(fuzzy_data, acc, "Check Fuzz Account Match")
Expand All @@ -911,6 +920,9 @@ def test_edit_account_info(self):

acc.pop('creation_time')
acc.pop('update_time')
acc.pop("latitude")
acc.pop("longitude")
acc.pop("cannot_geocode")
acc.pop('kit_name')
regular_data['account_type'] = 'standard'
regular_data["account_id"] = "aaaaaaaa-bbbb-cccc-dddd-eeeeffffffff"
Expand Down Expand Up @@ -1210,6 +1222,23 @@ def test_delete_source(self):
headers=MOCK_HEADERS
)
check_response(resp, 422)
self.assertIn("sample", resp.json["message"],
"Failure message should complain about samples")

# Remove the sample.
resp = self.client.delete(
'/api/accounts/%s/sources/%s/samples/%s?language_tag=en_US' %
(ACCT_ID, source_id_from_obj, sample_id),
headers=MOCK_HEADERS
)
check_response(resp)

# Now delete the source (Hopefully successfully!
resp = self.client.delete(
loc + "?language_tag=en_US",
headers=MOCK_HEADERS
)
check_response(resp, 204)

def test_associate_sample_and_survey(self):
"""
Expand Down Expand Up @@ -1771,6 +1800,9 @@ def test_scrub_source(self):
"US",
""
),
32.8798916,
-117.2363115,
False,
"en_US",
True)
accountRepo.create_account(acc)
Expand Down
4 changes: 0 additions & 4 deletions microsetta_private_api/celery_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def __call__(self, *args, **kwargs):
# "fetch_ffqs": {
# "task": "microsetta_private_api.util.vioscreen.fetch_ffqs",
# "schedule": 60 * 60 * 24 # every 24 hours
# },
# "geocode_accounts": {
# "task": "microsetta_private_api.tasks.geocode_accounts",
# "schedule": 60
# }
}

Expand Down
Loading