From 10ccba0bb906c59e0d358fcb471676121e65f571 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Tue, 8 Oct 2024 00:25:40 -0400 Subject: [PATCH] Add serialization for datetime fields. --- deepwell/src/models/alias.rs | 1 + deepwell/src/models/blob_pending.rs | 2 ++ deepwell/src/models/file.rs | 3 +++ deepwell/src/models/file_revision.rs | 1 + deepwell/src/models/filter.rs | 3 +++ deepwell/src/models/message_draft.rs | 3 +++ deepwell/src/models/message_record.rs | 4 ++++ deepwell/src/models/message_report.rs | 2 ++ deepwell/src/models/page.rs | 3 +++ deepwell/src/models/page_attribution.rs | 1 + deepwell/src/models/page_category.rs | 2 ++ deepwell/src/models/page_connection.rs | 2 ++ deepwell/src/models/page_connection_missing.rs | 2 ++ deepwell/src/models/page_link.rs | 2 ++ deepwell/src/models/page_lock.rs | 4 ++++ deepwell/src/models/page_parent.rs | 1 + deepwell/src/models/page_revision.rs | 3 +++ deepwell/src/models/page_vote.rs | 3 +++ deepwell/src/models/relation.rs | 3 +++ deepwell/src/models/session.rs | 2 ++ deepwell/src/models/site.rs | 3 +++ deepwell/src/models/site_domain.rs | 1 + deepwell/src/models/user.rs | 6 ++++++ deepwell/src/models/user_bot_owner.rs | 2 ++ 24 files changed, 59 insertions(+) diff --git a/deepwell/src/models/alias.rs b/deepwell/src/models/alias.rs index 3b489bfbb4..f502b823c1 100644 --- a/deepwell/src/models/alias.rs +++ b/deepwell/src/models/alias.rs @@ -10,6 +10,7 @@ pub struct Model { #[sea_orm(primary_key)] pub alias_id: i64, pub alias_type: AliasType, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, pub created_by: i64, pub target_id: i64, diff --git a/deepwell/src/models/blob_pending.rs b/deepwell/src/models/blob_pending.rs index 8cd96e2abf..5f89133319 100644 --- a/deepwell/src/models/blob_pending.rs +++ b/deepwell/src/models/blob_pending.rs @@ -9,7 +9,9 @@ pub struct Model { #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub external_id: String, pub created_by: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339")] pub expires_at: TimeDateTimeWithTimeZone, pub expected_length: i64, #[sea_orm(column_type = "Text")] diff --git a/deepwell/src/models/file.rs b/deepwell/src/models/file.rs index ce05ac6f77..7421debd7b 100644 --- a/deepwell/src/models/file.rs +++ b/deepwell/src/models/file.rs @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key)] pub file_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, pub from_wikidot: bool, #[sea_orm(column_type = "Text")] diff --git a/deepwell/src/models/file_revision.rs b/deepwell/src/models/file_revision.rs index b5250d6ea9..989483d82d 100644 --- a/deepwell/src/models/file_revision.rs +++ b/deepwell/src/models/file_revision.rs @@ -10,6 +10,7 @@ pub struct Model { #[sea_orm(primary_key)] pub revision_id: i64, pub revision_type: FileRevisionType, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, pub revision_number: i32, pub file_id: i64, diff --git a/deepwell/src/models/filter.rs b/deepwell/src/models/filter.rs index a62e24e527..e07cb1a3a8 100644 --- a/deepwell/src/models/filter.rs +++ b/deepwell/src/models/filter.rs @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key)] pub filter_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, pub site_id: Option, pub affects_user: bool, diff --git a/deepwell/src/models/message_draft.rs b/deepwell/src/models/message_draft.rs index 2c2053e820..2a0baed73d 100644 --- a/deepwell/src/models/message_draft.rs +++ b/deepwell/src/models/message_draft.rs @@ -8,7 +8,9 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub external_id: String, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, pub user_id: i64, pub recipients: Json, @@ -18,6 +20,7 @@ pub struct Model { pub wikitext_hash: Vec, #[sea_orm(column_type = "VarBinary(StringLen::None)")] pub compiled_hash: Vec, + #[serde(with = "time::serde::rfc3339")] pub compiled_at: TimeDateTimeWithTimeZone, #[sea_orm(column_type = "Text")] pub compiled_generator: String, diff --git a/deepwell/src/models/message_record.rs b/deepwell/src/models/message_record.rs index 0d07530b06..9301f3000f 100644 --- a/deepwell/src/models/message_record.rs +++ b/deepwell/src/models/message_record.rs @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub external_id: String, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339")] pub drafted_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub retracted_at: Option, pub sender_id: i64, #[sea_orm(column_type = "Text")] @@ -18,6 +21,7 @@ pub struct Model { pub wikitext_hash: Vec, #[sea_orm(column_type = "VarBinary(StringLen::None)")] pub compiled_hash: Vec, + #[serde(with = "time::serde::rfc3339")] pub compiled_at: TimeDateTimeWithTimeZone, #[sea_orm(column_type = "Text")] pub compiled_generator: String, diff --git a/deepwell/src/models/message_report.rs b/deepwell/src/models/message_report.rs index e1fc267014..60cf76eb5e 100644 --- a/deepwell/src/models/message_report.rs +++ b/deepwell/src/models/message_report.rs @@ -10,7 +10,9 @@ pub struct Model { pub message_id: i64, #[sea_orm(primary_key, auto_increment = false)] pub reported_to_site_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, #[sea_orm(column_type = "Text")] pub reason: String, diff --git a/deepwell/src/models/page.rs b/deepwell/src/models/page.rs index ab0450e1dd..3d0070c2de 100644 --- a/deepwell/src/models/page.rs +++ b/deepwell/src/models/page.rs @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key)] pub page_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, pub from_wikidot: bool, pub site_id: i64, diff --git a/deepwell/src/models/page_attribution.rs b/deepwell/src/models/page_attribution.rs index 47c70f1f40..e61c689dba 100644 --- a/deepwell/src/models/page_attribution.rs +++ b/deepwell/src/models/page_attribution.rs @@ -14,6 +14,7 @@ pub struct Model { pub attribution_type: String, #[sea_orm(primary_key, auto_increment = false)] pub attribution_date: TimeDate, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, } diff --git a/deepwell/src/models/page_category.rs b/deepwell/src/models/page_category.rs index b1ca1c4bb7..61af525760 100644 --- a/deepwell/src/models/page_category.rs +++ b/deepwell/src/models/page_category.rs @@ -8,7 +8,9 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key)] pub category_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, pub site_id: i64, #[sea_orm(column_type = "Text")] diff --git a/deepwell/src/models/page_connection.rs b/deepwell/src/models/page_connection.rs index b95b82cad1..4c3887731e 100644 --- a/deepwell/src/models/page_connection.rs +++ b/deepwell/src/models/page_connection.rs @@ -12,7 +12,9 @@ pub struct Model { pub to_page_id: i64, #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub connection_type: String, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, pub count: i32, } diff --git a/deepwell/src/models/page_connection_missing.rs b/deepwell/src/models/page_connection_missing.rs index 119a3ae420..b931adeb0a 100644 --- a/deepwell/src/models/page_connection_missing.rs +++ b/deepwell/src/models/page_connection_missing.rs @@ -14,7 +14,9 @@ pub struct Model { pub to_page_slug: String, #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub connection_type: String, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, pub count: i32, } diff --git a/deepwell/src/models/page_link.rs b/deepwell/src/models/page_link.rs index 128499e77f..31c5436838 100644 --- a/deepwell/src/models/page_link.rs +++ b/deepwell/src/models/page_link.rs @@ -10,7 +10,9 @@ pub struct Model { pub page_id: i64, #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub url: String, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, pub count: i32, } diff --git a/deepwell/src/models/page_lock.rs b/deepwell/src/models/page_lock.rs index 4304700d34..d0350a191f 100644 --- a/deepwell/src/models/page_lock.rs +++ b/deepwell/src/models/page_lock.rs @@ -8,9 +8,13 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key)] pub page_lock_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub expires_at: Option, pub from_wikidot: bool, #[sea_orm(column_type = "Text")] diff --git a/deepwell/src/models/page_parent.rs b/deepwell/src/models/page_parent.rs index 0401235949..13a6cb9df2 100644 --- a/deepwell/src/models/page_parent.rs +++ b/deepwell/src/models/page_parent.rs @@ -10,6 +10,7 @@ pub struct Model { pub parent_page_id: i64, #[sea_orm(primary_key, auto_increment = false)] pub child_page_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, } diff --git a/deepwell/src/models/page_revision.rs b/deepwell/src/models/page_revision.rs index 28a0aa3725..686c3a0350 100644 --- a/deepwell/src/models/page_revision.rs +++ b/deepwell/src/models/page_revision.rs @@ -10,7 +10,9 @@ pub struct Model { #[sea_orm(primary_key)] pub revision_id: i64, pub revision_type: PageRevisionType, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, pub revision_number: i32, pub page_id: i64, @@ -22,6 +24,7 @@ pub struct Model { pub wikitext_hash: Vec, #[sea_orm(column_type = "VarBinary(StringLen::None)")] pub compiled_hash: Vec, + #[serde(with = "time::serde::rfc3339")] pub compiled_at: TimeDateTimeWithTimeZone, #[sea_orm(column_type = "Text")] pub compiled_generator: String, diff --git a/deepwell/src/models/page_vote.rs b/deepwell/src/models/page_vote.rs index 9355247c31..5bf86256b2 100644 --- a/deepwell/src/models/page_vote.rs +++ b/deepwell/src/models/page_vote.rs @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key)] pub page_vote_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub disabled_at: Option, pub disabled_by: Option, pub from_wikidot: bool, diff --git a/deepwell/src/models/relation.rs b/deepwell/src/models/relation.rs index 325c733902..f7a00e80bb 100644 --- a/deepwell/src/models/relation.rs +++ b/deepwell/src/models/relation.rs @@ -17,10 +17,13 @@ pub struct Model { pub from_id: i64, pub metadata: Json, pub created_by: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, pub overwritten_by: Option, + #[serde(with = "time::serde::rfc3339::option")] pub overwritten_at: Option, pub deleted_by: Option, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, } diff --git a/deepwell/src/models/session.rs b/deepwell/src/models/session.rs index 613573bdac..c061dab585 100644 --- a/deepwell/src/models/session.rs +++ b/deepwell/src/models/session.rs @@ -9,7 +9,9 @@ pub struct Model { #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub session_token: String, pub user_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339")] pub expires_at: TimeDateTimeWithTimeZone, #[sea_orm(column_type = "Text")] pub ip_address: String, diff --git a/deepwell/src/models/site.rs b/deepwell/src/models/site.rs index da6fc836f8..576a9b3dff 100644 --- a/deepwell/src/models/site.rs +++ b/deepwell/src/models/site.rs @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct Model { #[sea_orm(primary_key)] pub site_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, pub from_wikidot: bool, #[sea_orm(column_type = "Text")] diff --git a/deepwell/src/models/site_domain.rs b/deepwell/src/models/site_domain.rs index c1851b6e04..5efc3e1f35 100644 --- a/deepwell/src/models/site_domain.rs +++ b/deepwell/src/models/site_domain.rs @@ -9,6 +9,7 @@ pub struct Model { #[sea_orm(primary_key, auto_increment = false, column_type = "Text")] pub domain: String, pub site_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, } diff --git a/deepwell/src/models/user.rs b/deepwell/src/models/user.rs index a985950552..6133d205c4 100644 --- a/deepwell/src/models/user.rs +++ b/deepwell/src/models/user.rs @@ -10,8 +10,11 @@ pub struct Model { #[sea_orm(primary_key)] pub user_id: i64, pub user_type: UserType, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, + #[serde(with = "time::serde::rfc3339::option")] pub deleted_at: Option, pub from_wikidot: bool, #[sea_orm(column_type = "Text")] @@ -19,11 +22,14 @@ pub struct Model { #[sea_orm(column_type = "Text")] pub slug: String, pub name_changes_left: i16, + #[serde(with = "time::serde::rfc3339")] pub last_name_change_added_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub last_renamed_at: Option, #[sea_orm(column_type = "Text")] pub email: String, pub email_is_alias: Option, + #[serde(with = "time::serde::rfc3339::option")] pub email_verified_at: Option, #[sea_orm(column_type = "Text")] pub password: String, diff --git a/deepwell/src/models/user_bot_owner.rs b/deepwell/src/models/user_bot_owner.rs index b5bc1cc88a..d58021d290 100644 --- a/deepwell/src/models/user_bot_owner.rs +++ b/deepwell/src/models/user_bot_owner.rs @@ -10,7 +10,9 @@ pub struct Model { pub bot_user_id: i64, #[sea_orm(primary_key, auto_increment = false)] pub human_user_id: i64, + #[serde(with = "time::serde::rfc3339")] pub created_at: TimeDateTimeWithTimeZone, + #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, #[sea_orm(column_type = "Text")] pub description: String,