Skip to content

Commit

Permalink
fixed performance issue:
Browse files Browse the repository at this point in the history
- limit=1 will largely impact the performance negatively
- specify the `aspect` parameter with aspectQuery will help speed up the query
  • Loading branch information
t83714 committed Feb 24, 2023
1 parent 43eed07 commit 8c395ce
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions magda-gateway/src/createCkanRedirectionRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default function buildCkanRedirectionRouter({
function getQueryRegistryRecordApiCacheKey(
aspectQuery: string[],
aspect: string[],
limit: number = 1
limit: number
) {
return JSON.stringify({
aspectQuery,
Expand All @@ -189,7 +189,7 @@ export default function buildCkanRedirectionRouter({
async function queryRegistryRecordApi(
aspectQuery: string[],
aspect: string[],
limit: number = 1
limit: number = undefined
) {
const cacheKey = getQueryRegistryRecordApiCacheKey(
aspectQuery,
Expand Down Expand Up @@ -234,7 +234,7 @@ export default function buildCkanRedirectionRouter({
aspectName: string,
retrieveAspectContent: boolean = true,
retrieveAspects: string[] = [],
limit: number = 1
limit: number = undefined
): Promise<any[]> {
const query = `${aspectName}.${
uuidRegEx.test(ckanIdOrName) ? "id" : "name"
Expand Down Expand Up @@ -270,7 +270,7 @@ export default function buildCkanRedirectionRouter({
ckanIdOrName: string,
aspectName: string
) {
const records = await queryCkanAspect(ckanIdOrName, aspectName, false);
const records = await queryCkanAspect(ckanIdOrName, aspectName);
if (!records || !records.length || !records[0]["id"]) {
return null;
} else {
Expand Down

0 comments on commit 8c395ce

Please sign in to comment.