https://github.com/nevill/timebased
https://github.com/nevill/timebased
statistics timebased
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nevill/timebased
- Owner: nevill
- License: bsd-3-clause
- Created: 2022-05-30T14:31:15.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-01T07:11:37.000Z (about 4 years ago)
- Last Synced: 2025-08-03T07:28:53.227Z (11 months ago)
- Topics: statistics, timebased
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Timebased
This repo contains useful methods can be used in your daily development.
### Timebased stats for a period of time.
You want to know most viewed products within 3 hours. Assume we have 3 buckets to store recent 3 hours views into them, here is a list
| Hour 1:00 | Hour 2:00 | Hour 3:00 |
| - | - | - |
|P1: 0|P1: 13|p1: 9|
|P2: 5|P2: 11|p2: 29|
|P3: 7|P3: 0|p3: 0|
|P4: 0|P4: 0|p4: 21|
Now, we are at fourth hour, (assume it's 3:10), we can get a rank list at the end.
1. P2: 45
1. p1: 22
1. p4: 21
1. p3: 7
You can check the implementation under `examples/`.