refactor: fewer non-macro queries
Some checks failed
/ integration-test--firefox (push) Failing after 3m5s
Some checks failed
/ integration-test--firefox (push) Failing after 3m5s
This commit is contained in:
parent
69e23fd9bb
commit
84c41dda4d
5 changed files with 119 additions and 111 deletions
|
|
@ -3,10 +3,10 @@ use axum::extract::FromRequestParts;
|
|||
use cache_bust::asset;
|
||||
use http::request::Parts;
|
||||
use maud::{DOCTYPE, Markup, html};
|
||||
use sqlx::FromRow;
|
||||
|
||||
use super::models::user::{AuthSession, User};
|
||||
use super::{AppError, AppState};
|
||||
use crate::db::DbId;
|
||||
|
||||
pub mod auth;
|
||||
pub mod contact;
|
||||
|
|
@ -16,10 +16,10 @@ pub mod ics;
|
|||
pub mod journal;
|
||||
pub mod settings;
|
||||
|
||||
#[derive(Debug, FromRow)]
|
||||
#[derive(Debug)]
|
||||
struct ContactLink {
|
||||
name: String,
|
||||
contact_id: u32,
|
||||
contact_id: DbId,
|
||||
}
|
||||
pub struct Layout {
|
||||
contact_links: Vec<ContactLink>,
|
||||
|
|
@ -39,7 +39,8 @@ impl FromRequestParts<AppState> for Layout {
|
|||
.map_err(|_| anyhow::Error::msg("could not get session"))?;
|
||||
let user = auth_session.user.unwrap();
|
||||
|
||||
let contact_links: Vec<ContactLink> = sqlx::query_as(
|
||||
let contact_links = sqlx::query_as!(
|
||||
ContactLink,
|
||||
"select c.id as contact_id,
|
||||
coalesce(n.name, '(unnamed)') as name
|
||||
from contacts c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue