|
|
|
@@ -23,6 +23,10 @@ const birdSelectFields = `
|
|
|
|
|
birds.motivators,
|
|
|
|
|
birds.demotivators,
|
|
|
|
|
birds.favorite_snack,
|
|
|
|
|
birds.vet_clinic_name,
|
|
|
|
|
birds.vet_clinic_address,
|
|
|
|
|
birds.vet_account_number,
|
|
|
|
|
birds.vet_doctor_name,
|
|
|
|
|
birds.gender,
|
|
|
|
|
birds.date_of_birth::text,
|
|
|
|
|
birds.gotcha_day::text,
|
|
|
|
@@ -287,6 +291,10 @@ export const createBird = async ({
|
|
|
|
|
motivators,
|
|
|
|
|
demotivators,
|
|
|
|
|
favoriteSnack,
|
|
|
|
|
vetClinicName = null,
|
|
|
|
|
vetClinicAddress = null,
|
|
|
|
|
vetAccountNumber = null,
|
|
|
|
|
vetDoctorName = null,
|
|
|
|
|
gender,
|
|
|
|
|
dateOfBirth,
|
|
|
|
|
gotchaDay,
|
|
|
|
@@ -308,6 +316,10 @@ export const createBird = async ({
|
|
|
|
|
motivators: string | null;
|
|
|
|
|
demotivators: string | null;
|
|
|
|
|
favoriteSnack: string | null;
|
|
|
|
|
vetClinicName?: string | null;
|
|
|
|
|
vetClinicAddress?: string | null;
|
|
|
|
|
vetAccountNumber?: string | null;
|
|
|
|
|
vetDoctorName?: string | null;
|
|
|
|
|
gender: BirdGender;
|
|
|
|
|
dateOfBirth: string | null;
|
|
|
|
|
gotchaDay: string | null;
|
|
|
|
@@ -322,9 +334,9 @@ export const createBird = async ({
|
|
|
|
|
publicProfileEnabled?: boolean;
|
|
|
|
|
}) => {
|
|
|
|
|
const result = await db.query<BirdRow>(
|
|
|
|
|
`INSERT INTO birds (id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, gender, date_of_birth, gotcha_day, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled)
|
|
|
|
|
VALUES (COALESCE($1::uuid, gen_random_uuid()), $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at, NULL::text AS latest_weight_grams, NULL::text AS latest_recorded_on`,
|
|
|
|
|
`INSERT INTO birds (id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, vet_clinic_name, vet_clinic_address, vet_account_number, vet_doctor_name, gender, date_of_birth, gotcha_day, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled)
|
|
|
|
|
VALUES (COALESCE($1::uuid, gen_random_uuid()), $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24)
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, vet_clinic_name, vet_clinic_address, vet_account_number, vet_doctor_name, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at, NULL::text AS latest_weight_grams, NULL::text AS latest_recorded_on`,
|
|
|
|
|
[
|
|
|
|
|
birdId ?? null,
|
|
|
|
|
workspaceId,
|
|
|
|
@@ -334,6 +346,10 @@ export const createBird = async ({
|
|
|
|
|
motivators,
|
|
|
|
|
demotivators,
|
|
|
|
|
favoriteSnack,
|
|
|
|
|
vetClinicName,
|
|
|
|
|
vetClinicAddress,
|
|
|
|
|
vetAccountNumber,
|
|
|
|
|
vetDoctorName,
|
|
|
|
|
gender,
|
|
|
|
|
dateOfBirth,
|
|
|
|
|
gotchaDay,
|
|
|
|
@@ -361,6 +377,10 @@ export const updateBird = async ({
|
|
|
|
|
motivators,
|
|
|
|
|
demotivators,
|
|
|
|
|
favoriteSnack,
|
|
|
|
|
vetClinicName,
|
|
|
|
|
vetClinicAddress,
|
|
|
|
|
vetAccountNumber,
|
|
|
|
|
vetDoctorName,
|
|
|
|
|
gender,
|
|
|
|
|
dateOfBirth,
|
|
|
|
|
gotchaDay,
|
|
|
|
@@ -382,6 +402,10 @@ export const updateBird = async ({
|
|
|
|
|
motivators: string | null;
|
|
|
|
|
demotivators: string | null;
|
|
|
|
|
favoriteSnack: string | null;
|
|
|
|
|
vetClinicName: string | null;
|
|
|
|
|
vetClinicAddress: string | null;
|
|
|
|
|
vetAccountNumber: string | null;
|
|
|
|
|
vetDoctorName: string | null;
|
|
|
|
|
gender: BirdGender;
|
|
|
|
|
dateOfBirth: string | null;
|
|
|
|
|
gotchaDay: string | null;
|
|
|
|
@@ -403,22 +427,26 @@ export const updateBird = async ({
|
|
|
|
|
motivators = $5,
|
|
|
|
|
demotivators = $6,
|
|
|
|
|
favorite_snack = $7,
|
|
|
|
|
gender = $8,
|
|
|
|
|
date_of_birth = $9,
|
|
|
|
|
gotcha_day = $10,
|
|
|
|
|
chart_color = $11,
|
|
|
|
|
photo_data_url = $12,
|
|
|
|
|
photo_object_key = $13,
|
|
|
|
|
photo_content_type = $14,
|
|
|
|
|
photo_updated_at = $15,
|
|
|
|
|
notify_on_dob = $16,
|
|
|
|
|
notify_on_gotcha_day = $17,
|
|
|
|
|
public_profile_code = $18,
|
|
|
|
|
public_profile_enabled = $19
|
|
|
|
|
vet_clinic_name = $8,
|
|
|
|
|
vet_clinic_address = $9,
|
|
|
|
|
vet_account_number = $10,
|
|
|
|
|
vet_doctor_name = $11,
|
|
|
|
|
gender = $12,
|
|
|
|
|
date_of_birth = $13,
|
|
|
|
|
gotcha_day = $14,
|
|
|
|
|
chart_color = $15,
|
|
|
|
|
photo_data_url = $16,
|
|
|
|
|
photo_object_key = $17,
|
|
|
|
|
photo_content_type = $18,
|
|
|
|
|
photo_updated_at = $19,
|
|
|
|
|
notify_on_dob = $20,
|
|
|
|
|
notify_on_gotcha_day = $21,
|
|
|
|
|
public_profile_code = $22,
|
|
|
|
|
public_profile_enabled = $23
|
|
|
|
|
WHERE id = $1
|
|
|
|
|
AND workspace_id = $20
|
|
|
|
|
AND workspace_id = $24
|
|
|
|
|
AND memorialized_at IS NULL
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, vet_clinic_name, vet_clinic_address, vet_account_number, vet_doctor_name, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
(
|
|
|
|
|
SELECT weight_grams::text
|
|
|
|
|
FROM weight_records
|
|
|
|
@@ -441,6 +469,10 @@ export const updateBird = async ({
|
|
|
|
|
motivators,
|
|
|
|
|
demotivators,
|
|
|
|
|
favoriteSnack,
|
|
|
|
|
vetClinicName,
|
|
|
|
|
vetClinicAddress,
|
|
|
|
|
vetAccountNumber,
|
|
|
|
|
vetDoctorName,
|
|
|
|
|
gender,
|
|
|
|
|
dateOfBirth,
|
|
|
|
|
gotchaDay,
|
|
|
|
@@ -482,7 +514,7 @@ export const memorializeBird = async ({
|
|
|
|
|
WHERE id = $1
|
|
|
|
|
AND workspace_id = $2
|
|
|
|
|
AND memorialized_at IS NULL
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, vet_clinic_name, vet_clinic_address, vet_account_number, vet_doctor_name, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
(
|
|
|
|
|
SELECT weight_grams::text
|
|
|
|
|
FROM weight_records
|
|
|
|
@@ -518,7 +550,7 @@ export const updateMemorialReminderPreference = async ({
|
|
|
|
|
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, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, vet_clinic_name, vet_clinic_address, vet_account_number, vet_doctor_name, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
(
|
|
|
|
|
SELECT weight_grams::text
|
|
|
|
|
FROM weight_records
|
|
|
|
@@ -558,7 +590,7 @@ export const transferBirdToWorkspace = async (birdId: string, sourceWorkspaceId:
|
|
|
|
|
WHERE id = $1
|
|
|
|
|
AND workspace_id = $2
|
|
|
|
|
AND memorialized_at IS NULL
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
RETURNING id, workspace_id, name, tag_id, species, motivators, demotivators, favorite_snack, vet_clinic_name, vet_clinic_address, vet_account_number, vet_doctor_name, gender, date_of_birth::text, gotcha_day::text, chart_color, photo_data_url, photo_object_key, photo_content_type, photo_updated_at, notify_on_dob, notify_on_gotcha_day, public_profile_code, public_profile_enabled, memorialized_at, memorialized_on::text, memorial_note, notify_on_memorial_day, created_at,
|
|
|
|
|
(
|
|
|
|
|
SELECT weight_grams::text
|
|
|
|
|
FROM weight_records
|
|
|
|
|