Recommendation question: not for admins and authors
The team's answers would only blur the number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
//! * messages from the "Visszajelzés" page (bug, idea, question), with a
|
||||
//! state and the operator's reply, both shown to the user there;
|
||||
//! * one "would you recommend us?" question (0–10, NPS), asked once in the
|
||||
//! app after a couple of finished contents.
|
||||
//! app after a couple of finished contents (not of the team).
|
||||
//!
|
||||
//! Admins see it all on Admin → Visszajelzések; the admin menu counts what is
|
||||
//! new.
|
||||
@@ -356,11 +356,13 @@ pub async fn unseen_replies(conn: &mut PgConnection, user: Uuid) -> Result<i64,
|
||||
|
||||
// --- the recommendation question (NPS) -----------------------------------------------------------
|
||||
|
||||
/// Whether to ask the user now: not asked before, and has a couple of
|
||||
/// finished contents (the free summary does not count).
|
||||
/// Whether to ask the user now: not asked before, has a couple of finished
|
||||
/// contents (the free summary does not count), and is no one of the team
|
||||
/// (admins and authors).
|
||||
pub async fn nps_due(conn: &mut PgConnection, user: Uuid) -> Result<bool, sqlx::Error> {
|
||||
sqlx::query_scalar(&format!(
|
||||
"SELECT NOT EXISTS (SELECT 1 FROM nps_answers WHERE user_id = $1) \
|
||||
AND NOT EXISTS (SELECT 1 FROM users WHERE id = $1 AND roles && ARRAY['admin', 'creator']) \
|
||||
AND (SELECT count(*) FROM analyses WHERE requested_by = $1 AND status = 'done' \
|
||||
AND kind IN ('natal', 'synastry', 'forecast', 'tarot')) \
|
||||
+ (SELECT count(*) FROM questions WHERE asked_by = $1 AND status = 'done') >= {NPS_AFTER}"
|
||||
|
||||
Reference in New Issue
Block a user