-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add time to observed_at #4227
base: main
Are you sure you want to change the base?
Add time to observed_at #4227
Conversation
|
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.
Just a few remarks, looks good otherwise
except ValueError: | ||
messages.error(self.request, _("Can not parse date, falling back to show current date.")) | ||
return datetime.now(timezone.utc) | ||
observed_at = datetime.fromisoformat(observed_at_string).replace(tzinfo=timezone.utc) |
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.
A minor optimization, but the problem here is in the case of a missing request parameter, you already have a ISO formatted UTC timestamp (due to line 86). Reparsing the already formatted string seems redundant. Another way to do this is (in pseudocode):
if "observed_at" in self.request.GET:
observed_at = datetime.fromisoformat(self.request.GET['observed_at']).replace(tzinfo=timezone.utc)
else:
observed_at = datetime.now(timezone.utc)
context["observed_at"] = self.observed_at.strftime("%Y-%m-%d %H:%M") | ||
context["observed_at_human_readable"] = self.observed_at.strftime("%B %d, %Y, %H:%M (%Z)") |
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.
Since datetime formatting can be handled in the template, introducing two new variables for this looks redundant to me. I suggest applying formatting directly in the template instead
context["observed_at"] = self.observed_at.strftime("%Y-%m-%d %H:%M") | ||
context["observed_at_human_readable"] = self.observed_at.strftime("%B %d, %Y, %H:%M (%Z)") |
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 earlier comment
Changes
now
timeIssue link
#4225
Closes #4225
Demo
QA notes
Mute a finding and then filter for "show muted findings"
You should see the muted finding in the list. Before this was not possible.
Code Checklist
.env
changes files if required and changed the.env-dist
accordingly.Checklist for code reviewers:
Copy-paste the checklist from the docs/source/templates folder into your comment.
Checklist for QA:
Copy-paste the checklist from the docs/source/templates folder into your comment.