From 8997d92e41eb22481bff9ed816747ce564671fce Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Wed, 21 May 2025 09:53:10 +0300 Subject: [PATCH] feat: Add created_at, updated_at fields in the db proposal model --- heromodels/examples/governance_proposal_example/main.rs | 4 ++++ heromodels/examples/governance_rhai/example.rs | 8 ++++++++ heromodels/src/models/governance/proposal.rs | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/heromodels/examples/governance_proposal_example/main.rs b/heromodels/examples/governance_proposal_example/main.rs index 9b75c9d..9d790f9 100644 --- a/heromodels/examples/governance_proposal_example/main.rs +++ b/heromodels/examples/governance_proposal_example/main.rs @@ -18,6 +18,8 @@ fn main() { "Ahmed fared", // creator_id "Community Fund Allocation for Q3", // title "Proposal to allocate funds for community projects in the third quarter.", // description + Utc::now(), // created_at + Utc::now(), // updated_at Utc::now(), // vote_start_date Utc::now() + Duration::days(14), // vote_end_date (14 days from now) ); @@ -130,6 +132,8 @@ fn main() { "Internal Team Restructure Vote", "Vote on proposed internal team changes.", Utc::now(), + Utc::now(), + Utc::now(), Utc::now() + Duration::days(7), ); private_proposal.private_group = Some(vec![10, 20, 30]); // Only users 10, 20, 30 can vote diff --git a/heromodels/examples/governance_rhai/example.rs b/heromodels/examples/governance_rhai/example.rs index 65a9089..0b1ba14 100644 --- a/heromodels/examples/governance_rhai/example.rs +++ b/heromodels/examples/governance_rhai/example.rs @@ -38,6 +38,8 @@ fn main() -> Result<(), Box> { creator_name, title, description, + Utc::now(), + Utc::now(), start_date, end_date, ) @@ -156,6 +158,8 @@ fn main() -> Result<(), Box> { "Retrieved Creator Name", "Retrieved Proposal", "Retrieved Description", + Utc::now(), + Utc::now(), start_date, end_date, ) @@ -180,6 +184,8 @@ fn main() -> Result<(), Box> { "Creator Name 1", "Proposal 1", "Description 1", + Utc::now(), + Utc::now(), start_date, end_date, ), @@ -189,6 +195,8 @@ fn main() -> Result<(), Box> { "Creator Name 2", "Proposal 2", "Description 2", + Utc::now(), + Utc::now(), start_date, end_date, ), diff --git a/heromodels/src/models/governance/proposal.rs b/heromodels/src/models/governance/proposal.rs index 4e26a68..3ab0647 100644 --- a/heromodels/src/models/governance/proposal.rs +++ b/heromodels/src/models/governance/proposal.rs @@ -109,6 +109,9 @@ pub struct Proposal { pub description: String, pub status: ProposalStatus, + pub created_at: DateTime, + pub updated_at: DateTime, + // Voting event aspects pub vote_start_date: DateTime, pub vote_end_date: DateTime, @@ -134,6 +137,8 @@ impl Proposal { creator_name: impl ToString, title: impl ToString, description: impl ToString, + created_at: DateTime, + updated_at: DateTime, vote_start_date: DateTime, vote_end_date: DateTime, ) -> Self { @@ -149,6 +154,8 @@ impl Proposal { title: title.to_string(), description: description.to_string(), status: ProposalStatus::Draft, + created_at, + updated_at, vote_start_date, vote_end_date, vote_status: VoteEventStatus::Open, // Default to open when created