Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ arrow-ipc = { version = "=58.1.0", features = ["lz4"] }
clap = { version = "4", features = ["derive", "env"] }
dirs = "6"
duckdb = { version = "=1.10501.0", features = ["bundled", "appender-arrow"] }
iana-time-zone = "0.1"
open = "5"
regex = "1"
serde = { version = "1", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion skills/apitally-cli/references/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Fetch aggregated metrics for an app. Outputs NDJSON to stdout by default.
- `--interval`: Time interval for grouping (`month`, `day`, `hour`, `minute`). When omitted, returns a single row per group for the entire time range
- `--group-by`: JSON array of field names to group by, in addition to time period
- `--filters`: JSON array of filter objects (see below)
- `--timezone`: Timezone for intervals and to interpret since/until if not tz-aware (defaults to UTC)
- `--timezone`: Timezone for intervals and to interpret since/until if not tz-aware (defaults to system timezone)
- `--db`: Write to `metrics` table in DuckDB instead of outputting NDJSON to stdout

**Deduplication in DuckDB:** Deletes all existing rows for the same `app_id` within the fetched time range before inserting new data.
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ enum Command {

/// Timezone for intervals and to interpret since/until if not tz-aware
///
/// Defaults to UTC. Example: America/New_York.
/// Defaults to system timezone. Example: America/New_York.
#[arg(long)]
timezone: Option<String>,

Expand Down
10 changes: 6 additions & 4 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ pub fn run(
.map_err(|e| input_err(format!("invalid JSON for --filters: {e}")))?;
body["filters"] = filters_value;
}
if let Some(timezone) = timezone {
body["timezone"] = serde_json::json!(timezone);
}
let timezone = match timezone {
Some(tz) => tz.to_owned(),
None => iana_time_zone::get_timezone().unwrap_or_else(|_| "UTC".to_owned()),
Comment thread
itssimon marked this conversation as resolved.
};
body["timezone"] = serde_json::json!(timezone);
let url = format!("{api_base_url}/v1/apps/{app_id}/metrics");
let response = api_post(&url, &api_key, &body)?;

Expand Down Expand Up @@ -229,7 +231,7 @@ mod tests {
Some("hour"),
Some(r#"["method"]"#),
None,
None,
Some("Australia/Brisbane"),
None,
Some("test-key"),
Some(&server.url()),
Expand Down
Loading