Skip to content

Commit 9ca8e7e

Browse files
committed
fix: resolved failing workflows
1 parent c49b23e commit 9ca8e7e

File tree

4 files changed

+24
-46
lines changed

4 files changed

+24
-46
lines changed

Cargo.lock

Lines changed: 10 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/daily_task/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use chrono::NaiveTime;
21
use crate::graphql::mutations::{
32
fetch_and_update_codeforces_stats, fetch_and_update_leetcode, update_leaderboard_scores,
43
};
4+
use chrono::NaiveTime;
55
use chrono_tz::Asia::Kolkata;
66
use sqlx::PgPool;
77
use std::sync::Arc;
@@ -133,15 +133,15 @@ pub async fn update_leaderboard_task(pool: Arc<PgPool>) {
133133
// Update leaderboard
134134
match update_leaderboard_scores(pool.clone()).await {
135135
Ok(_) => println!("Leaderboard updated."),
136-
Err(e) => eprintln!("Failed to update leaderboard: {:?}", e),
136+
Err(e) => eprintln!("Failed to update leaderboard: {e:?}"),
137137
}
138138
}
139139
}
140-
Err(e) => eprintln!("Failed to fetch members: {:?}", e),
140+
Err(e) => eprintln!("Failed to fetch members: {e:?}"),
141141
}
142142
}
143143

144-
async fn update_attendance(members: Vec<Member>, pool: &PgPool) {
144+
async fn update_attendance(members: &Vec<Member>, pool: &PgPool) {
145145
#[allow(deprecated)]
146146
let today = chrono::Utc::now()
147147
.with_timezone(&Kolkata)

src/graphql/mutations/leaderboard_api.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub async fn fetch_and_update_codeforces_stats(
1010
member_id: i32,
1111
username: &str,
1212
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
13-
let url = format!("https://codeforces.com/api/user.rating?handle={}", username);
13+
let url = format!("https://codeforces.com/api/user.rating?handle={username}");
1414
let response = reqwest::get(&url).await?.text().await?;
1515
let data: Value = serde_json::from_str(&response)?;
1616

@@ -51,18 +51,17 @@ pub async fn fetch_and_update_codeforces_stats(
5151
.await;
5252

5353
match update_result {
54-
Ok(_) => println!("Codeforces stats updated for member ID: {}", member_id),
55-
Err(e) => eprintln!(
56-
"Failed to update Codeforces stats for member ID {}: {:?}",
57-
member_id, e
58-
),
54+
Ok(_) => println!("Codeforces stats updated for member ID: {member_id}"),
55+
Err(e) => {
56+
eprintln!("Failed to update Codeforces stats for member ID {member_id}: {e:?}")
57+
}
5958
}
6059

6160
return Ok(());
6261
}
6362
}
6463

65-
Err(format!("Failed to fetch stats for Codeforces handle: {}", username).into())
64+
Err(format!("Failed to fetch stats for Codeforces handle: {username}").into())
6665
}
6766

6867
pub async fn update_leaderboard_scores(pool: Arc<PgPool>) -> Result<(), sqlx::Error> {

src/graphql/mutations/update_leaderboard.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ impl LeaderboardMutation {
2020
)
2121
.fetch_all(pool.as_ref())
2222
.await
23-
.map_err(|e| {
24-
async_graphql::Error::new(format!("Failed to fetch LeetCode stats: {:?}", e))
25-
})?;
23+
.map_err(|e| async_graphql::Error::new(format!("Failed to fetch LeetCode stats: {e:?}")))?;
2624

2725
let codeforces_stats = sqlx::query!(
2826
"SELECT member_id, codeforces_rating, max_rating, contests_participated
@@ -31,7 +29,7 @@ impl LeaderboardMutation {
3129
.fetch_all(pool.as_ref())
3230
.await
3331
.map_err(|e| {
34-
async_graphql::Error::new(format!("Failed to fetch Codeforces stats: {:?}", e))
32+
async_graphql::Error::new(format!("Failed to fetch Codeforces stats: {e:?}"))
3533
})?;
3634

3735
let cf_lookup: HashMap<i32, (i32, i32, i32)> = codeforces_stats
@@ -72,8 +70,7 @@ impl LeaderboardMutation {
7270
unified_score = EXCLUDED.unified_score,
7371
last_updated = NOW()",
7472
row.member_id,
75-
leetcode_score,
76-
codeforces_score,
73+
0,codeforces_score,
7774
unified_score
7875
)
7976
.execute(pool.as_ref())
@@ -110,7 +107,7 @@ impl LeaderboardMutation {
110107
unified_score = EXCLUDED.unified_score,
111108
last_updated = NOW()",
112109
row.member_id,
113-
codeforces_score,
110+
0,codeforces_score,
114111
unified_score
115112
)
116113
.execute(pool.as_ref())

0 commit comments

Comments
 (0)