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

Minghui dev #55

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
16 changes: 12 additions & 4 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ pm_interval = 7
gnt_interval = 365
ct_update = 02/06/24
pm_update = 02/01/24
minghui.clinical_update = 01/08/24
minghui.grant_update = 11/30/22
minghui.pubmed_update = 10/30/22
minghui.gard_update = 11/30/23
; minghui.clinical_update = 01/08/24
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confused on what these lines are with the ; symbol

Copy link
Collaborator Author

@MingghuiA MingghuiA May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ; symbol means these lines are commented out

; minghui.grant_update = 11/30/22
; minghui.pubmed_update = 10/30/22
; minghui.gard_update = 11/30/23
; minghui.rdas.ctkg_update = 05/15/24
; minghui.rdas.gfkg_update = 05/01/24
; minghui.rdas.pakg_update = 05/15/24
; minghui.rdas.gard_update = 05/15/24
minghui.rdas.ctkg_update = 01/01/24
minghui.rdas.gfkg_update = 01/01/23
minghui.rdas.pakg_update = 01/01/24
minghui.rdas.gard_update = 01/01/24

[TEST_TRANSFER_DETECTION]
clinical =
Expand Down
164 changes: 0 additions & 164 deletions email/ses_firebase.py

This file was deleted.

58 changes: 42 additions & 16 deletions emails/alert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import boto3
import sys
sys.path.append('/home/aom2/RDAS')
sys.path.append('/home/aom2/RDAS/emails')
from botocore.exceptions import ClientError

sender_email = 'ncatsrdas@mail.nih.gov'
Expand All @@ -10,31 +13,54 @@ def setup_email_client():
)
return client

def send_email(sub,msg,recip,html=None,client=setup_email_client()):
if not client:
return

response = client.send_email(
Source=sender_email,
Destination={
'ToAddresses': [
f'{recip}',
],
},
Message={
def send_email(subject, html, recipient, client=setup_email_client()):
print("Sending emails to:", recipient)
# sender_email = client # Replace with your email
# Set up the email
message={
'Subject': {
'Data': f'{sub}',
'Data': f'{subject}',
},
'Body': {
'Text': {
'Data': f'{msg}',
},

'Html': {
'Data': f'{html}'
},
}
}


# Send the email
response = client.send_email(
Source=sender_email,
Destination={'ToAddresses': [recipient]},
Message=message
)
print("Email sent successfully.")


# def send_email(sub,html,recip,client=setup_email_client()):
# if not client:
# return

# response = client.send_email(
# Source=sender_email,
# Destination={
# 'ToAddresses': [
# f'{recip}',
# ],
# },
# Message={
# 'Subject': {
# 'Data': f'{sub}',
# },
# 'Body': {
# 'Html': {
# 'Data': f'{html}'
# },
# }
# }
# )

def send_raw_email(sub,msg,recip,client=None):
if not client:
Expand Down
32 changes: 0 additions & 32 deletions emails/email_template1.html

This file was deleted.

84 changes: 84 additions & 0 deletions emails/email_template3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!-- email_template.html -->
<html>
<head>
<style>
body { background-color: white; font-family: Arial, sans-serif; }
/* Add more styling as needed */
</style>
</head>
<!-- <body style="text-align: center;">
<h1 style="font-size:50px; color:purple;">Rare Disease Alert System</h1>
<h2>{{ data['name'] }}</h2>
<h3>You have {{ data['total'] }} new entries for your subscribed rare diseases in the database</h3>
<table border="1" style="margin: auto;">
<tr>
<th>Name</th>
<th>GARD ID</th>
<th>New Articles Number</th>
<th>New Clinical Trials Number</th>
<th>New Funding Project Number</th>
</tr>
{% for gard_id, gard_name in data['subscriptions'].items() %}
{% set articles = data[gard_id].get('articles', 0) %}
{% set trials = data[gard_id].get('trials', 0) %}
{% set grants = data[gard_id].get('grants', 0) %}
{% if articles > 0 or trials > 0 or grants > 0 %}
<tr>
<td><a href="https://rdas.ncats.nih.gov/disease?id={{ gard_id }}"> {{ gard_name }} </a></td>
<td>{{ gard_id }}</td>
<td>{{ articles }}</td>
<td>{{ trials }}</td>
<td>{{ grants }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
<h4>Results gathered within the time period of {{ data['update_date_start'] }} - {{ data['update_date_end'] }}</h4>
<img src="https://upload.wikimedia.org/wikipedia/commons/6/6e/National_Center_for_Advancing_Translational_Sciences_logo.png" alt="Rare Disease Alert System" width="300">
</body>
</html> -->

<body style="text-align: center;">
<h1 style="font-size:50px; color:purple;">Rare Disease Alert System</h1>
<!-- <h2>{{ data['name'] }}</h2> -->
<h3>You have {{ data['total'] }} new entries for your subscribed rare diseases in the database</h3>
<table border="1" style="margin: auto;">
<tr>
<th>Disease Name</th>
<th>GARD ID</th>
{% for dataset in data['datasets'] %}
{% if dataset == 'articles' %}
<th>New Articles</th>
{% elif dataset == 'trials' %}
<th>New Clinical Trials</th>
{% elif dataset == 'grants' %}
<th>New Fundings</th>
{% endif %}
{% endfor %}
</tr>
{% for gard_id, gard_name in data['subscriptions'].items() %}
{% set articles = data[gard_id].get('articles', 0) %}
{% set trials = data[gard_id].get('trials', 0) %}
{% set grants = data[gard_id].get('grants', 0) %}
{% if articles > 0 or trials > 0 or grants > 0 %}
<tr>
<td><a href="https://rdas.ncats.nih.gov/disease?id={{ gard_id }}"> {{ gard_name }} </a></td>
<td>{{ gard_id }}</td>
{% for dataset in data['datasets'] %}
{% if dataset == 'articles' %}
<td>{{ articles }}</td>
{% elif dataset == 'trials' %}
<td>{{ trials }}</td>
{% elif dataset == 'grants' %}
<td>{{ grants }}</td>
{% endif %}
{% endfor %}
</tr>
{% endif %}
{% endfor %}
</table>
<h4>Results gathered within the time period of {{ data['update_date_start'] }} - {{ data['update_date_end'] }}</h4>

<img src="https://upload.wikimedia.org/wikipedia/commons/6/6e/National_Center_for_Advancing_Translational_Sciences_logo.png" alt="Rare Disease Alert System" width="300">
</body>
</html>
Loading