mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
lint fixes
This commit is contained in:
@@ -29,7 +29,7 @@ router.put(
|
||||
if (validationErrors.length > 0) {
|
||||
return res.status(403).send(validationErrors)
|
||||
}
|
||||
const result = await writeLocality(editedLocality, comment, references, req.user!)
|
||||
const result = await writeLocality(editedLocality, comment, references, req.user)
|
||||
return res.status(200).send({ id: result })
|
||||
}
|
||||
)
|
||||
|
||||
@@ -177,7 +177,10 @@ export const validateEntireLocality = (editedFields: EditDataType<Prisma.now_loc
|
||||
return errors
|
||||
}
|
||||
|
||||
export const filterDuplicateLocalitySpecies = async (locality: EditDataType<LocalityDetailsType>, user: User | undefined) => {
|
||||
export const filterDuplicateLocalitySpecies = async (
|
||||
locality: EditDataType<LocalityDetailsType>,
|
||||
user: User | undefined
|
||||
) => {
|
||||
if (!locality.lid) return
|
||||
|
||||
// Get existing data of locality
|
||||
@@ -190,17 +193,18 @@ export const filterDuplicateLocalitySpecies = async (locality: EditDataType<Loca
|
||||
localityDetailsSpeciesIds.push(localitySpecies.species_id)
|
||||
}
|
||||
|
||||
|
||||
// Compare if the species already exists and that we are trying to add it again
|
||||
// and filter those cases out
|
||||
const updatedLocalityNow_ls = locality.now_ls.filter(localitySpecies => {
|
||||
if (localitySpecies.species_id) {
|
||||
// Logic is flipped for filter as we want to skip the ones the check matches
|
||||
return !(localityDetailsSpeciesIds.includes(localitySpecies.species_id) && localitySpecies.rowState === "new")
|
||||
return !(localityDetailsSpeciesIds.includes(localitySpecies.species_id) && localitySpecies.rowState === 'new')
|
||||
}
|
||||
|
||||
// code shouldn't get here ever
|
||||
logger.info(`Filter already existing species: localitySpecies didn't have species_id. Skipping. ${localitySpecies}`)
|
||||
logger.info(
|
||||
`Filter already existing species: localitySpecies didn't have species_id. Skipping. ${JSON.stringify(localitySpecies)}`
|
||||
)
|
||||
return false
|
||||
})
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ export const writeLocality = async (
|
||||
references: Reference[] | undefined,
|
||||
user: User | undefined
|
||||
) => {
|
||||
|
||||
const updateOrAdd = locality.lid ? 'update' : 'add'
|
||||
const writeHandler = getLocalityWriteHandler(updateOrAdd)
|
||||
|
||||
@@ -49,11 +48,11 @@ export const writeLocality = async (
|
||||
await writeHandler.start()
|
||||
|
||||
const filteredLocality = await filterDuplicateLocalitySpecies(locality, user)
|
||||
if (updateOrAdd === "update" && filteredLocality) {
|
||||
if (updateOrAdd === 'update' && filteredLocality) {
|
||||
locality.now_ls = filteredLocality
|
||||
}
|
||||
|
||||
if (updateOrAdd === "add") {
|
||||
if (updateOrAdd === 'add') {
|
||||
const { lid: newLid } = await writeHandler.createObject('now_loc', locality, ['lid'])
|
||||
locality.lid = newLid as number
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user