feat: lives-with field
Some checks failed
/ integration-test--firefox (push) Failing after 3m8s

This commit is contained in:
Robert Perce 2026-01-24 11:13:27 -06:00
parent a0afb6dfd3
commit fd5f1899c1
4 changed files with 53 additions and 17 deletions

View file

@ -74,12 +74,12 @@ mod get {
) -> Result<Markup, AppError> {
let pool = &state.db(&auth_session.user.unwrap()).pool;
let contact: HydratedContact = sqlx::query_as(
"select id, birthday, manually_freshened_at, (
select string_agg(name,'\x1c' order by sort)
from names where contact_id = c.id
) as names
from contacts c
where c.id = $1",
"select *, (
select string_agg(name,'\x1c' order by sort)
from names where contact_id = c.id
) as names
from contacts c
where c.id = $1",
)
.bind(contact_id)
.fetch_one(pool)
@ -156,6 +156,12 @@ mod get {
"(never)"
}
}
@if contact.lives_with.len() > 0 {
label { "lives with" }
div { (contact.lives_with) }
}
@if addresses.len() == 1 {
label { "address" }
#addresses {
@ -207,16 +213,21 @@ mod get {
) -> Result<Markup, AppError> {
let pool = &state.db(&auth_session.user.unwrap()).pool;
let contact: HydratedContact = sqlx::query_as(
"select id, birthday, manually_freshened_at, (
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 journal_mentions cms on cms.entry_id = jes.id
where cms.url = '/contact/'||c.id
order by jes.date desc limit 1
) as last_mention_date from contacts c
where c.id = $1",
"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 journal_mentions cms on cms.entry_id = jes.id
where cms.url = '/contact/'||c.id
or cms.url in (
select '/group/'||name
from groups
where contact_id = c.id
)
order by jes.date desc limit 1
) as last_mention_date from contacts c
where c.id = $1",
)
.bind(contact_id)
.fetch_one(pool)
@ -289,6 +300,10 @@ mod get {
span x-text="date.length ? date.split('T')[0] : '(never)'" {}
input type="button" value="Mark fresh now" x-on:click="date = new Date().toISOString()";
}
label { "lives with" }
div {
input name="lives_with" value=(contact.lives_with);
}
label { "addresses" }
div x-data=(json!({ "addresses": addresses, "new_label": "", "new_address": "" })) {
template x-for="(address, index) in addresses" x-bind:key="index" {
@ -361,6 +376,7 @@ mod put {
name: Option<Vec<String>>,
birthday: String,
manually_freshened_at: String,
lives_with: String,
address_label: Option<Vec<String>>,
address_value: Option<Vec<String>>,
group: Option<Vec<String>>,
@ -400,9 +416,10 @@ mod put {
};
sqlx::query!(
"update contacts set (birthday, manually_freshened_at, text_body) = ($1, $2, $3) where id = $4",
"update contacts set (birthday, manually_freshened_at, lives_with, text_body) = ($1, $2, $3, $4) where id = $5",
birthday,
manually_freshened_at,
payload.lives_with,
text_body,
contact_id
)