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

Filter None from report, catch all possible exceptions during upload and do not stage the project #34

Merged
merged 5 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 16 additions & 14 deletions daily_read/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@
for owner in modified_orders:
if upload:
report = daily_rep.populate_and_write_report(owner, modified_orders[owner], config_values.STATUS_PRIORITY)
# Publish reports
for status in modified_orders[owner]["projects"].keys():
for project in modified_orders[owner]["projects"][status]:
uploaded = False
uploaded = op.upload_report_to_order_portal(report, project, "published")
if uploaded:
op.projects_data.stage_data_for_project(project)
# Hide old reports
for status in modified_orders[owner]["delete_report_for"].keys():
for project in modified_orders[owner]["delete_report_for"][status]:
uploaded = False
uploaded = op.upload_report_to_order_portal("", project, "review")
if uploaded:
op.projects_data.stage_data_for_project(project)
# Publish reports with published, hide reports with review
for upload_category, report_state in {"projects": "published", "delete_report_for": "review"}.items():
for status in modified_orders[owner][upload_category].keys():
for project in modified_orders[owner][upload_category][status]:
uploaded = False
report_upload = report if upload_category == "projects" else ""
try:
uploaded = op.upload_report_to_order_portal(report_upload, project, report_state)

Check warning on line 103 in daily_read/__main__.py

View check run for this annotation

Codecov / codecov/patch

daily_read/__main__.py#L97-L103

Added lines #L97 - L103 were not covered by tests
aanil marked this conversation as resolved.
Show resolved Hide resolved
# Stage changes only if report was uploaded
if uploaded:
op.projects_data.stage_data_for_project(project)

Check warning on line 106 in daily_read/__main__.py

View check run for this annotation

Codecov / codecov/patch

daily_read/__main__.py#L105-L106

Added lines #L105 - L106 were not covered by tests
# catch any and every exception during upload
except Exception as e:
log.error(

Check warning on line 109 in daily_read/__main__.py

View check run for this annotation

Codecov / codecov/patch

daily_read/__main__.py#L108-L109

Added lines #L108 - L109 were not covered by tests
f"Exception Raised: Issue in uploading/hiding reports for {project.project_id}: {e}\nContinuing to next project"
)
# Commit all uploaded projects
op.projects_data.commit_staged_data(f"Commit reports updates for {datetime.datetime.now()}")

Expand Down
3 changes: 2 additions & 1 deletion daily_read/order_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def upload_report_to_order_portal(self, report, project, status):
response = requests.post(url, headers=self.headers, json=indata)

if response.status_code == 200:
log.info(f"Updated report for order with project id: {project.project_id}")
operation = "Updated" if report else "Hid"
log.info(f"{operation} report for order with project id: {project.project_id}")
return True
else:
log.error(
Expand Down
4 changes: 1 addition & 3 deletions daily_read/statusdb.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Classes for handling various utility functions"""


import logging

import couchdb
import logging

log = logging.getLogger(__name__)

Expand Down
16 changes: 6 additions & 10 deletions daily_read/templates/daily_report.html.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<iframe
id="ngi_progress_report"
srcdoc='
<iframe id="ngi_progress_report" srcdoc='
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Expand Down Expand Up @@ -155,6 +153,7 @@
{% else %}
<div id="projects_list">
{% for date_prio, date_type in priority | dictsort %}
{% if date_type != "None"%}
<div class="row p-3">
<div
class="col-sm border-end border-primary me-3 d-flex align-items-center"
Expand Down Expand Up @@ -214,6 +213,7 @@
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
Expand All @@ -232,10 +232,6 @@
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
</script>
</body>
'
width="120%"
height="2000"
frameborder="0"
sandbox="allow-scripts allow-top-navigation"
></iframe>
</html>
' width="120%" height="2000" frameborder="0" sandbox="allow-scripts allow-top-navigation"></iframe>

</html>
Loading