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
|
|
@ -9,7 +9,6 @@ use super::Layout;
|
|||
use crate::db::DbId;
|
||||
use crate::models::user::AuthSession;
|
||||
use crate::models::{Birthday, HydratedContact, JournalEntry};
|
||||
use crate::switchboard::{MentionHost, MentionHostType};
|
||||
use crate::{AppError, AppState};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -129,22 +128,7 @@ pub mod get {
|
|||
let user = auth_session.user.unwrap();
|
||||
let pool = &state.db(&user).pool;
|
||||
|
||||
let contacts: Vec<HydratedContact> = sqlx::query_as(
|
||||
"select *, (
|
||||
select string_agg(name,'\x1c' order by sort)
|
||||
from names where contact_id = c.id
|
||||
) as names, (
|
||||
select jes.date from journal_entries jes
|
||||
join mentions ms on ms.entity_id = jes.id
|
||||
where ms.entity_type = $1
|
||||
and ms.url = '/contact/'||c.id
|
||||
order by jes.date desc limit 1
|
||||
) as last_mention_date from contacts c",
|
||||
)
|
||||
.bind(MentionHostType::JournalEntry as DbId)
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
|
||||
let contacts = HydratedContact::all(&pool).await?;
|
||||
let mut freshens: Vec<ContactFreshness> = contacts
|
||||
.clone()
|
||||
.into_iter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue