Skip to content

Commit

Permalink
Standard searches are now faster! Huzzah! #2335
Browse files Browse the repository at this point in the history
  • Loading branch information
knirirr committed Jun 5, 2024
1 parent 3c1daa9 commit d09d06e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 76 deletions.
52 changes: 14 additions & 38 deletions src/components/Records/Search/Output/AssociatedRecordsSummary.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<template>
<div class="d-flex flex-column">
<div
v-for="(associatedRecord, associationName) in associatedRecords.registryNumber"
:key="associationName+'_'+associatedRecord.val"
v-for="(associatedRecord, associationName) in associatedRecords"
:key="associationName+'_'+associatedRecord"
class="d-flex flex-row"
>
<h4
:class="['my-0 font-weight-light',{'opacity-low':associatedRecord.val===0}]"
>
{{ setRecordLabels(associatedRecord.label) }}
{{ setRecordLabels(associationName) }}
</h4>
<span
:class="['counter-style',{'opacity-low':associatedRecord.val===0}]"
>{{ associatedRecord.val }}</span>
:class="['counter-style',{'opacity-low':associatedRecord===0}]"
>{{ associatedRecord }}</span>
</div>
</div>
</template>
Expand All @@ -32,40 +32,16 @@ export default {
},
methods: {
setRecordLabels(label) {
if (this.associatedRecords.registry === 'standard')
switch (label)
{
switch (label)
{
case 'standards':
return 'Related Standards';
case 'databases':
return 'Implementing Databases';
case 'policies':
return 'Endorsing Policies';
}
}
else if(this.associatedRecords.registry === 'database')
{
switch (label)
{
case 'standards':
return 'Standards Implemented';
case 'databases':
return 'Related Databases';
case 'policies':
return 'Endorsing Policies';
}
}else
{
switch (label)
{
case 'standards':
return 'Related Standards';
case 'databases':
return 'Related Databases';
case 'policies':
return 'Related Policies';
}
case 'standard':
return 'Linked Standards';
case 'database':
return 'Linked Databases';
case 'policy':
return 'Linked Policies';
case 'collection':
return 'Linked Collections';
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Records/Search/Output/RecordsCardStack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<v-divider class="dashed-line" />
<!-- Associated Records Summary -->
<associated-records-summary
:associated-records="associatedRecords(record)"
:associated-records="record.relatedRecordsCount"
class="ml-5"
/>
</v-card>
Expand Down
29 changes: 1 addition & 28 deletions src/lib/GraphClient/queries/getRecords.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,7 @@
"label"
]
},
{
"queryName": "recordAssociations",
"fields": [
{
"name": "linkedRecord",
"fields": [
"name",
"id",
"registry"
]
},
"recordAssocLabel"
]
},
{
"queryName": "reverseRecordAssociations",
"fields": [
{
"name": "fairsharingRecord",
"fields": [
"name",
"id",
"registry"
]
},
"recordAssocLabel"
]
},
"relatedRecordsCount",
"status",
"isRecommended"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ describe("AssociatedRecordsSummary.vue", function () {
});

it("can check setRecordLabels method", () => {
wrapper.vm.associatedRecords.registry = "database"
expect(wrapper.vm.setRecordLabels("standards")).toBe("Standards Implemented");
expect(wrapper.vm.setRecordLabels("databases")).toBe("Related Databases");
expect(wrapper.vm.setRecordLabels("policies")).toBe("Endorsing Policies");
wrapper.vm.associatedRecords.registry = "collection"
expect(wrapper.vm.setRecordLabels("standards")).toBe("Related Standards");
expect(wrapper.vm.setRecordLabels("databases")).toBe("Related Databases");
expect(wrapper.vm.setRecordLabels("policies")).toBe("Related Policies");
expect(wrapper.vm.setRecordLabels("standard")).toBe("Linked Standards");
expect(wrapper.vm.setRecordLabels("database")).toBe("Linked Databases");
expect(wrapper.vm.setRecordLabels("policy")).toBe("Linked Policies");
expect(wrapper.vm.setRecordLabels("collection")).toBe("Linked Collections");
});

});
2 changes: 1 addition & 1 deletion tests/unit/lib/GraphClient/GraphClient.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe("GraphQL Client", function () {

it("can correctly build a query string from a JSON", function () {
const expectedOutput =
'searchFairsharingRecords(field1:true field2:"true" field3:["true","false"]field4:{operator: "_and", fields: [{operator: "_and", registry: ["database"]}]}){ aggregations currentPage perPage totalCount totalPages firstPage records{id type name abbreviation doi registry description domains{ label id definitions iri synonyms inFairsharing}subjects{ label id definitions iri synonyms}taxonomies{ label}userDefinedTags{ label}recordAssociations{ linkedRecord{name id registry } recordAssocLabel}reverseRecordAssociations{ fairsharingRecord{name id registry } recordAssocLabel}status isRecommended }}';
'searchFairsharingRecords(field1:true field2:"true" field3:["true","false"]field4:{operator: "_and", fields: [{operator: "_and", registry: ["database"]}]}){ aggregations currentPage perPage totalCount totalPages firstPage records{id type name abbreviation doi registry description domains{ label id definitions iri synonyms inFairsharing}subjects{ label id definitions iri synonyms}taxonomies{ label}userDefinedTags{ label}relatedRecordsCount status isRecommended }}';
query.queryParam = {
field1: true,
field2: "true",
Expand Down

0 comments on commit d09d06e

Please sign in to comment.