Skip to content

Commit

Permalink
chore(hmi-client): removing explicit xdd Extractions call (#1117)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvince2 authored May 23, 2023
1 parent adff773 commit 5da71d4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

<script setup lang="ts">
import { ref, computed, PropType } from 'vue';
import { XDDExtractionType } from '@/types/XDD';
import { Document, XDDFacetsItemResponse, Dataset } from '@/types/Types';
import useQueryStore from '@/stores/query';
import { Model } from '@/types/Model';
Expand Down Expand Up @@ -120,36 +119,9 @@ const filteredAssets = computed(() => {
if (searchResults) {
if (props.resultType === ResourceType.XDD) {
let documentsFromExtractions: Document[] = [];
if (searchResults.xddExtractions && searchResults.xddExtractions.length > 0) {
const docMap: { [docid: string]: Document } = {};
searchResults.xddExtractions.forEach((ex) => {
const docid = ex.properties.documentBibjson.gddId;
if (docMap[docid] === undefined) {
docMap[docid] = ex.properties.documentBibjson;
docMap[docid].relatedExtractions = [];
}
// Avoid duplicate documents
else if (ex.askemClass === XDDExtractionType.Doc) {
const docExtractions = docMap[docid].relatedExtractions?.filter(
(extraction) => extraction.askemClass === XDDExtractionType.Doc
);
if (docExtractions) {
for (let i = 0; i < docExtractions.length; i++) {
if (ex.properties.doi === docExtractions[i].properties.doi) return; // Skip
}
}
}
docMap[docid].relatedExtractions?.push(ex);
});
documentsFromExtractions = Object.values(docMap) as Document[];
}
const documentSearchResults = searchResults.results as Document[];
return [...documentsFromExtractions, ...documentSearchResults];
return [...documentSearchResults];
}
if (props.resultType === ResourceType.MODEL || props.resultType === ResourceType.DATASET) {
return searchResults.results;
Expand Down
17 changes: 0 additions & 17 deletions packages/client/hmi-client/src/services/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,6 @@ const searchXDDDocuments = async (
return undefined;
};

const searchXDDExtractions = async (term: string): Promise<Extraction[]> => {
// also, perform search across extractions
let extractionsSearchResults = [] as Extraction[];
if (term !== '') {
// Temporary call to get a sufficient amount of extractions
// (Every call is limited to providing 30 extractions)
extractionsSearchResults = [
...(await getXDDArtifacts(term, [XDDExtractionType.Figure, XDDExtractionType.Table])),
...(await getXDDArtifacts(term, [XDDExtractionType.Doc]))
];
}
return extractionsSearchResults;
};

const filterAssets = <T extends Model | Dataset>(
allAssets: T[],
resourceType: ResourceType,
Expand Down Expand Up @@ -260,7 +246,6 @@ const getAssets = async (params: GetAssetsParams) => {
let assetList: Model[] | Dataset[] | Document[] = [];
let projectAssetType: ProjectAssetTypes;
let xddResults: DocumentsResponseOK | undefined;
let xddExtractions: Extraction[] | undefined;
let hits: number | undefined;

switch (resourceType) {
Expand All @@ -278,7 +263,6 @@ const getAssets = async (params: GetAssetsParams) => {
assetList = xddResults.data;
hits = xddResults.hits;
}
xddExtractions = await searchXDDExtractions(term);
projectAssetType = ProjectAssetTypes.DOCUMENTS;
break;
default:
Expand Down Expand Up @@ -437,7 +421,6 @@ const getAssets = async (params: GetAssetsParams) => {
const newFacets: { [p: string]: XDDFacetsItemResponse } = xddResults ? xddResults.facets : {};
results.allDataFilteredWithFacets = {
results: xddResults ? xddResults.data : [],
xddExtractions,
searchSubsystem: resourceType,
facets: newFacets,
rawConceptFacets: conceptFacets
Expand Down
3 changes: 1 addition & 2 deletions packages/client/hmi-client/src/types/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XDDFacetsItemResponse, Document, Extraction, Dataset } from '@/types/Types';
import { XDDFacetsItemResponse, Document, Dataset } from '@/types/Types';
import { ConceptFacets } from './Concept';
import { DatasetSearchParams } from './Dataset';
import { Model, ModelSearchParams } from './Model';
Expand Down Expand Up @@ -40,7 +40,6 @@ export type SearchResults = {
results: ResultType[];
facets?: { [p: string]: XDDFacetsItemResponse } | Facets;
rawConceptFacets?: ConceptFacets | null;
xddExtractions?: Extraction[]; // the result from searching XDD artifacts against a given search term
searchSubsystem: string;
hits?: number;
hasMore?: boolean;
Expand Down

0 comments on commit 5da71d4

Please sign in to comment.