feat(export): add repo topic export
zhenyi committed
Added lib/export/repo/topic.rs lib/export/repo/topic.rs +44 −0 View lib/export/repo/topic.rs
@@ -0,0 +1,44 @@
1use serde::{Deserialize, Serialize};
2use time::OffsetDateTime;
3use time::format_description::well_known::Rfc3339;
4use utoipa::{IntoParams, ToSchema};
5use uuid::Uuid;
6
7fn fmt_ts(ts: OffsetDateTime) -> String {
8 ts.format(&Rfc3339).unwrap_or_default()
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
12pub struct TopicView {
13 pub id: Uuid,
14 pub name: String,
15 pub repo_count: i32,
16 pub created_at: String,
17 pub updated_at: String,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
21pub struct TopicList {
22 pub topics: Vec<String>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
26pub struct TopicSearchResult {
27 pub topics: Vec<TopicView>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
31pub struct RepoTopicOptions {
32 pub topics: Vec<String>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
36pub struct TopicSearchQuery {
37 pub q: Option<String>,
38 pub page: Option<u64>,
39 pub limit: Option<u64>,
40}
41
42pub fn fmt_ts_pub(ts: OffsetDateTime) -> String {
43 fmt_ts(ts)
44}