some changes. more debugging to do. maybe some understanding

This commit is contained in:
Eero Antikainen
2024-09-11 12:56:53 +03:00
parent 62cf12af6b
commit b3f0a0e386
5 changed files with 38 additions and 39 deletions
+1 -4
View File
@@ -1,5 +1,5 @@
import { Request, Router } from 'express'
import { getAllLocalities, getLocalityDetails, validateEntireLocality } from '../services/locality'
import { getLocalityDetails, validateEntireLocality } from '../services/locality'
import { getAllCrossSearch } from '../services/crossSearch'
import { fixBigInt } from '../utils/common'
import { EditDataType, EditMetaData, LocalityDetailsType } from '../../../frontend/src/backendTypes'
@@ -10,10 +10,7 @@ import { deleteLocality, writeLocality } from '../services/write/locality'
const router = Router()
router.get('/all', async (req, res) => {
const localities = await getAllLocalities(req.user)
const crossSearch = await getAllCrossSearch(req.user)
console.log(crossSearch[2])
console.log(crossSearch[2]?.now_ls[0].com_species)
return res.status(200).send(fixBigInt(crossSearch))
})
+21 -16
View File
@@ -20,35 +20,40 @@ type CrossSearchListType = {
min_age: number
country: string | null
loc_status: boolean | null
species_id: number
now_plr: {
pid: number
now_ls:{
species_id: number
subclass_or_superorder_name: string
order_name: string
suborder_or_superfamily_name: string
family_name: string
subfamily_name: string
genus_name: string
species_name: string
unique_identifier: string
taxonomic_status: string
sp_status: string
}
}[]
now_ls: {
com_species: {
species_id: number
subclass_or_superorder_name: string | null
order_name: string
suborder_or_superfamily_name: string | null
family_name: string
subfamily_name: string | null
genus_name: string
species_name: string
unique_identifier: string
taxonomic_status: string
sp_status: boolean | null
}
}[]
}
export const getAllCrossSearch = async (user?: User) => {
const showAll = user && [Role.Admin, Role.EditUnrestricted].includes(user.role)
const removeProjects: (loc: CrossSearchListType) => Omit<CrossSearchListType, 'now_plr'> = loc => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { now_plr, ...rest } = loc
console.log(typeof loc)
// console.log(loc)
return rest
}
const result = await nowDb.now_loc.findMany({
// take: 5,
take: 5,
select: {
lid: true,
//columns from now_loc
@@ -65,7 +70,7 @@ export const getAllCrossSearch = async (user?: User) => {
now_ls: {
select: {
com_species: {
select: {
select: {
//columns from com_species
species_id: true,
subclass_or_superorder_name: true,
+1 -1
View File
@@ -90,7 +90,7 @@ export type CrossSearch = {
min_age: number
country: string | null
loc_status: boolean | null
subRows?: now_ls[];
now_ls: Array<Species>
}
export type Sequence = Prisma.now_tu_sequence
@@ -35,20 +35,20 @@ export const CrossSearchTable = ({ selectorFn }: { selectorFn?: (newObject: Cros
header: 'Min age',
filterVariant: 'range',
},
// {
// accessorKey: 'now_ls',
// header: 'Species IDs',
// enableSorting: false,
// Cell: ({ cell }) => (
// <div>
// {cell.getValue().map((speciesObj: any, index: number) => (
// <div key={index}>
// {speciesObj.com_species.species_id}
// </div>
// ))}
// </div>
// )
// }
// {
// accessorKey: 'now_ls',
// header: 'Species IDs',
// enableSorting: false,
// Cell: ({ cell }) => (
// <div>
// {cell.getValue().map((speciesObj: any, index: number) => (
// <div key={index}>
// {speciesObj.com_species.species_id}
// </div>
// ))}
// </div>
// )
// }
],
[]
)
+1 -4
View File
@@ -39,7 +39,4 @@ const crossSearchApi = api.injectEndpoints({
}),
})
export const {
useGetAllCrossSearchQuery,
useGetCrossSearchListMutation,
} = crossSearchApi
export const { useGetAllCrossSearchQuery, useGetCrossSearchListMutation } = crossSearchApi