Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Fetch only necessary columns when checking subscription status
Browse files Browse the repository at this point in the history
  • Loading branch information
0rzech committed Mar 20, 2024
1 parent 9342236 commit 5d08d19
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 67 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

2 changes: 0 additions & 2 deletions src/domain/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
mod new_subscriber;
mod subscriber_email;
mod subscriber_name;
mod subscription;
mod subscription_status;
mod subscription_token;

pub use new_subscriber::NewSubscriber;
pub use subscriber_email::SubscriberEmail;
pub use subscriber_name::SubscriberName;
pub use subscription::Subscription;
pub use subscription_status::SubscriptionStatus;
pub use subscription_token::{token_regex, SubscriptionToken};
16 changes: 0 additions & 16 deletions src/domain/subscription.rs

This file was deleted.

13 changes: 10 additions & 3 deletions src/routes/subscriptions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{
app_state::AppState,
domain::{
NewSubscriber, SubscriberEmail, SubscriberName, Subscription, SubscriptionStatus,
SubscriptionToken,
NewSubscriber, SubscriberEmail, SubscriberName, SubscriptionStatus, SubscriptionToken,
},
email_client::EmailClient,
};
Expand Down Expand Up @@ -86,7 +85,8 @@ async fn get_subscription(
) -> Result<Option<Subscription>, anyhow::Error> {
let query = sqlx::query!(
r#"
SELECT * FROM subscriptions
SELECT id, status
FROM subscriptions
WHERE email = $1
"#,
email.as_ref()
Expand Down Expand Up @@ -210,6 +210,13 @@ impl TryFrom<FormData> for NewSubscriber {
}
}

#[derive(FromRow)]
struct Subscription {
id: Uuid,
#[sqlx(try_from = "String")]
status: SubscriptionStatus,
}

#[derive(Template)]
#[template(path = "welcome.html")]
struct HtmlBodyTemplate<'a> {
Expand Down

0 comments on commit 5d08d19

Please sign in to comment.