Refine usage fallback logic with 1-day threshold#57
Open
alv-cor wants to merge 1 commit intoaload0:mainfrom
Open
Refine usage fallback logic with 1-day threshold#57alv-cor wants to merge 1 commit intoaload0:mainfrom
alv-cor wants to merge 1 commit intoaload0:mainfrom
Conversation
Add a Map.totalTime() helper and ONE_DAY_MS constant; use a mutable `usage` variable to prefer event-based usage only when it's non-empty and the summed time is <= one day. If that check fails, fall back to stats-based calculation and return it only if it's <= one day; otherwise return an empty map. Also change exception handling to return an empty map instead of falling back to stats. This avoids returning large/invalid aggregates and makes the fallback behavior more explicit.
Contributor
Author
|
Note that this is only a dirty patch. I think this happens because stats are calculated each time the menu is accessed, and since the calculation is based on past events/intents, it is possible that logs from +1 week are deleted arbitrarily by the phone. A feasible solution could be saving statistics from past days in some way, so error prone calculation is avoided. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Days from past weeks show sometimes a usage higher than 24 hours, what is physically impossible. This PR aims to hide usage for those days where stats are not precise.