79 lines
1.8 KiB
Rust
79 lines
1.8 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_json::Value;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct TrackPoint {
|
|
pub index: usize,
|
|
pub time: DateTime<Utc>,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct DetectedCrossing {
|
|
pub track_index: usize,
|
|
pub crossing_time: DateTime<Utc>,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
pub from_county_id: i64,
|
|
pub to_county_id: i64,
|
|
pub fraction: f64,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct WebhookEnvelope {
|
|
pub secret: String,
|
|
pub events: Vec<WebhookEvent>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct WebhookEvent {
|
|
pub athlete_id: String,
|
|
#[serde(rename = "type")]
|
|
pub event_type: String,
|
|
pub timestamp: DateTime<Utc>,
|
|
#[serde(default)]
|
|
pub activity: Option<Value>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Clone)]
|
|
pub struct LeaderboardRow {
|
|
pub rank: i64,
|
|
pub athlete: String,
|
|
pub from_county: String,
|
|
pub to_county: String,
|
|
pub crossing_time: DateTime<Utc>,
|
|
pub activity_id: String,
|
|
pub activity_url: String,
|
|
pub interval_url: Option<String>,
|
|
pub average_watts: Option<f64>,
|
|
pub average_heartrate: Option<f64>,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Clone)]
|
|
pub struct LeaderboardGroup {
|
|
pub bucket_start: DateTime<Utc>,
|
|
pub from_county: String,
|
|
pub to_county: String,
|
|
pub crossing_lat: f64,
|
|
pub crossing_lon: f64,
|
|
pub rows: Vec<LeaderboardRow>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Clone)]
|
|
pub struct ActivityCrossing {
|
|
pub crossing_time: DateTime<Utc>,
|
|
pub from_county: String,
|
|
pub to_county: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
pub rank: i64,
|
|
pub activity_id: String,
|
|
pub athlete: String,
|
|
pub interval_url: Option<String>,
|
|
pub average_watts: Option<f64>,
|
|
pub average_heartrate: Option<f64>,
|
|
}
|