Skip to main content

linkrs_server/web/models/
metadata.rs

1//! Metadata Models (Query History & Favorites)
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// Query history item
7#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
8pub struct HistoryItem {
9    pub id: String,
10    pub session_id: String,
11    pub query: String,
12    #[schema(value_type = String)]
13    pub executed_at: DateTime<Utc>,
14    pub execution_time_ms: i64,
15    pub rows_returned: i64,
16    pub success: bool,
17    pub error_message: Option<String>,
18}
19
20/// Request to add history item
21#[derive(Debug, Deserialize, utoipa::ToSchema)]
22pub struct AddHistoryRequest {
23    pub query: String,
24    pub execution_time_ms: i64,
25    pub rows_returned: i64,
26    pub success: bool,
27    pub error_message: Option<String>,
28}
29
30/// Query favorite item
31#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
32pub struct FavoriteItem {
33    pub id: String,
34    pub session_id: String,
35    pub name: String,
36    pub query: String,
37    pub description: Option<String>,
38    #[schema(value_type = String)]
39    pub created_at: DateTime<Utc>,
40}
41
42/// Request to add favorite
43#[derive(Debug, Deserialize, utoipa::ToSchema)]
44pub struct AddFavoriteRequest {
45    pub name: String,
46    pub query: String,
47    pub description: Option<String>,
48}
49
50/// Request to update favorite
51#[derive(Debug, Deserialize, utoipa::ToSchema)]
52pub struct UpdateFavoriteRequest {
53    pub name: Option<String>,
54    pub query: Option<String>,
55    pub description: Option<String>,
56}
57
58/// Favorite list response
59#[derive(Debug, Serialize, utoipa::ToSchema)]
60pub struct FavoriteListResponse {
61    pub items: Vec<FavoriteItem>,
62}
63
64/// History list response
65#[derive(Debug, Serialize, utoipa::ToSchema)]
66pub struct HistoryListResponse {
67    pub items: Vec<HistoryItem>,
68    pub total: i64,
69}