Skip to content

Commit 9a4daba

Browse files
feat: timezone-aware graph ranges
Signed-off-by: Henry <mail@henrygressmann.de>
1 parent 6f981f9 commit 9a4daba

20 files changed

Lines changed: 1144 additions & 731 deletions

File tree

Cargo.lock

Lines changed: 52 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ argh={version="0.1", default-features=false, features=["help"]}
4646
anyhow={version="1.0"}
4747
rand={version="0.10", default-features=false, features=["std", "thread_rng"]}
4848
chrono={version="0.4", default-features=false, features=["std", "now", "serde"]}
49+
chrono-tz="0.10"
4950
config={version="0.15", default-features=false, features=["toml"]}
5051
tracing={version="0.1", default-features=false, features=["std"]}
5152
tracing-subscriber={version="0.3", features=["env-filter"]}

benches/reports.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use chrono::{Days, Utc};
22
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
33
use liwan::app::Liwan;
4-
use liwan::app::reports::{self, DateRange, Dimension, Metric};
4+
use liwan::app::reports::{self, DateRange, Dimension, GraphInterval, Metric};
55
use liwan::config::Config;
66
use std::time::Duration;
77

@@ -30,6 +30,8 @@ fn benchmark_reports(c: &mut Criterion) {
3030
start: Utc::now().checked_sub_days(Days::new(365)).expect("failed to build range start"),
3131
end: Utc::now(),
3232
};
33+
let day_buckets = reports::build_graph_buckets(&range, GraphInterval::Day, Some("UTC"))
34+
.expect("failed to build day buckets for benchmark");
3335

3436
let conn = app.events_conn().expect("failed to get events connection");
3537

@@ -51,7 +53,7 @@ fn benchmark_reports(c: &mut Criterion) {
5153
for metric in [Metric::Views, Metric::UniqueVisitors, Metric::BounceRate, Metric::AvgTimeOnSite] {
5254
group.bench_with_input(BenchmarkId::new("metric", format!("{metric:?}")), &metric, |b, metric| {
5355
b.iter(|| {
54-
reports::overall_report(&conn, &entities, "pageview", &range, 365, &[], metric)
56+
reports::overall_report(&conn, &entities, "pageview", &range, &day_buckets, &[], metric)
5557
.expect("overall_report failed")
5658
});
5759
});

0 commit comments

Comments
 (0)