Skip to content

Commit

Permalink
feat(be): Added jig liked and published counts
Browse files Browse the repository at this point in the history
  • Loading branch information
MendyBerger committed Feb 23, 2024
1 parent 9a250df commit 20264f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend/api/src/db/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,17 @@ select
order by last_used desc
limit 1
),
(
select count(*) as liked_jig_count
from jig_like
where user_id = "user".id
),
(
select count(*) as published_jigs_count
from jig
where published_at is not null
and author_id = "user".id
),
location,
opt_into_edu_resources,
array(
Expand Down Expand Up @@ -556,6 +567,8 @@ where
age_ranges: row.age_ranges,
affiliations: row.affiliations,
opt_into_edu_resources: row.opt_into_edu_resources,
liked_jig_count: row.liked_jig_count.unwrap_or_default(),
published_jigs_count: row.published_jigs_count.unwrap_or_default(),
}
})
.collect())
Expand Down
4 changes: 4 additions & 0 deletions shared/rust/src/domain/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ pub struct UserProfileExport {
pub country: Option<String>,
/// Whether this user has opted in to receive educational resources
pub opt_into_edu_resources: bool,
/// Number of liked jigs
pub liked_jig_count: i64,
/// Number of published jigs
pub published_jigs_count: i64,
}

fn serialize_list<S, T>(list: &Vec<T>, serializer: S) -> Result<S::Ok, S::Error>
Expand Down

0 comments on commit 20264f9

Please sign in to comment.