cleaned up stripe config

This commit is contained in:
Corey Blais
2026-04-30 21:54:13 -04:00
parent 646f895ed6
commit cd7c4383d0
9 changed files with 384 additions and 73 deletions
+42 -3
View File
@@ -113,7 +113,10 @@ export const findBirdsByBandId = async (tagId: string) => {
ORDER BY recorded_on DESC
LIMIT 1
) latest ON TRUE
WHERE LOWER(birds.tag_id) = LOWER($1)
WHERE birds.tag_id IS NOT NULL
AND BTRIM(birds.tag_id) <> ''
AND LOWER(BTRIM(birds.tag_id)) NOT IN ('unknown', 'not recorded', 'n/a', 'na', 'none')
AND LOWER(birds.tag_id) = LOWER($1)
AND birds.memorialized_at IS NULL
ORDER BY birds.created_at ASC
LIMIT 10`,
@@ -261,7 +264,7 @@ export const createBird = async ({
}: {
workspaceId: number;
name: string;
tagId: string;
tagId: string | null;
species: string;
gender: BirdGender;
dateOfBirth: string | null;
@@ -298,7 +301,7 @@ export const updateBird = async ({
birdId: string;
workspaceId: number;
name: string;
tagId: string;
tagId: string | null;
species: string;
gender: BirdGender;
dateOfBirth: string | null;
@@ -387,6 +390,42 @@ export const memorializeBird = async ({
return result.rows[0] ?? null;
};
export const updateMemorialReminderPreference = async ({
birdId,
workspaceId,
notifyOnMemorialDay,
}: {
birdId: string;
workspaceId: number;
notifyOnMemorialDay: boolean;
}) => {
const result = await db.query<BirdRow>(
`UPDATE birds
SET notify_on_memorial_day = $3
WHERE id = $1
AND workspace_id = $2
AND memorialized_at IS NOT NULL
RETURNING id, workspace_id, name, tag_id, species, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, notify_on_dob, notify_on_gotcha_day, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
(
SELECT weight_grams::text
FROM weight_records
WHERE bird_id = birds.id
ORDER BY recorded_on DESC
LIMIT 1
) AS latest_weight_grams,
(
SELECT recorded_on::text
FROM weight_records
WHERE bird_id = birds.id
ORDER BY recorded_on DESC
LIMIT 1
) AS latest_recorded_on`,
[birdId, workspaceId, notifyOnMemorialDay],
);
return result.rows[0] ?? null;
};
export const deleteBird = async (birdId: string, workspaceId: number) => {
const result = await db.query<{ id: string }>(
`DELETE FROM birds