-
Notifications
You must be signed in to change notification settings - Fork 47
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
WIP: Add 'created' field to reportsummary and expose in UI (#939) #940
base: master
Are you sure you want to change the base?
Conversation
This only adds a _created_ field during cache generation, which wouldn't make it work for old, cached reports. It also involved quite a bit of vue hackery, due to the data not being available during django page render. Maybe the model ought to change to take not only a `collectionid` but also a `collection.created`? This is also WIP because I'm literally dumping the Python `created` attribute into the JSON and reading it out in JS. There is no explicit serialization/parsing of the date and I'm not sure what format is going to be used. Heh.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #940 +/- ##
==========================================
- Coverage 69.98% 69.97% -0.01%
==========================================
Files 149 149
Lines 9229 9230 +1
Branches 90 90
==========================================
Hits 6459 6459
- Misses 2749 2750 +1
Partials 21 21 ☔ View full report in Codecov by Sentry. |
@@ -125,6 +125,7 @@ def calculate_report_summary(pk): | |||
elif not data: | |||
# This is the root | |||
data = coverage | |||
data["created"] = collection.created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below, this shouldn't be necessary.
@@ -81,7 +82,8 @@ | |||
}, | |||
watch: { | |||
'chart.data': function() { | |||
this.draw() | |||
this.draw(); | |||
document.title = '{{ collectionid }} - Summary - ' + chart.data.created; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the full collection object instead (passed to the template here, fetched like this), and replace any collectionid
uses in the template to collection.id
.
Then you can use {{collection.created}}
directly in a JS string literal to append to title, though created()
on line 98 is a better place for it. There's an existing helper formatClientTimestamp()
defined in the base template you can use.
document.title += ` - ${formatClientTimestamp("{{ collection.created }}")}`
The {{}}
tags are evaluated on the server by Django so that will already be resolved before JS sees it.
This only adds a created field during cache generation, which
wouldn't make it work for old, cached reports.
It also involved quite a bit of vue hackery, due to the data
not being available during django page render.
Maybe the model ought to change to take not only a
collectionid
but also a
collection.created
?This is also WIP because I'm literally dumping the Python
created
attribute into the JSON and reading it out in JS. There is no explicit
serialization/parsing of the date and I'm not sure what format
is going to be used. Heh.