fix: sub-day deadline precision in get_campaign_status#59
Conversation
|
Nice granularity improvement addressing the sub-day truncation in #45. One heads-up though: adding |
|
Hey @morelucks 👋 — the sub-day deadline fix for #45 looks correct. Unfortunately I don't see any CI check results on this PR. Could you rebase onto the latest |
Summary
This PR addresses issue #45 where sub-day deadline values for campaigns are truncated to 0 by the integer division
(end_time - now) / 86_400. Rather than applying a breaking change to existingdays_remainingsemantics, we implemented Option A (additive) which keeps backward compatibility while introducing higher granularity for clients (e.g., dashboards and indexers).Proposed Changes
campaign/src/types.rs):hours_remaining: u32to theCampaignStatusResponsestruct.campaign/src/contract.rs):get_campaign_statusto compute bothdays_remainingandhours_remainingusing the time delta.hours_remainingis clamped to0.campaign/src/test/get_campaign_status_tests.rs):calculates_subday_remainingto verify that active campaigns with less than 24 hours remaining return the correct number of hours.calculates_past_subday_remainingto verify that campaigns past their deadlines return0hours.campaign/test_snapshots/test/get_campaign_status_tests/.Closes #45