Skip to content

Commit

Permalink
Merge pull request #34 from aanil/fix_git
Browse files Browse the repository at this point in the history
Filter None from report, catch all possible exceptions during upload and do not stage the project
  • Loading branch information
aanil authored Jan 29, 2024
2 parents 913ae31 + 2a9909a commit 5ef79ea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
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 @@ def generate_all(upload=False, develop=False):
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)
# Stage changes only if report was uploaded
if uploaded:
op.projects_data.stage_data_for_project(project)
# catch any and every exception during upload
except Exception as e:
log.error(
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>

0 comments on commit 5ef79ea

Please sign in to comment.