mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
some changes. more debugging to do. maybe some understanding
This commit is contained in:
@@ -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))
|
||||
})
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Vendored
+1
-1
@@ -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>
|
||||
// )
|
||||
// }
|
||||
],
|
||||
[]
|
||||
)
|
||||
|
||||
@@ -39,7 +39,4 @@ const crossSearchApi = api.injectEndpoints({
|
||||
}),
|
||||
})
|
||||
|
||||
export const {
|
||||
useGetAllCrossSearchQuery,
|
||||
useGetCrossSearchListMutation,
|
||||
} = crossSearchApi
|
||||
export const { useGetAllCrossSearchQuery, useGetCrossSearchListMutation } = crossSearchApi
|
||||
|
||||
Reference in New Issue
Block a user