Skip to content

Commit

Permalink
Merge branch 'release/v19.11.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-c committed Nov 7, 2019
2 parents 36da746 + 8810e8e commit bbb3776
Show file tree
Hide file tree
Showing 32 changed files with 704 additions and 146 deletions.
5 changes: 5 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ unit_tests:
TOXENV: py3
<<: *unit_test_definition

unit_tests_celery_background:
variables:
TOXENV: celery_background
<<: *unit_test_definition

docgen_test:
variables:
TOXENV: docs
Expand Down
12 changes: 12 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
- db
- redis
- celeryworker
- celeryworkerslow
- celerybeat
volumes:
- source: user-documents
Expand All @@ -45,6 +46,16 @@ services:
depends_on:
- redis

celeryworkerslow:
<<: *service_base
command:
celery worker
--app portal.celery_worker.celery
--queue low_priority
--loglevel debug
depends_on:
- redis

celerybeat:
<<: *service_base
command: bash -c '
Expand All @@ -58,6 +69,7 @@ services:
'
depends_on:
- celeryworker
- celeryworkerslow
redis:
image: redis
Expand Down
178 changes: 178 additions & 0 deletions portal/config/eproms/Organization.json
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,184 @@
},
"resourceType": "Organization"
},
{
"extension": [
{
"timezone": "Europe/London",
"url": "http://hl7.org/fhir/StructureDefinition/user-timezone"
},
{
"research_protocols": [
{"name": "IRONMAN v3"}
],
"url": "http://us.truenth.org/identity-codes/research-protocol"
}
],
"id": 146119,
"identifier": [
{
"system": "http://pcctc.org/",
"use": "secondary",
"value": "146-119"
}
],
"language": "en_GB",
"name": "Velindre Cancer Centre",
"partOf": {
"reference": "api/organization/26000"
},
"resourceType": "Organization"
},
{
"extension": [
{
"timezone": "Europe/London",
"url": "http://hl7.org/fhir/StructureDefinition/user-timezone"
},
{
"research_protocols": [
{"name": "IRONMAN v3"}
],
"url": "http://us.truenth.org/identity-codes/research-protocol"
}
],
"id": 146120,
"identifier": [
{
"system": "http://pcctc.org/",
"use": "secondary",
"value": "146-120"
}
],
"language": "en_GB",
"name": "University Hospitals of Morecambe Bay NHS Trust",
"partOf": {
"reference": "api/organization/26000"
},
"resourceType": "Organization"
},
{
"extension": [
{
"timezone": "Europe/London",
"url": "http://hl7.org/fhir/StructureDefinition/user-timezone"
},
{
"research_protocols": [
{"name": "IRONMAN v3"}
],
"url": "http://us.truenth.org/identity-codes/research-protocol"
}
],
"id": 26100,
"language": "en_GB",
"name": "South Tyneside and Sunderland NHS Foundation Trust",
"partOf": {
"reference": "api/organization/26000"
},
"resourceType": "Organization"
},
{
"extension": [
{
"timezone": "Europe/London",
"url": "http://hl7.org/fhir/StructureDefinition/user-timezone"
},
{
"research_protocols": [
{"name": "IRONMAN v3"}
],
"url": "http://us.truenth.org/identity-codes/research-protocol"
}
],
"id": 146121,
"identifier": [
{
"system": "http://pcctc.org/",
"use": "secondary",
"value": "146-121"
}
],
"language": "en_GB",
"name": "South Tyneside District Hospital",
"partOf": {
"reference": "api/organization/26100"
},
"resourceType": "Organization"
},
{
"extension": [
{
"timezone": "Europe/London",
"url": "http://hl7.org/fhir/StructureDefinition/user-timezone"
},
{
"research_protocols": [
{"name": "IRONMAN v3"}
],
"url": "http://us.truenth.org/identity-codes/research-protocol"
}
],
"id": 146122,
"identifier": [
{
"system": "http://pcctc.org/",
"use": "secondary",
"value": "146-122"
}
],
"language": "en_GB",
"name": "Sunderland Royal Hospital",
"partOf": {
"reference": "api/organization/26100"
},
"resourceType": "Organization"
},
{
"extension": [
{
"research_protocols": [
{"name": "IRONMAN v3"}
],
"url": "http://us.truenth.org/identity-codes/research-protocol"
}
],
"id": 21700,
"language": "en_AU",
"name": "Queensland University of Technology",
"partOf": {
"reference": "api/organization/21000"
},
"resourceType": "Organization"
},
{
"extension": [
{
"timezone": "Australia/Brisbane",
"url": "http://hl7.org/fhir/StructureDefinition/user-timezone"
},
{
"research_protocols": [
{"name": "IRONMAN v3"}
],
"url": "http://us.truenth.org/identity-codes/research-protocol"
}
],
"id": 146118,
"identifier": [
{
"system": "http://pcctc.org/",
"use": "secondary",
"value": "146-118"
}
],
"language": "en_AU",
"name": "Royal Brisbane & Women's Hospital",
"partOf": {
"reference": "api/organization/21700"
},
"resourceType": "Organization"
},
{
"id": 30000,
"identifier": [
Expand Down
2 changes: 1 addition & 1 deletion portal/date_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def parse(data, error_subject=None, none_safe=False):
dt = parser.parse(data)
except (TypeError, ValueError) as e:
msg = "Unable to parse {}: {}".format(error_subject, e)
current_app.logger.warn(msg)
current_app.logger.warning(msg)
abort(400, msg)
if dt.tzinfo:
# Convert to UTC if necessary
Expand Down
2 changes: 1 addition & 1 deletion portal/gil/templates/gil/what-is-prostate-cancer.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1 class="page-intro__main">{% trans %}What is <span class="page-intro__main--a
</div>
<div class="mini-boxes__item">
<div class="mini-box">
<p class="mini-box__copy">{{_("In 2015, approximately 220,800 men were diagnosed with prostate cancer, and more than 27,540 men died from the disease.")}}</p>
<p class="mini-box__copy">{{_("In 2019, over 174,500 men will be diagnosed with prostate cancer in the USA.")}}</p>
</div>
</div>
<div class="mini-boxes__item">
Expand Down
95 changes: 95 additions & 0 deletions portal/migrations/versions/677b8b841cb3_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""Add recipient_id to email_messages table and populate
Revision ID: 677b8b841cb3
Revises: da6506c5899a
Create Date: 2019-10-23 11:36:41.947859
"""
from alembic import op
import logging
import re
import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql import text

from portal.models.audit import Audit
from portal.models.message import EmailMessage
from portal.models.user import User

# revision identifiers, used by Alembic.
revision = '677b8b841cb3'
down_revision = 'da6506c5899a'

logger = logging.getLogger("alembic")
Session = sessionmaker()


def upgrade():
op.add_column(
'email_messages',
sa.Column('recipient_id', sa.Integer(), nullable=True))
op.create_foreign_key(
'email_messages_recipient_id_fkey',
'email_messages',
'users',
['recipient_id'],
['id'],
ondelete='CASCADE')

session = Session(bind=op.get_bind())
# Email messages generate an audit row, holding the subject_id.
# Build a dictionary for lookup below when the current email doesn't match
old_address_dict = dict()
for adt in session.query(Audit).filter(Audit.comment.like('EmailMessage %')):
finds = re.match(
r"EmailMessage\ .*?sent\ to\ (.*?)\ from .*", adt.comment)
if finds.groups():
old_address_dict[finds.groups()[0].lower()] = adt.subject_id

# nested query kills runtime - cache current user-email list
emails_to_user_id = dict()
for u in session.query(User).filter(
User.deleted_id.is_(None)).with_entities(User.id, User.email):
emails_to_user_id[u.email.lower()] = u.id

# Populate the recipient_id as best we can.
# SQLA doesn't like changes inside a query - store intent in dict
change_em = dict()
for em in session.query(EmailMessage).filter(
EmailMessage.recipients != 'help.truenthusa@movember.com'):
if ',' in em.recipients:
raise ValueError("can't handle multiple recipients")

# always use lowercase addresses for comparison
recipients = em.recipients.lower()

# First, eliminate all that have a matching current email
if recipients in emails_to_user_id:
change_em[em.id] = emails_to_user_id[recipients]
continue

# Next, see if address can be found in the old_address_dict
if recipients in old_address_dict:
change_em[em.id] = old_address_dict[recipients]
continue

logging.warning("no match for {} to {}".format(
em.subject, em.recipients))

logging.info("found {} gaining recipient_id".format(len(change_em)))
conn = op.get_bind()
for email_message_id, recipient_id in change_em.items():
stmt = (
"UPDATE email_messages SET recipient_id=:recipient_id "
"WHERE id=:email_message_id")
conn.execute(
text(stmt),
email_message_id=email_message_id,
recipient_id=recipient_id)


def downgrade():
op.drop_constraint(
'email_messages_recipient_id_fkey',
'email_messages', type_='foreignkey')
op.drop_column('email_messages', 'recipient_id')
4 changes: 2 additions & 2 deletions portal/models/intervention.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def update_from_json(self, data):
# for prod -> staging, warn if seen on any other system
if 'link_url' in data and self.link_url != data['link_url']:
if current_app.config.get("SYSTEMT_TYPE", '').lower() != 'staging':
current_app.logger.warn(
current_app.logger.warning(
"IMPORTING non-portable intervention({}) link_url: '{}'"
"".format(self.name, data['link_url']))
self.link_url = data['link_url']
if 'client_id' in data and self.client_id != data['client_id']:
if current_app.config.get("SYSTEMT_TYPE", '').lower() != 'staging':
current_app.logger.warn(
current_app.logger.warning(
"IMPORTING non-portable intervention({}) client_id: '{}'"
"".format(self.name, data['client_id']))
self.client_id = data['client_id']
Expand Down
Loading

0 comments on commit bbb3776

Please sign in to comment.