-
Notifications
You must be signed in to change notification settings - Fork 31
Bundle Analysis: fix trends when no data in query range #1267
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -454,7 +454,7 @@ def __init__( | |
| @sentry_sdk.trace | ||
| def _compute_measurements( | ||
| self, measurable_name: str, measurable_ids: List[str] | ||
| ) -> Dict[int, List[Dict[str, Any]]]: | ||
| ) -> Dict[str, List[Dict[str, Any]]]: | ||
| all_measurements = measurements_by_ids( | ||
| repository=self.repository, | ||
| measurable_name=measurable_name, | ||
|
|
@@ -463,11 +463,13 @@ def _compute_measurements( | |
| after=self.after, | ||
| before=self.before, | ||
| branch=self.branch, | ||
| ) | ||
| ) or {measurable_ids[0]: []} | ||
|
|
||
| # Carry over previous available value for start date if its value is null | ||
| for measurable_id, measurements in all_measurements.items(): | ||
| if self.after is not None and measurements[0]["timestamp_bin"] > self.after: | ||
| if self.after is not None and ( | ||
| not measurements or measurements[0]["timestamp_bin"] > self.after | ||
| ): | ||
| carryover_measurement = measurements_last_uploaded_before_start_date( | ||
| owner_id=self.repository.author.ownerid, | ||
| repo_id=self.repository.repoid, | ||
|
|
@@ -481,8 +483,10 @@ def _compute_measurements( | |
| # If there isn't any measurements before the start date range, measurements will be untouched | ||
| if carryover_measurement: | ||
| value = Decimal(carryover_measurement[0]["value"]) | ||
| carryover = dict(measurements[0]) | ||
| carryover["timestamp_bin"] = self.after | ||
| carryover = dict(measurements[0]) if measurements else {} | ||
| carryover["timestamp_bin"] = self.after.replace( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this to "zero out" the timestamp?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, in the downstream when building the list of measurements to return it needs to have 00:00:00.000 as the time, that is expected because normally we pull the data from the aggregate tables, naturally it always agg by n days and so the time is always 0s. But in this case when we carry over the last datapoint we don't query from the aggregate tables, instead it comes from the un-agg'd table so the time is when it got inserted. So this part would zero out the times to comply with the logic later.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahhhh okay makes sense |
||
| hour=0, minute=0, second=0, microsecond=0 | ||
| ) | ||
| carryover["min"] = value | ||
| carryover["max"] = value | ||
| carryover["avg"] = value | ||
|
|
||
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.
was this change on purpose? Should we also change the type on 41 as well
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.
yeah because when this function was made the measurable_id was only ints representing the flag IDs for flag measurements, but it can be also str for component names or BA reports.
Yes updating line 41.