mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Tolerate invalid occurrence reference dates
This commit is contained in:
@@ -119,6 +119,44 @@ type OccurrenceUpdate = {
|
||||
updates: OccurrenceLogRow[]
|
||||
}
|
||||
|
||||
const referenceWithoutExactDateSelect = {
|
||||
rid: true,
|
||||
ref_type_id: true,
|
||||
journal_id: true,
|
||||
title_primary: true,
|
||||
date_primary: true,
|
||||
volume: true,
|
||||
issue: true,
|
||||
start_page: true,
|
||||
end_page: true,
|
||||
publisher: true,
|
||||
pub_place: true,
|
||||
title_secondary: true,
|
||||
date_secondary: true,
|
||||
title_series: true,
|
||||
issn_isbn: true,
|
||||
ref_abstract: true,
|
||||
web_url: true,
|
||||
misc_1: true,
|
||||
misc_2: true,
|
||||
gen_notes: true,
|
||||
printed_language: true,
|
||||
used_morph: true,
|
||||
used_now: true,
|
||||
used_gene: true,
|
||||
ref_authors: true,
|
||||
ref_journal: true,
|
||||
} as const
|
||||
|
||||
const addNullExactDateToReferences = <T extends { ref_ref: object }>(references: T[]) =>
|
||||
references.map(reference => ({
|
||||
...reference,
|
||||
ref_ref: {
|
||||
...reference.ref_ref,
|
||||
exact_date: null,
|
||||
},
|
||||
}))
|
||||
|
||||
const stringifyLogValue = (value: unknown) => {
|
||||
if (value === null || value === undefined) return ''
|
||||
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return String(value)
|
||||
@@ -193,7 +231,7 @@ const getOccurrenceUpdates = async (lid: number, speciesId: number) => {
|
||||
now_lr: {
|
||||
include: {
|
||||
ref_ref: {
|
||||
include: { ref_authors: true, ref_journal: true },
|
||||
select: referenceWithoutExactDateSelect,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -207,7 +245,7 @@ const getOccurrenceUpdates = async (lid: number, speciesId: number) => {
|
||||
now_sr: {
|
||||
include: {
|
||||
ref_ref: {
|
||||
include: { ref_authors: true, ref_journal: true },
|
||||
select: referenceWithoutExactDateSelect,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -233,7 +271,7 @@ const getOccurrenceUpdates = async (lid: number, speciesId: number) => {
|
||||
update.lau_coordinator
|
||||
),
|
||||
occ_comment: update.lau_comment ?? '',
|
||||
references: update.now_lr as unknown as AnyReference[],
|
||||
references: addNullExactDateToReferences(update.now_lr) as unknown as AnyReference[],
|
||||
updates: nowLsLogs.filter(logRow => logRow.luid === update.luid),
|
||||
})),
|
||||
...speciesUpdates.map(update => ({
|
||||
@@ -247,7 +285,7 @@ const getOccurrenceUpdates = async (lid: number, speciesId: number) => {
|
||||
update.sau_coordinator
|
||||
),
|
||||
occ_comment: update.sau_comment ?? '',
|
||||
references: update.now_sr as unknown as AnyReference[],
|
||||
references: addNullExactDateToReferences(update.now_sr) as unknown as AnyReference[],
|
||||
updates: nowLsLogs.filter(logRow => logRow.suid === update.suid),
|
||||
})),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user