Skip to content

Commit

Permalink
#1152 - fix handling of string ID from lucene
Browse files Browse the repository at this point in the history
this fixes the ability to select/deselect items
  • Loading branch information
louise-davies committed Oct 3, 2023
1 parent 0193e68 commit c0298fd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/datagateway-common/src/api/lucene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ interface RangeRequest {
export interface SearchResult {
id: number;
score: number;
source: SearchResultSource;
source: Omit<SearchResultSource, 'id'> & { id: string }; // TODO: if patrick fixes the string issue, revert this
}

interface RangeFacetResponse {
Expand Down
2 changes: 1 addition & 1 deletion packages/datagateway-common/src/app.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export interface SearchFacilityCycleSource {
}

export interface SearchResultSource {
id: number;
id: number; // TODO: if patrick doesn't fix the string issue, set this to string and fix the typing issues
name: string;
title?: string;
visitId?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ const DatasetCardView = (props: DatasetCardViewProps): React.ReactElement => {
});

function mapSource(response: SearchResponse): SearchResultSource[] {
return response.results?.map((result) => result.source) ?? [];
return (
response.results?.map((result) => ({
...result.source,
id: result.id,
})) ?? []
);
}

function mapIds(response: SearchResponse): number[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ const InvestigationCardView = (
);

function mapSource(response: SearchResponse): SearchResultSource[] {
return response.results?.map((result) => result.source) ?? [];
return (
response.results?.map((result) => ({
...result.source,
id: result.id,
})) ?? []
);
}

function mapIds(response: SearchResponse): number[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ const DatafileSearchTable = (
});

function mapSource(response: SearchResponse): SearchResultSource[] {
return response.results?.map((result) => result.source) ?? [];
return (
response.results?.map((result) => ({
...result.source,
id: result.id,
})) ?? []
);
}

function mapIds(response: SearchResponse): number[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ const DatasetSearchTable = ({
});

function mapSource(response: SearchResponse): SearchResultSource[] {
return response.results?.map((result) => result.source) ?? [];
return (
response.results?.map((result) => ({
...result.source,
id: result.id,
})) ?? []
);
}

function mapIds(response: SearchResponse): number[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ const InvestigationSearchTable = (
});

function mapSource(response: SearchResponse): SearchResultSource[] {
return response.results?.map((result) => result.source) ?? [];
return (
response.results?.map((result) => ({
...result.source,
id: result.id,
})) ?? []
);
}

function mapIds(response: SearchResponse): number[] {
Expand Down
6 changes: 3 additions & 3 deletions packages/datagateway-search/src/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mockSearchResponses: SearchResponse[] = [
score: 1,
id: 1,
source: {
id: 1,
id: '1',
name: 'Datafile test name',
location: '/datafiletest',
fileSize: 1,
Expand All @@ -47,7 +47,7 @@ const mockSearchResponses: SearchResponse[] = [
id: 596,
score: 269,
source: {
id: 749,
id: '749',
name: 'source 1',
},
},
Expand All @@ -59,7 +59,7 @@ const mockSearchResponses: SearchResponse[] = [
id: 916,
score: 160,
source: {
id: 143,
id: '143',
name: 'source 3',
},
},
Expand Down

0 comments on commit c0298fd

Please sign in to comment.