//! Discover page query models. use chrono::{DateTime, Utc}; use serde::Serialize; use sqlx::FromRow; use super::super::id_types::*; use super::super::validated_types::*; /// A flattened item row returned by the discover/search query. #[derive(Debug, Clone, FromRow)] #[allow(dead_code)] // Fields populated by sqlx query, read during type conversion pub struct DbDiscoverItemRow { /// Item primary key. pub id: ItemId, /// Item title. pub title: String, /// Item description. pub description: Option, /// Price in cents. pub price_cents: i32, /// Content type. pub item_type: super::super::ItemType, /// When the item was created. pub created_at: DateTime, /// Creator's username (joined from users). pub username: Username, /// Parent project title (joined from projects). pub project_title: String, /// Number of completed purchases. pub sales_count: i64, /// Primary tag name (joined from item_tags/tags), or NULL if no primary tag. pub primary_tag_name: Option, /// Whether PWYW pricing is enabled. pub pwyw_enabled: bool, /// Minimum price in cents when PWYW is enabled. pub pwyw_min_cents: Option, /// Trigram similarity score (set when searching, `None` otherwise). pub match_score: Option, /// AI disclosure tier — drives the badge / row label on Discover. pub ai_tier: super::super::AiTier, } /// A flattened project row returned by the discover projects query. #[derive(Debug, Clone, FromRow)] #[allow(dead_code)] // Fields populated by sqlx query, read during type conversion pub struct DbDiscoverProjectRow { /// Project URL slug. pub slug: Slug, /// Project title. pub title: String, /// Project description. pub description: Option, /// Project category. pub project_type: super::super::ProjectType, /// When the project was created. pub created_at: DateTime, /// Creator's username (joined from users). pub username: Username, /// Number of public items in this project. pub item_count: i64, /// Trigram similarity score (set when searching, `None` otherwise). pub match_score: Option, /// Category name (joined from project_categories), or NULL if uncategorized. pub category_name: Option, /// Category slug (joined from project_categories), or NULL if uncategorized. pub category_slug: Option, } /// An item_type value paired with the number of matching items. #[derive(Debug, Clone, FromRow)] pub struct DbItemTypeCount { /// The item_type category value. pub category: String, /// Number of matching items of this type. pub count: i64, } /// Bucketed item counts by price range for the discover page sidebar. #[derive(Debug, Clone, Default)] pub struct DbPriceRangeCounts { /// Items priced at $0. pub free: i64, /// Items priced $0.01 -- $24.99. pub under_25: i64, /// Items priced $25.00 -- $49.99. pub range_25_50: i64, /// Items priced $50.00 -- $99.99. pub range_50_100: i64, /// Items priced $100.00 and above. pub over_100: i64, } /// A user-defined external link shown on their profile. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbCustomLink { /// Database primary key. pub id: CustomLinkId, /// Owning user's ID. pub user_id: UserId, /// Full URL. pub url: String, /// Display title for the link. pub title: String, /// Optional description shown below the title. pub description: Option, /// Position in the user's link list. pub sort_order: i32, /// When the link was created. pub created_at: DateTime, /// When the link was last modified. pub updated_at: DateTime, }