Skip to content

Commit

Permalink
Revert audio support.
Browse files Browse the repository at this point in the history
  • Loading branch information
kelockhart committed May 17, 2023
1 parent 67be543 commit d42bcb9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 2.7

- name: Install dependencies
run: |
Expand Down
1 change: 0 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
API_VAULT_MYADS_SETUP = API_ENDPOINT + '/v1/vault/get-myads/%s'
API_VAULT_MYADS_SETUP_DATE = API_ENDPOINT + '/v1/vault/get-myads/%s/%s'
API_ADSWS_USER_EMAIL = API_ENDPOINT + '/v1/user/%s'
API_EXPORT_CUSTOM = API_ENDPOINT + '/v1/export/custom'

ARXIV_URL = 'https://ui.adsabs.harvard.edu/link_gateway/{0}/EPRINT_HTML?utm_source=myads&utm_medium=email&utm_campaign=type:{1}&utm_term={2}&utm_content=rank:{3}'

Expand Down
16 changes: 1 addition & 15 deletions myadsp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def task_process_myads(message):
even if they were already processed today)
'test_send_to': email address to send output to, if not that of the user (for testing)
'retries': number of retries attempted
'audio_files': dict, key is bibcode, value is audio file name
}
:return: no return
"""
Expand Down Expand Up @@ -133,13 +132,6 @@ def task_process_myads(message):
setup = r.json()
payload = []
has_results = 0
if message.get('audio_files'):
audio_file_dict = message.get('audio_files')
audio_bib = audio_file_dict.keys()
all_audio_out = {b["title"]: b["file"] for b in audio_file_dict}
else:
audio_bib = []
all_audio_out = {}
for s in setup:
if s['frequency'] == message['frequency']:
# only return 5 results, unless it's the daily arXiv posting, then return max
Expand Down Expand Up @@ -195,9 +187,6 @@ def task_process_myads(message):
else:
results = r['results']

audio_out_dict = {audio_file_dict[r['bibcode']]['title']: audio_file_dict[r['bibcode']]['file']
for r in results if r['bibcode'] in audio_bib}

# keep track of queries that have returned results
if results:
has_results += 1
Expand All @@ -208,10 +197,7 @@ def task_process_myads(message):
'results': results,
'query': r['query'],
'qtype': qtype,
'id': s['id'],
'audio_files': audio_out_dict,
'all_audio_files': all_audio_out
})
'id': s['id']})
else:
# wrong frequency for this round of processing
continue
Expand Down
36 changes: 0 additions & 36 deletions myadsp/templates/one_col.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,13 @@
{% extends "email.html" %}
{% block payload %}
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateColumns" style="max-width: 768px;">
<tr>
{% if payload[0].all_audio_files|length > 0 %}
<form method="post" action="https://dev.adsabs.harvard.edu/audio-player" class="inline">
<input
type="hidden"
name="sources"
value={{ payload[0].all_audio_files }}
/>
<button
type="submit"
name="submit_param"
value="submit_value"
class="link-button"
>
Listen to all astro-ph
</button>
</form>
{% endif %}
</tr>
<tr>
<td align="center" valign="top" width="100%" class="templateColumnContainer">
<table border="0" cellpadding="10" cellspacing="0" width="100%">
<tr>
<td align="justify" valign="top" class="templateColumnContainer">
{% for p in payload %}
<h3><a href="{{ p.query_url.format(p.qtype, p.id) }}" title="{{ p.query }}" style="text-decoration: none; color: #000000; font-weight: bold;">{{ p.name }}</a></h3>
{% if p.audio_files|length > 0 %}
<form method="post" action="https://dev.adsabs.harvard.edu/audio-player" class="inline">
<input
type="hidden"
name="sources"
value={{ p.audio_files }}
/>
<button
type="submit"
name="submit_param"
value="submit_value"
class="link-button"
>
Listen to section
</button>
</form>
{% endif %}
{% if p.results|length > 0 %}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
{% for r in p.results %}
Expand Down
53 changes: 0 additions & 53 deletions myadsp/templates/two_col.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,13 @@
{% extends "email.html" %}
{% block payload %}
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateColumns" style="">
<tr>
{% if left_payload[0].all_audio_files|length > 0 %}
<form method="post" action="https://dev.adsabs.harvard.edu/audio-player" class="inline">
<input
type="hidden"
name="sources"
value={{ left_payload[0].all_audio_files }}
/>
<button
type="submit"
name="submit_param"
value="submit_value"
class="link-button"
>
Listen to all astro-ph
</button>
</form>
{% endif %}
</tr>
<tr>
<td align="center" valign="top" width="50%" class="templateColumnContainer" style="border-right: 1px solid #dbdbdb;">
<table border="0" cellpadding="10" cellspacing="0" width="100%">
<tr>
<td align="justify" valign="top" class="leftColumnContent">
{% for p in left_payload %}
<h3><a href="{{ p.query_url.format(p.qtype, p.id) }}" title="{{ p.query }}" style="text-decoration: none; color: #000000; font-weight: bold;">{{ p.name }}</a></h3>
{% if p.audio_files|length > 0 %}
<form method="post" action="https://dev.adsabs.harvard.edu/audio-player" class="inline">
<input
type="hidden"
name="sources"
value={{ p.audio_files }}
/>
<button
type="submit"
name="submit_param"
value="submit_value"
class="link-button"
>
Listen to section
</button>
</form>
{% endif %}
{% if p.results|length > 0 %}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
{% for r in p.results %}
Expand Down Expand Up @@ -94,23 +58,6 @@ <h3><a href="{{ p.query_url.format(p.qtype, p.id) }}" title="{{ p.query }}" styl
<td align="justify" valign="top" class="rightColumnContent">
{% for p in right_payload %}
<h3><a href="{{ p.query_url.format(p.qtype, p.id) }}" title="{{ p.query }}" style="text-decoration: none; color: #000000; font-weight: bold;">{{ p.name }}</a></h3>
{% if p.audio_files|length > 0 %}
<form method="post" action="https://dev.adsabs.harvard.edu/audio-player" class="inline">
<input
type="hidden"
name="sources"
value={{ p.audio_files }}
/>
<button
type="submit"
name="submit_param"
value="submit_value"
class="link-button"
>
Listen to section
</button>
</form>
{% endif %}
{% if p.results|length > 0 %}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
{% for r in p.results %}
Expand Down
28 changes: 9 additions & 19 deletions myadsp/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@
"year": "2012",
"bibstem": ["ApJS"]}],
'qtype': 'general',
'id': 123,
'audio_files': {"Title 2012yCat..51392620N": "2012yCat..51392620N.mp3",
"Title 2012ApJS..199...26H": "2012ApJS..199...26H.mp3"},
'all_audio_files': {"Title 2012yCat..51392620N": "2012yCat..51392620N.mp3",
"Title 2012ApJS..199...26H": "2012ApJS..199...26H.mp3"}
},
'id': 123},
{'name': 'Query 2',
'query_url': 'https://ui.adsabs.harvard.edu/search/q=bibstem%3Aarxiv?utm_source=myads&utm_medium=email&utm_campaign=type:{0}&utm_term={1}&utm_content=queryurl',
'results': [{"author_norm": ["Nantais, J", "Huchra, J"],
Expand All @@ -48,12 +43,7 @@
"year": "2012",
"bibstem": ["ApJS"]}],
'qtype': 'arXiv',
'id': 456,
'audio_files': {"2012yCat..51392620N": "2012yCat..51392620N.mp3",
"2012ApJS..199...26H": "2012ApJS..199...26H.mp3"},
'all_audio_files': {"Title 2012yCat..51392620N": "2012yCat..51392620N.mp3",
"Title 2012ApJS..199...26H": "2012ApJS..199...26H.mp3"}
}]
'id': 456}]


class TestmyADSCelery(unittest.TestCase):
Expand Down Expand Up @@ -600,19 +590,19 @@ def test_payload_to_html(self):
formatted_payload = utils.payload_to_html(payload, col=1, email_address="test@tester.com")

split_payload = formatted_payload.split('\n')
self.assertIn(u'templateColumnContainer"', split_payload[93])
self.assertEqual(split_payload[98].strip(),
self.assertIn(u'templateColumnContainer"', split_payload[77])
self.assertEqual(split_payload[79].strip(),
u'<h3><a href="https://ui.adsabs.harvard.edu/search/q=bibstem%3Aarxiv?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=queryurl" title="" style="text-decoration: none; color: #000000; font-weight: bold;">Query 1</a></h3>')

self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[134])
self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[98])

formatted_payload = utils.payload_to_html(payload, col=2)

split_payload = formatted_payload.split('\n')
self.assertIn(u'class="leftColumnContent"', split_payload[96])
self.assertEqual(split_payload[98].strip(),

self.assertIn(u'class="leftColumnContent"', split_payload[77])
self.assertEqual(split_payload[79].strip(),
u'<h3><a href="https://ui.adsabs.harvard.edu/search/q=bibstem%3Aarxiv?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=queryurl" title="" style="text-decoration: none; color: #000000; font-weight: bold;">Query 1</a></h3>')
self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[134])
self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[98])

formatted_payload = utils.payload_to_html(payload, col=3)
self.assertIsNone(formatted_payload)
Expand Down
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
adsputils==v1.4.3
adsputils==v1.2.7
alembic==0.9.1
psycopg2==2.8.3
Jinja2==2.11.2
portalocker==1.7.1
boto3==1.24.72
markupsafe==2.0.1

0 comments on commit d42bcb9

Please sign in to comment.