Skip to content

Commit

Permalink
SIMSBIOHUB-591: Show all user's data on Project page & add search fun…
Browse files Browse the repository at this point in the history
…ctionality (#1296)

- Added new summary page and components.
- Added/update project/survey/observations/animals/telemetry GET all endpoints, which support filter parameters and pagination.
  • Loading branch information
mauberti-bc authored Jul 5, 2024
1 parent 9113f6a commit 5e245cf
Show file tree
Hide file tree
Showing 154 changed files with 7,826 additions and 2,231 deletions.
4 changes: 4 additions & 0 deletions api/src/__mocks__/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export class MockReq {
params = {};
body = {};
files: any[] = [];
// Exists on authenticated requests. @see authentication.ts and authorization.ts
keycloak_token?: Record<string, any>;
// Exists on authenticated requests. @see authentication.ts and authorization.ts
system_user?: Record<string, any>;
}

export type ExtendedMockRes = MockRes & Response;
Expand Down
6 changes: 6 additions & 0 deletions api/src/models/animal-view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface IAnimalAdvancedFilters {
keyword?: string;
itis_tsns?: number[];
itis_tsn?: number;
system_user_id?: number;
}
2 changes: 1 addition & 1 deletion api/src/models/biohub-create.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { FeatureCollection } from 'geojson';
import { describe } from 'mocha';
import { ObservationRecord } from '../repositories/observation-repository';
import { ObservationRecord } from '../repositories/observation-repository/observation-repository';
import {
PostSurveyObservationToBiohubObject,
PostSurveySubmissionToBioHubObject,
Expand Down
2 changes: 1 addition & 1 deletion api/src/models/biohub-create.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FeatureCollection } from 'geojson';
import { ATTACHMENT_TYPE } from '../constants/attachments';
import { ISurveyAttachment, ISurveyReportAttachment } from '../repositories/attachment-repository';
import { ObservationRecord } from '../repositories/observation-repository';
import { ObservationRecord } from '../repositories/observation-repository/observation-repository';
import { getLogger } from '../utils/logger';
import { GetSurveyData, GetSurveyPurposeAndMethodologyData } from './survey-view';

Expand Down
11 changes: 11 additions & 0 deletions api/src/models/observation-view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface IObservationAdvancedFilters {
keyword?: string;
itis_tsns?: number[];
itis_tsn?: number;
start_date?: string;
end_date?: string;
start_time?: string;
end_time?: string;
min_count?: number;
system_user_id?: number;
}
14 changes: 10 additions & 4 deletions api/src/models/project-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { SystemUser } from '../repositories/user-repository';

export interface IProjectAdvancedFilters {
keyword?: string;
project_name?: string;
itis_tsn?: number;
itis_tsns?: number[];
system_user_id?: number;
project_name?: string;
}

export interface IGetProject {
Expand All @@ -25,13 +27,17 @@ export const ProjectData = z.object({

export type ProjectData = z.infer<typeof ProjectData>;

export const ProjectListData = z.object({
export const FindProjectsResponse = z.object({
project_id: z.number(),
name: z.string(),
regions: z.array(z.string())
start_date: z.string().nullable(),
end_date: z.string().nullable(),
regions: z.array(z.string()),
focal_species: z.array(z.number()),
types: z.array(z.number())
});

export type ProjectListData = z.infer<typeof ProjectListData>;
export type FindProjectsResponse = z.infer<typeof FindProjectsResponse>;

/**
* Pre-processes GET /projects/{id} objectives data
Expand Down
25 changes: 25 additions & 0 deletions api/src/models/survey-view.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Feature } from 'geojson';
import { z } from 'zod';
import { SurveyMetadataPublish } from '../repositories/history-publish-repository';
import { IPermitModel } from '../repositories/permit-repository';
import { SiteSelectionData } from '../repositories/site-selection-strategy-repository';
Expand All @@ -8,6 +9,30 @@ import { SurveyUser } from '../repositories/survey-participation-repository';
import { SystemUser } from '../repositories/user-repository';
import { ITaxonomy } from '../services/platform-service';

export interface ISurveyAdvancedFilters {
keyword?: string;
itis_tsn?: number;
itis_tsns?: number[];
start_date?: string;
end_date?: string;
survey_name?: string;
system_user_id?: number;
}

export const FindSurveysResponse = z.object({
project_id: z.number(),
survey_id: z.number(),
name: z.string(),
progress_id: z.number(),
regions: z.array(z.string()),
start_date: z.string().nullable(),
end_date: z.string().nullable().optional().nullable(),
focal_species: z.array(z.number().nullable()),
types: z.array(z.number().nullable())
});

export type FindSurveysResponse = z.infer<typeof FindSurveysResponse>;

export type SurveyObject = {
survey_details: GetSurveyData;
species: GetFocalSpeciesData & GetAncillarySpeciesData;
Expand Down
6 changes: 6 additions & 0 deletions api/src/models/telemetry-view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface ITelemetryAdvancedFilters {
keyword?: string;
itis_tsns?: number[];
itis_tsn?: number;
system_user_id?: number;
}
Loading

0 comments on commit 5e245cf

Please sign in to comment.