Add "interest" booleans to signups form

Nate and Max Brunsfeld created

Co-Authored-By: Max Brunsfeld
<max@zed.dev>

Change summary

server/migrations/20210920192001_add_interests_to_signups.sql |  4 
server/src/db.rs                                              | 22 ++++
server/src/home.rs                                            | 17 +++
3 files changed, 38 insertions(+), 5 deletions(-)

Detailed changes

server/src/db.rs 🔗

@@ -47,17 +47,30 @@ impl Db {
         github_login: &str,
         email_address: &str,
         about: &str,
+        wants_releases: bool,
+        wants_updates: bool,
+        wants_community: bool,
     ) -> Result<SignupId> {
         test_support!(self, {
             let query = "
-                INSERT INTO signups (github_login, email_address, about)
-                VALUES ($1, $2, $3)
+                INSERT INTO signups (
+                    github_login,
+                    email_address,
+                    about,
+                    wants_releases,
+                    wants_updates,
+                    wants_community
+                )
+                VALUES ($1, $2, $3, $4, $5, $6)
                 RETURNING id
             ";
             sqlx::query_scalar(query)
                 .bind(github_login)
                 .bind(email_address)
                 .bind(about)
+                .bind(wants_releases)
+                .bind(wants_updates)
+                .bind(wants_community)
                 .fetch_one(&self.pool)
                 .await
                 .map(SignupId)
@@ -501,6 +514,9 @@ pub struct Signup {
     pub github_login: String,
     pub email_address: String,
     pub about: String,
+    pub wants_releases: Option<bool>,
+    pub wants_updates: Option<bool>,
+    pub wants_community: Option<bool>,
 }
 
 id_type!(ChannelId);
@@ -731,4 +747,4 @@ pub mod tests {
         assert_eq!(msg1_id, msg3_id);
         assert_eq!(msg2_id, msg4_id);
     }
-}
+}

server/src/home.rs 🔗

@@ -61,6 +61,12 @@ async fn post_signup(mut request: Request) -> tide::Result {
         github_login: String,
         email_address: String,
         about: String,
+        #[serde(default)]
+        wants_releases: bool,
+        #[serde(default)]
+        wants_updates: bool,
+        #[serde(default)]
+        wants_community: bool,
     }
 
     let mut form: Form = request.body_form().await?;
@@ -75,7 +81,14 @@ async fn post_signup(mut request: Request) -> tide::Result {
     // Save signup in the database
     request
         .db()
-        .create_signup(&form.github_login, &form.email_address, &form.about)
+        .create_signup(
+            &form.github_login,
+            &form.email_address,
+            &form.about,
+            form.wants_releases,
+            form.wants_updates,
+            form.wants_community,
+        )
         .await?;
 
     let layout_data = request.layout_data().await?;
@@ -101,4 +114,4 @@ async fn get_release_asset(request: Request) -> tide::Result {
         .content_type(mime::BYTE_STREAM)
         .body(body)
         .build())
-}
+}