Refactor insights handling and error encoding in presentation layer
- Updated insights analyzer tests to use Utc for date handling. - Added timezone support for insights retrieval, allowing insights to be bucketed by the user's local time. - Introduced `encode_domain_error` for better error handling in API responses. - Modified various handlers to utilize the new error encoding function. - Enhanced insights API to reject unknown time zones and return appropriate errors. - Updated frontend components to handle insights data with timezone awareness. - Improved localization for insights sample counts.
This commit is contained in:
@@ -17,7 +17,7 @@ pub enum InsightDto {
|
||||
sample_count: u32,
|
||||
},
|
||||
/// `genre`'s share of watches in `month` (1–12) is `multiplier` times the
|
||||
/// uniform 1/12 baseline.
|
||||
/// user's own share of watches in that month.
|
||||
Seasonality {
|
||||
genre: String,
|
||||
month: u32,
|
||||
@@ -47,3 +47,11 @@ pub enum InsightDto {
|
||||
pub struct InsightsResponse {
|
||||
pub insights: Vec<InsightDto>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, utoipa::IntoParams)]
|
||||
#[into_params(parameter_in = Query)]
|
||||
pub struct InsightsQueryParams {
|
||||
/// IANA time zone (e.g. `Europe/Warsaw`) months, weekdays and hours are
|
||||
/// bucketed in. Defaults to UTC.
|
||||
pub tz: Option<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user