From 4db566820ebab02e98b5959db3e65926a0a0d1a4 Mon Sep 17 00:00:00 2001 From: Maija Y Date: Wed, 15 Jan 2025 11:19:34 +0200 Subject: [PATCH] Mailchimp syncer checks if user has completed course --- ...05c905af9b0bbd078bf3b88a6ea28f869d5a106b6456752361f0.json} | 4 ++-- services/headless-lms/models/src/marketing_consents.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) rename services/headless-lms/models/.sqlx/{query-60d52cbbc49c9556b8ef35f960b5739762e6afece10dede977403e33ef5f8516.json => query-9085a18a90d505c905af9b0bbd078bf3b88a6ea28f869d5a106b6456752361f0.json} (95%) diff --git a/services/headless-lms/models/.sqlx/query-60d52cbbc49c9556b8ef35f960b5739762e6afece10dede977403e33ef5f8516.json b/services/headless-lms/models/.sqlx/query-9085a18a90d505c905af9b0bbd078bf3b88a6ea28f869d5a106b6456752361f0.json similarity index 95% rename from services/headless-lms/models/.sqlx/query-60d52cbbc49c9556b8ef35f960b5739762e6afece10dede977403e33ef5f8516.json rename to services/headless-lms/models/.sqlx/query-9085a18a90d505c905af9b0bbd078bf3b88a6ea28f869d5a106b6456752361f0.json index 166d8d0b159..a73f178c5ba 100644 --- a/services/headless-lms/models/.sqlx/query-60d52cbbc49c9556b8ef35f960b5739762e6afece10dede977403e33ef5f8516.json +++ b/services/headless-lms/models/.sqlx/query-9085a18a90d505c905af9b0bbd078bf3b88a6ea28f869d5a106b6456752361f0.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n umc.id,\n umc.course_id,\n umc.course_language_group_id,\n umc.user_id,\n umc.user_mailchimp_id,\n umc.consent,\n umc.email_subscription_in_mailchimp,\n umc.created_at,\n umc.updated_at,\n umc.deleted_at,\n umc.synced_to_mailchimp_at,\n u.first_name AS first_name,\n u.last_name AS last_name,\n u.email AS email,\n c.name AS course_name,\n c.language_code AS locale,\n CASE WHEN cmc.passed IS NOT NULL THEN cmc.completion_date ELSE NULL END AS completed_course_at,\n COALESCE(csfa.research_consent, urc.research_consent) AS research_consent\n FROM user_marketing_consents AS umc\n JOIN user_details AS u ON u.user_id = umc.user_id\n JOIN courses AS c ON c.id = umc.course_id\n LEFT JOIN course_module_completions AS cmc\n ON cmc.user_id = umc.user_id AND cmc.course_id = umc.course_id\n LEFT JOIN course_specific_consent_form_answers AS csfa\n ON csfa.course_id = umc.course_id AND csfa.user_id = umc.user_id\n LEFT JOIN user_research_consents AS urc\n ON urc.user_id = umc.user_id\n WHERE umc.course_language_group_id = $1\n AND (\n umc.synced_to_mailchimp_at IS NULL\n OR umc.synced_to_mailchimp_at < umc.updated_at\n OR csfa.updated_at > umc.synced_to_mailchimp_at\n OR urc.updated_at > umc.synced_to_mailchimp_at\n)\n ", + "query": "\n SELECT\n umc.id,\n umc.course_id,\n umc.course_language_group_id,\n umc.user_id,\n umc.user_mailchimp_id,\n umc.consent,\n umc.email_subscription_in_mailchimp,\n umc.created_at,\n umc.updated_at,\n umc.deleted_at,\n umc.synced_to_mailchimp_at,\n u.first_name AS first_name,\n u.last_name AS last_name,\n u.email AS email,\n c.name AS course_name,\n c.language_code AS locale,\n CASE WHEN cmc.passed IS NOT NULL THEN cmc.completion_date ELSE NULL END AS completed_course_at,\n COALESCE(csfa.research_consent, urc.research_consent) AS research_consent\n FROM user_marketing_consents AS umc\n JOIN user_details AS u ON u.user_id = umc.user_id\n JOIN courses AS c ON c.id = umc.course_id\n LEFT JOIN course_module_completions AS cmc\n ON cmc.user_id = umc.user_id AND cmc.course_id = umc.course_id\n LEFT JOIN course_specific_consent_form_answers AS csfa\n ON csfa.course_id = umc.course_id AND csfa.user_id = umc.user_id\n LEFT JOIN user_research_consents AS urc\n ON urc.user_id = umc.user_id\n WHERE umc.course_language_group_id = $1\n AND (\n umc.synced_to_mailchimp_at IS NULL\n OR umc.synced_to_mailchimp_at < umc.updated_at\n OR csfa.updated_at > umc.synced_to_mailchimp_at\n OR urc.updated_at > umc.synced_to_mailchimp_at\n OR cmc.updated_at > umc.synced_to_mailchimp_at\n)\n ", "describe": { "columns": [ { @@ -118,5 +118,5 @@ null ] }, - "hash": "60d52cbbc49c9556b8ef35f960b5739762e6afece10dede977403e33ef5f8516" + "hash": "9085a18a90d505c905af9b0bbd078bf3b88a6ea28f869d5a106b6456752361f0" } diff --git a/services/headless-lms/models/src/marketing_consents.rs b/services/headless-lms/models/src/marketing_consents.rs index 7a9f1d982ad..89e5264f3d4 100644 --- a/services/headless-lms/models/src/marketing_consents.rs +++ b/services/headless-lms/models/src/marketing_consents.rs @@ -158,6 +158,7 @@ pub async fn fetch_all_unsynced_user_marketing_consents_by_course_language_group OR umc.synced_to_mailchimp_at < umc.updated_at OR csfa.updated_at > umc.synced_to_mailchimp_at OR urc.updated_at > umc.synced_to_mailchimp_at + OR cmc.updated_at > umc.synced_to_mailchimp_at ) ", course_language_group_id