Skip to content

Commit 1ebf50e

Browse files
committed
fix: move status update date calculation out of business logic
1 parent 124d83f commit 1ebf50e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/graphql/mutations/status_mutations.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use async_graphql::{Context, Object, Result};
2-
use chrono_tz::Asia::Kolkata;
2+
use chrono::NaiveDate;
33
use sqlx::PgPool;
44
use std::sync::Arc;
55

@@ -14,15 +14,10 @@ impl StatusMutations {
1414
&self,
1515
ctx: &Context<'_>,
1616
emails: Vec<String>,
17+
date: NaiveDate,
1718
) -> Result<Vec<StatusUpdateRecord>> {
1819
let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context");
1920
#[allow(deprecated)]
20-
let yesterday = chrono::Utc::now()
21-
.with_timezone(&Kolkata)
22-
.date()
23-
.naive_local()
24-
- chrono::Duration::days(1);
25-
2621
let status = sqlx::query_as::<_, StatusUpdateRecord>(
2722
"UPDATE StatusUpdateHistory SET
2823
is_sent = true
@@ -32,7 +27,7 @@ impl StatusMutations {
3227
",
3328
)
3429
.bind(emails)
35-
.bind(yesterday)
30+
.bind(date)
3631
.fetch_all(pool.as_ref())
3732
.await?;
3833

0 commit comments

Comments
 (0)