Skip to content

fix: Release metrics return incorrect featuresPerWeek value #280#306

Open
YuliaMittova wants to merge 1 commit intotoloka-agent/159-autofrom
bugfix/280-release-metrics-return-incorrect-featuresPerWeek-value
Open

fix: Release metrics return incorrect featuresPerWeek value #280#306
YuliaMittova wants to merge 1 commit intotoloka-agent/159-autofrom
bugfix/280-release-metrics-return-incorrect-featuresPerWeek-value

Conversation

@YuliaMittova
Copy link
Copy Markdown

Bugfix for issue #280

@innokenty
Copy link
Copy Markdown

innokenty commented Mar 31, 2026

So if there no bug – then we can't create any dataset from this issue, we just cancel it.

No need to create a PR next time – you can just drop a comment on the issue 👍

@innokenty innokenty closed this Mar 31, 2026
@innokenty
Copy link
Copy Markdown

So actually.... this isn't a problem with the test, the bug is valid!

Your test mocks the value "now" to comply with the logic, but that is exactly the problem: logic of calculating this percentage of features per week should not depend on the current time for the releases that are already released! This is exactly the whole point: when a release already released, this value shouldn't change, no matter how much time has passed since then.

Look at the golden test referred on the bug issue: it actually emulates the correct behaviour for a releases that has released_at date, and not mocking any instants.

@innokenty innokenty reopened this Mar 31, 2026
Copy link
Copy Markdown

@innokenty innokenty left a comment

Choose a reason for hiding this comment

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

The bug-issue is valid: please re-analyze, add a bugfix and provide correct tests that validate the logic correctly. Look into the linked golden test – it seems pretty good to me.

FAIL_TO_PASS: MetricsIntegrationTests#shouldCalculateFeaturesPerWeekExactlyForKnownFixture, MetricsIntegrationTest#shouldReturnZeroVelocityWhenLessThanTwoWeeksOfData, MetricsIntegrationTest#shouldReturnZeroVelocityWhenThereIsNoData
@YuliaMittova YuliaMittova force-pushed the bugfix/280-release-metrics-return-incorrect-featuresPerWeek-value branch from efe0e29 to 7015624 Compare March 31, 2026 22:49
@YuliaMittova
Copy link
Copy Markdown
Author

The bug-issue is valid: please re-analyze, add a bugfix and provide correct tests that validate the logic correctly. Look into the linked golden test – it seems pretty good to me.

@innokenty fixed logic and tests. Please take a look.

@YuliaMittova YuliaMittova requested a review from innokenty March 31, 2026 22:50
Comment on lines +61 to +74
@Test
void shouldCalculateFeaturesPerWeekExactlyForKnownFixture() throws Exception {
assertThat(d(velocity(getMetrics("TEST-FAST")), "featuresPerWeek")).isEqualTo(5.0);
}

@Test
void shouldReturnZeroVelocityWhenLessThanTwoWeeksOfData() throws Exception {
assertThat(d(velocity(getMetrics("GO-2024.2.3")), "featuresPerWeek")).isEqualTo(0.0);
}

@Test
void shouldReturnZeroVelocityWhenThereIsNoData() throws Exception {
assertThat(d(velocity(getMetrics("GO-2024.2.7")), "featuresPerWeek")).isEqualTo(0.0);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please add more test coverage. The only real test is only checking the most simple case of "5.0" and does not cover all the use cases.

Image Image Image

Copy link
Copy Markdown

@innokenty innokenty left a comment

Choose a reason for hiding this comment

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

We need a bit more tests, than a single basic happy-case scenario, please cover some corner cases.


private long calculateBusinessWeeksElapsed(Instant startDate) {
long businessDaysElapsed = calculateBusinessDaysElapsed(startDate);
private long calculateBusinessWeeksElapsed(Instant startDate, Instant endDate) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The precision is lost here: long businessDaysElapsed / 5.
Please preserve the fractional business-week value instead of truncating it, and add a test where the period between createdAt and releasedAt includes a partial business week.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yeah, we definitely need a test for a fractional value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants