From 7aa8205115b16aaf7c7ca60f23b3f31583e4f94d Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Sat, 28 Oct 2017 21:10:09 +0300 Subject: [PATCH] DB support tracking welcome email sends --- .../migrations/20171028204514-welcome-email.down.sql | 0 .../migrations/20171028204514-welcome-email.up.sql | 1 + resources/sql/queries.sql | 10 ++++++++++ src/clj/commiteth/db/users.clj | 5 +++++ 4 files changed, 16 insertions(+) create mode 100644 resources/migrations/20171028204514-welcome-email.down.sql create mode 100644 resources/migrations/20171028204514-welcome-email.up.sql diff --git a/resources/migrations/20171028204514-welcome-email.down.sql b/resources/migrations/20171028204514-welcome-email.down.sql new file mode 100644 index 0000000..e69de29 diff --git a/resources/migrations/20171028204514-welcome-email.up.sql b/resources/migrations/20171028204514-welcome-email.up.sql new file mode 100644 index 0000000..39bbeb9 --- /dev/null +++ b/resources/migrations/20171028204514-welcome-email.up.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."users" ADD COLUMN "welcome_email_sent" int DEFAULT '0'; diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 59aba69..106e288 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -552,6 +552,16 @@ FROM activity_feed_view ORDER BY updated DESC LIMIT 100; +-- :name get-new-users-for-welcome-email :? :* +-- :doc users who have not been sent a welcome email +SELECT + id, + login, + email, + name +FROM users +WHERE welcome_email_sent = 0; + -- :name usage-metrics-by-day :? :* -- :doc data for usage metrics chart diff --git a/src/clj/commiteth/db/users.clj b/src/clj/commiteth/db/users.clj index 2e6f091..488a5db 100644 --- a/src/clj/commiteth/db/users.clj +++ b/src/clj/commiteth/db/users.clj @@ -37,3 +37,8 @@ [repo-id] (jdbc/with-db-connection [con-db *db*] (db/get-repo-owner {:repo_id repo-id}))) + +(defn get-new-users-for-welcome-email + [] + (jdbc/with-db-connection [con-db *db*] + (db/get-new-users-for-welcome-email)))