Skip to content

Commit a576b37

Browse files
committed
feat: added hall-of-fame to statistics
1 parent da3caf9 commit a576b37

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

server/.sqlx/query-8ee4104fd4da0df005bba732952d9b4232dc0d96022f5ecc7557cbd4e9c1a011.json renamed to server/.sqlx/query-b4091c5f2fe10b8be3574cfb18880ff60de8c51ca8693256d1dbe85d2f11c429.json

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

server/sql/get_statistics.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ highest_rating AS (
6363
pr.merged_at - pr.created_at ASC
6464
LIMIT
6565
1
66+
), hall_of_fame AS (
67+
SELECT
68+
STRING_AGG(u.login, ',') AS fame_logins
69+
FROM
70+
users AS u
71+
WHERE
72+
u.permanent_bonus > 0
6673
)
6774
SELECT
6875
ss.number_of_sloths,
@@ -78,8 +85,10 @@ SELECT
7885
fm.full_name AS fastest_org_full_name,
7986
fm.created_at as fastest_included,
8087
fm.merged_at as fastest_merged,
81-
fm.number AS fastest_pr_number
88+
fm.number AS fastest_pr_number,
89+
hof.fame_logins as hall_of_fame
8290
FROM
8391
sloth_stats ss,
8492
highest_rating hr,
85-
fastest_merge fm;
93+
fastest_merge fm,
94+
hall_of_fame hof;

server/src/db/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,7 @@ pub struct Statistics {
146146
pub fastest_pr_number: Option<i32>,
147147
pub fastest_included: Option<chrono::NaiveDateTime>,
148148
pub fastest_merged: Option<chrono::NaiveDateTime>,
149+
150+
// CSV
151+
pub hall_of_fame: Option<String>,
149152
}

server/src/entrypoints/types.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,25 @@ pub struct Statistics {
287287
pub total_rating: u32,
288288
pub highest_sloth_rating: (GithubMeta, u32),
289289
pub shortest_merge_time: (String, String),
290+
pub number_of_famed_sloths: u32,
291+
pub hall_of_fame: Vec<GithubMeta>,
290292
}
291293

292294
impl From<crate::db::types::Statistics> for Statistics {
293295
fn from(value: crate::db::types::Statistics) -> Self {
294-
dbg!(&value);
295296
let duration = value
296297
.fastest_merged
297298
.map(|x| x - value.fastest_included.unwrap_or_default())
298299
.unwrap_or_default();
300+
let hall_of_fame = if let Some(hall_of_fame) = value.hall_of_fame {
301+
hall_of_fame
302+
.split(',')
303+
.map(|x| GithubMeta::new(x.to_string(), None))
304+
.collect()
305+
} else {
306+
vec![]
307+
};
308+
299309
Self {
300310
number_of_sloths: value.number_of_sloths.unwrap_or_default() as u32,
301311
number_of_repos: value.number_of_repos.unwrap_or_default() as u32,
@@ -315,6 +325,8 @@ impl From<crate::db::types::Statistics> for Statistics {
315325
),
316326
duration.to_string(),
317327
),
328+
number_of_famed_sloths: hall_of_fame.len() as u32,
329+
hall_of_fame,
318330
}
319331
}
320332
}

0 commit comments

Comments
 (0)