Skip to content

added decrementByValueInTimeBucket function#1337

Merged
Vignesh-772 merged 1 commit into
mainfrom
update_sliding_window
Jun 9, 2026
Merged

added decrementByValueInTimeBucket function#1337
Vignesh-772 merged 1 commit into
mainfrom
update_sliding_window

Conversation

@Hari-Krishna-Dupaguntla

@Hari-Krishna-Dupaguntla Hari-Krishna-Dupaguntla commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates

Description

Additional Changes

  • This PR modifies the database schema (database migration added)
  • This PR modifies dhall configs/environment variables

Motivation and Context

How did you test it?

Checklist

  • I formatted the code and addressed linter errors ./dev/format-all-files.sh
  • I reviewed submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

Summary by CodeRabbit

  • New Features
    • Time-aware counter operations: you can now decrement counters within specific time buckets by supplying an explicit timestamp. This enables more flexible, precise control and adjustments of time-based counters (e.g., backdated corrections or aligned updates) without changing existing workflows.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1f60165-50b3-475f-bd52-eb08a1c3327c

📥 Commits

Reviewing files that changed from the base of the PR and between 200233f and fde1474.

📒 Files selected for processing (1)
  • lib/mobility-core/src/Kernel/Utils/SlidingWindowCounters.hs
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/mobility-core/src/Kernel/Utils/SlidingWindowCounters.hs

Walkthrough

This PR adds a new exported function decrementByValueInTimeBucket to the SlidingWindowCounters module. The function accepts a UTCTime and decrement Integer, then delegates to the existing decrementByValueImpl using the provided timestamp and standard key builders.

Changes

Sliding Window Counter Decrement Export

Layer / File(s) Summary
New decrementByValueInTimeBucket function export
lib/mobility-core/src/Kernel/Utils/SlidingWindowCounters.hs
Module export list is updated to include decrementByValueInTimeBucket, and the new function is implemented to accept an explicit UTCTime and decrement value, delegating to the existing decrementByValueImpl with the provided timestamp.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • nammayatri/shared-kernel#1307: Refactors time-based key generation and sliding-window read/decrement invalidation for explicit UTCTime handling in the same module.

Poem

🐰 A hop, a tick, a time-bound tweak,
I pass the UTC and the value meek,
The bucket yields its counted song,
Decremented neat, both sure and strong,
Redis sighs — the window moves along.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change—adding a new function named decrementByValueInTimeBucket to the SlidingWindowCounters module.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update_sliding_window

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/mobility-core/src/Kernel/Utils/SlidingWindowCounters.hs`:
- Around line 267-278: Change decrementByValueInTimeBucket to require a concrete
UTCTime (not Maybe) so callers must supply an explicit timestamp and we do not
fall back to now inside decrementByValueImpl; update its type signature to
accept UTCTime and the implementation to call decrementByValueImpl directly with
that UTCTime (retain the same key builders: makeSWKeyForTime,
makeQuickAccessWindowCountKey, makeSlidingWindowKey), and update any callers to
pass a concrete UTCTime instead of Nothing to ensure bucket-specific decrements.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57c59050-d243-438c-a644-e82183442115

📥 Commits

Reviewing files that changed from the base of the PR and between bfbf24d and 200233f.

📒 Files selected for processing (1)
  • lib/mobility-core/src/Kernel/Utils/SlidingWindowCounters.hs

Comment thread lib/mobility-core/src/Kernel/Utils/SlidingWindowCounters.hs Outdated
@Vignesh-772 Vignesh-772 force-pushed the update_sliding_window branch from 5357405 to fde1474 Compare June 9, 2026 06:28
@Vignesh-772 Vignesh-772 merged commit 2fef320 into main Jun 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants