Recommendation question: not for admins and authors
CI / test (push) Successful in 2m38s
CI / build (push) Skipped
CI / deploy (push) Skipped

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:
feco
2026-11-24 07:49:26 +00:00
co-authored by Claude Opus 5.5
parent e1dee3a20d
commit 6731955fce
3 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ A felhasználók elégedettségét a rendszeren belül mérjük: semmi nem megy
## 3. Ajánlási kérdés (NPS) ## 3. Ajánlási kérdés (NPS)
- **Kinek:** akinek már legalább 2 kész tartalma van (részletes elemzés, előrejelzés, kártyajóslás vagy válasz; az ingyenes összefoglaló nem számít). - **Kinek:** akinek már legalább 2 kész tartalma van (részletes elemzés, előrejelzés, kártyajóslás vagy válasz; az ingyenes összefoglaló nem számít). Az adminok és a szerzők nem kapják meg.
- **Hogyan:** egyszer, egy bezárható dobozban az oldal legalján, a tartalom (a `main`) után és a lábléc előtt, külön: „Mennyire ajánlanád a Sorsfonalakat egy barátodnak?” (0–10), utána egy nem kötelező „Mi a legfontosabb oka?”. Fent túlságosan elvonta volna a figyelmet a tartalomról. - **Hogyan:** egyszer, egy bezárható dobozban az oldal legalján, a tartalom (a `main`) után és a lábléc előtt, külön: „Mennyire ajánlanád a Sorsfonalakat egy barátodnak?” (0–10), utána egy nem kötelező „Mi a legfontosabb oka?”. Fent túlságosan elvonta volna a figyelmet a tartalomról.
- **Ha bezárja,** az is számít: nem jön elő újra. - **Ha bezárja,** az is számít: nem jön elő újra.
- **Pontszám:** a 9–10 ajánló, a 7–8 semleges, a 0–6 nem ajánló. Az NPS = (ajánlók − nem ajánlók) / válaszok × 100, −100 és 100 között. - **Pontszám:** a 9–10 ajánló, a 7–8 semleges, a 0–6 nem ajánló. Az NPS = (ajánlók − nem ajánlók) / válaszok × 100, −100 és 100 között.
+5 -3
View File
@@ -8,7 +8,7 @@
//! * messages from the "Visszajelzés" page (bug, idea, question), with a //! * messages from the "Visszajelzés" page (bug, idea, question), with a
//! state and the operator's reply, both shown to the user there; //! 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 //! * 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 //! Admins see it all on Admin → Visszajelzések; the admin menu counts what is
//! new. //! new.
@@ -356,11 +356,13 @@ pub async fn unseen_replies(conn: &mut PgConnection, user: Uuid) -> Result<i64,
// --- the recommendation question (NPS) ----------------------------------------------------------- // --- the recommendation question (NPS) -----------------------------------------------------------
/// Whether to ask the user now: not asked before, and has a couple of /// Whether to ask the user now: not asked before, has a couple of finished
/// finished contents (the free summary does not count). /// 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> { pub async fn nps_due(conn: &mut PgConnection, user: Uuid) -> Result<bool, sqlx::Error> {
sqlx::query_scalar(&format!( sqlx::query_scalar(&format!(
"SELECT NOT EXISTS (SELECT 1 FROM nps_answers WHERE user_id = $1) \ "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 (SELECT count(*) FROM analyses WHERE requested_by = $1 AND status = 'done' \
AND kind IN ('natal', 'synastry', 'forecast', 'tarot')) \ AND kind IN ('natal', 'synastry', 'forecast', 'tarot')) \
+ (SELECT count(*) FROM questions WHERE asked_by = $1 AND status = 'done') >= {NPS_AFTER}" + (SELECT count(*) FROM questions WHERE asked_by = $1 AND status = 'done') >= {NPS_AFTER}"
+6
View File
@@ -3946,6 +3946,12 @@ async fn the_recommendation_question_comes_once_after_two_contents(pool: PgPool)
} }
assert_eq!(app.post("/v1/nps", Some(&bela), json!({"score": null})).await.status, StatusCode::NO_CONTENT); assert_eq!(app.post("/v1/nps", Some(&bela), json!({"score": null})).await.status, StatusCode::NO_CONTENT);
assert_eq!(app.get("/v1/me", Some(&bela)).await.body["nps_due"], false); assert_eq!(app.get("/v1/me", Some(&bela)).await.body["nps_due"], false);
// Not the team: an admin is not asked.
let admin_id = user_id(&app, &admin).await;
for _ in 0..2 {
analysis_row(&app, "tarot", None, admin_id, "done").await;
}
assert_eq!(app.get("/v1/me", Some(&admin)).await.body["nps_due"], false);
let r = app.get("/v1/admin/feedback/summary", Some(&admin)).await; let r = app.get("/v1/admin/feedback/summary", Some(&admin)).await;
let nps = &r.body["nps"]; let nps = &r.body["nps"];
assert_eq!( assert_eq!(