cleaned up stripe config
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user