feat: Add created_at, updated_at fields in the db proposal model

This commit is contained in:
Mahmoud-Emad 2025-05-21 09:53:10 +03:00
parent 5327d1f00c
commit 8997d92e41
3 changed files with 19 additions and 0 deletions

View File

@ -18,6 +18,8 @@ fn main() {
"Ahmed fared", // creator_id "Ahmed fared", // creator_id
"Community Fund Allocation for Q3", // title "Community Fund Allocation for Q3", // title
"Proposal to allocate funds for community projects in the third quarter.", // description "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(), // vote_start_date
Utc::now() + Duration::days(14), // vote_end_date (14 days from now) Utc::now() + Duration::days(14), // vote_end_date (14 days from now)
); );
@ -130,6 +132,8 @@ fn main() {
"Internal Team Restructure Vote", "Internal Team Restructure Vote",
"Vote on proposed internal team changes.", "Vote on proposed internal team changes.",
Utc::now(), Utc::now(),
Utc::now(),
Utc::now(),
Utc::now() + Duration::days(7), Utc::now() + Duration::days(7),
); );
private_proposal.private_group = Some(vec![10, 20, 30]); // Only users 10, 20, 30 can vote private_proposal.private_group = Some(vec![10, 20, 30]); // Only users 10, 20, 30 can vote

View File

@ -38,6 +38,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
creator_name, creator_name,
title, title,
description, description,
Utc::now(),
Utc::now(),
start_date, start_date,
end_date, end_date,
) )
@ -156,6 +158,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"Retrieved Creator Name", "Retrieved Creator Name",
"Retrieved Proposal", "Retrieved Proposal",
"Retrieved Description", "Retrieved Description",
Utc::now(),
Utc::now(),
start_date, start_date,
end_date, end_date,
) )
@ -180,6 +184,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"Creator Name 1", "Creator Name 1",
"Proposal 1", "Proposal 1",
"Description 1", "Description 1",
Utc::now(),
Utc::now(),
start_date, start_date,
end_date, end_date,
), ),
@ -189,6 +195,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"Creator Name 2", "Creator Name 2",
"Proposal 2", "Proposal 2",
"Description 2", "Description 2",
Utc::now(),
Utc::now(),
start_date, start_date,
end_date, end_date,
), ),

View File

@ -109,6 +109,9 @@ pub struct Proposal {
pub description: String, pub description: String,
pub status: ProposalStatus, pub status: ProposalStatus,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
// Voting event aspects // Voting event aspects
pub vote_start_date: DateTime<Utc>, pub vote_start_date: DateTime<Utc>,
pub vote_end_date: DateTime<Utc>, pub vote_end_date: DateTime<Utc>,
@ -134,6 +137,8 @@ impl Proposal {
creator_name: impl ToString, creator_name: impl ToString,
title: impl ToString, title: impl ToString,
description: impl ToString, description: impl ToString,
created_at: DateTime<Utc>,
updated_at: DateTime<Utc>,
vote_start_date: DateTime<Utc>, vote_start_date: DateTime<Utc>,
vote_end_date: DateTime<Utc>, vote_end_date: DateTime<Utc>,
) -> Self { ) -> Self {
@ -149,6 +154,8 @@ impl Proposal {
title: title.to_string(), title: title.to_string(),
description: description.to_string(), description: description.to_string(),
status: ProposalStatus::Draft, status: ProposalStatus::Draft,
created_at,
updated_at,
vote_start_date, vote_start_date,
vote_end_date, vote_end_date,
vote_status: VoteEventStatus::Open, // Default to open when created vote_status: VoteEventStatus::Open, // Default to open when created