From 20264f90a1f2266fe12f350e736420f1a1413f9a Mon Sep 17 00:00:00 2001 From: Mendy Berger <12537668+MendyBerger@users.noreply.github.com> Date: Fri, 23 Feb 2024 12:45:38 -0500 Subject: [PATCH] feat(be): Added jig liked and published counts --- backend/api/src/db/user.rs | 13 +++++++++++++ shared/rust/src/domain/user.rs | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/backend/api/src/db/user.rs b/backend/api/src/db/user.rs index 0ad9600f6..ddd14e543 100644 --- a/backend/api/src/db/user.rs +++ b/backend/api/src/db/user.rs @@ -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( @@ -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()) diff --git a/shared/rust/src/domain/user.rs b/shared/rust/src/domain/user.rs index 18be4c1db..6660393f6 100644 --- a/shared/rust/src/domain/user.rs +++ b/shared/rust/src/domain/user.rs @@ -479,6 +479,10 @@ pub struct UserProfileExport { pub country: Option, /// 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(list: &Vec, serializer: S) -> Result