Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def fill_timeseries(
interval: timedelta,
values: list[Row],
) -> list[Row]:
# remove microseconds
start = start.replace(microsecond=0)
end = end.replace(microsecond=0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Database and generated timestamps misaligned when start has microseconds

The fix removes microseconds from the local start and end variables in fill_timeseries, which affects the generated bucket timestamps. However, the database query still uses the original start (with microseconds) as the origin for date_bin, causing the database-returned timestamps to be offset by the microsecond amount. This prevents the bucket matching logic from working correctly since the comparison ts == values[index]["timestamp"] will fail due to the timestamp offset, ultimately causing an UnconsumedBuckets exception when not all buckets match.

Fix in Cursor Fix in Web


def iter_interval(start: datetime, end: datetime, interval: timedelta) -> Iterator[int]:
while start <= end:
yield int(start.timestamp() * 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,3 +523,47 @@ def test_other_with_resolved_issues(self) -> None:
"valueUnit": None,
"interval": 3_600_000,
}

def test_buckets_not_filling(self) -> None:
self.start = (self.end - timedelta(days=14)).replace(microsecond=1234)

project = self.create_project()
self.create_group(
project=project,
status=1,
first_seen=self.start + timedelta(days=1),
resolved_at=self.start + timedelta(days=1, hours=1),
type=2,
)
response = self.do_request(
{
"start": self.start,
"end": self.end,
"project": project.id,
"interval": "12h",
"category": "issue",
"yAxis": "count(new_issues)",
},
)
assert response.status_code == 200, response.content
assert response.data["meta"] == {
"dataset": "issue",
"start": self.start.timestamp() * 1000,
"end": self.end.timestamp() * 1000,
}
assert len(response.data["timeSeries"]) == 1
timeseries = response.data["timeSeries"][0]
assert len(timeseries["values"]) == 29
assert timeseries["values"] == [
{
"incomplete": False,
"timestamp": round((self.start + timedelta(hours=x * 12)).timestamp() * 1000) - 1,
"value": 1 if x == 2 else 0,
}
for x in range(29)
]
assert timeseries["meta"] == {
"valueType": "integer",
"valueUnit": None,
"interval": 43_200_000,
}
Loading