Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add "added_to_mailing_list" column on signups table

Joseph Lyons4436ec48ebab
diff --git a/crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql b/crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql
new file mode 100644
index 00000000000..b154396df12
--- /dev/null
+++ b/crates/collab/migrations/20221125192125_add_added_to_mailing_list_to_signups.sql
@@ -0,0 +1,2 @@
+ALTER TABLE "signups"
+ ADD "added_to_mailing_list" BOOLEAN NOT NULL DEFAULT FALSE;
\ No newline at end of file
diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs
index 1609764f6e0..85ace9a5f2f 100644
--- a/crates/collab/src/db.rs
+++ b/crates/collab/src/db.rs
@@ -390,10 +390,11 @@ impl Db<sqlx::Postgres> {
platform_unknown,
editor_features,
programming_languages,
- device_id
+ device_id,
+ added_to_mailing_list
)
VALUES
- ($1, $2, FALSE, $3, $4, $5, FALSE, $6, $7, $8)
+ ($1, $2, FALSE, $3, $4, $5, FALSE, $6, $7, $8, $9)
ON CONFLICT (email_address) DO UPDATE SET
email_address = excluded.email_address
RETURNING id
@@ -407,6 +408,7 @@ impl Db<sqlx::Postgres> {
.bind(&signup.editor_features)
.bind(&signup.programming_languages)
.bind(&signup.device_id)
+ .bind(&signup.added_to_mailing_list)
.execute(&self.pool)
.await?;
Ok(())
@@ -1270,6 +1272,7 @@ pub struct Signup {
pub editor_features: Vec<String>,
pub programming_languages: Vec<String>,
pub device_id: Option<String>,
+ pub added_to_mailing_list: bool,
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, FromRow)]
diff --git a/crates/collab/src/db_tests.rs b/crates/collab/src/db_tests.rs
index b3f964b8a7b..6260eadc4a8 100644
--- a/crates/collab/src/db_tests.rs
+++ b/crates/collab/src/db_tests.rs
@@ -657,6 +657,7 @@ async fn test_signups() {
editor_features: vec!["speed".into()],
programming_languages: vec!["rust".into(), "c".into()],
device_id: Some(format!("device_id_{i}")),
+ added_to_mailing_list: i != 0, // One user failed to subscribe
})
.collect::<Vec<Signup>>();