Skip to main content

systemprompt_analytics/models/cli/
content.rs

1//! CLI-facing content analytics rows.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8use sqlx::FromRow;
9use systemprompt_identifiers::{ContentId, SourceId};
10
11#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
12pub struct TopContentRow {
13    pub content_id: ContentId,
14    pub slug: Option<String>,
15    pub title: Option<String>,
16    pub source_id: Option<SourceId>,
17    pub total_views: i64,
18    pub unique_visitors: i64,
19    pub avg_time_on_page_seconds: Option<f64>,
20    pub trend_direction: Option<String>,
21}
22
23#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
24pub struct ContentStatsRow {
25    pub total_views: i64,
26    pub unique_visitors: i64,
27    pub avg_time_on_page_seconds: Option<f64>,
28    pub avg_scroll_depth: Option<f64>,
29    pub total_clicks: i64,
30}
31
32#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
33pub struct ContentTrendRow {
34    pub timestamp: DateTime<Utc>,
35    pub views: i64,
36    pub unique_visitors: i64,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
40pub struct TrafficSourceRow {
41    pub source: Option<String>,
42    pub count: i64,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
46pub struct GeoRow {
47    pub country: Option<String>,
48    pub count: i64,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
52pub struct DeviceRow {
53    pub device: Option<String>,
54    pub browser: Option<String>,
55    pub count: i64,
56}
57
58#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
59pub struct BotTotalsRow {
60    pub human: i64,
61    pub bot: i64,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
65pub struct BotTypeRow {
66    pub bot_type: Option<String>,
67    pub count: i64,
68}