openwisp-utils icon indicating copy to clipboard operation
openwisp-utils copied to clipboard

Prevent Duplicate Metric Usage Reports by Adding Daily Payload Hashing #531

Open AditiSah05 opened this issue 2 months ago • 1 comments

Checklist

  • [x] I have read the OpenWISP Contributing Guidelines.
  • [x] I have manually tested the changes proposed in this pull request.
  • [x] I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • [x] I have updated the documentation.

Reference to Existing Issue

Closes #531 .

Please open a new issue if there isn't an existing issue yet.

Description of Changes

This pull request introduces a reliable mechanism to ensure that metric usage data is sent only once per day, addressing the issue of duplicate submissions caused by repeated executions in certain Django configurations.

To achieve this, the system now generates a hash of the daily metric payload and stores it along with the current date. When metrics are generated again on the same day, the stored hash is compared with the new one. If the payload is unchanged, the system simply skips the transmission. This prevents unnecessary duplication while keeping the reporting behavior consistent and lightweight.

In addition to the core logic, the following updates have been made:

-Added a persistent storage step for recording the daily payload hash.

-Implemented comparison logic to detect and prevent repeated submissions within the same day.

-Added and updated test cases to validate the new behavior, including hash creation, daily checks, and skip conditions.

-Updated the documentation to clearly explain the new flow and provide guidance on correct configuration.

Screenshot

This change does not modify any user-facing interface, so no screenshot is required.

AditiSah05 avatar Dec 07 '25 10:12 AditiSah05

Hi @pandafy , I’ve completed the changes and submitted the pull request. Whenever you have a moment, could you please review it and share your feedback? Thank you!

AditiSah05 avatar Dec 07 '25 10:12 AditiSah05