From 1075dde7cbe01c3f87520c3b3ac42dd9bbd3a961 Mon Sep 17 00:00:00 2001 From: devketanpro Date: Mon, 9 Jan 2023 10:30:47 +0530 Subject: [PATCH 1/3] ingest dashboard does not count incoming items [SDESK-6782] --- scripts/apps/ingest/directives/IngestUserDashboard.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/apps/ingest/directives/IngestUserDashboard.ts b/scripts/apps/ingest/directives/IngestUserDashboard.ts index e874245af4..c4f023320f 100644 --- a/scripts/apps/ingest/directives/IngestUserDashboard.ts +++ b/scripts/apps/ingest/directives/IngestUserDashboard.ts @@ -27,14 +27,11 @@ export function IngestUserDashboard(api, userList, privileges, moment) { }, }; - var resource = 'ingest'; + var resources = ['ingest', 'events', 'planning']; - if (scope.item.content_types.includes('event') || scope.item.content_types.includes('planning')) { - resource = scope.item.content_types.includes('event') ? 'events' : 'planning'; - } - api.query(resource, criteria).then((result) => { - scope.ingested_count = result._meta.total; - }); + resources.map((resource) => api.query(resource, criteria).then((result) => { + scope.ingested_count += result._meta.total; + })); } function updateProvider() { From 57b3571b672b4fb722a29ea24b85e76a2c3eb8b9 Mon Sep 17 00:00:00 2001 From: devketanpro Date: Tue, 10 Jan 2023 09:06:30 +0530 Subject: [PATCH 2/3] filter out resources based on content_types --- scripts/apps/ingest/directives/IngestUserDashboard.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/apps/ingest/directives/IngestUserDashboard.ts b/scripts/apps/ingest/directives/IngestUserDashboard.ts index c4f023320f..fda291c558 100644 --- a/scripts/apps/ingest/directives/IngestUserDashboard.ts +++ b/scripts/apps/ingest/directives/IngestUserDashboard.ts @@ -27,8 +27,12 @@ export function IngestUserDashboard(api, userList, privileges, moment) { }, }; - var resources = ['ingest', 'events', 'planning']; + var resources = ['ingest']; + if (scope.item.content_types.includes('event') || scope.item.content_types.includes('planning')) { + resources.push(scope.item.content_types.includes('event') && 'events'); + resources.push(scope.item.content_types.includes('planning') && 'planning'); + } resources.map((resource) => api.query(resource, criteria).then((result) => { scope.ingested_count += result._meta.total; })); From 1f1d08504fa267c11f592b28851fc20116a20537 Mon Sep 17 00:00:00 2001 From: devketanpro Date: Tue, 10 Jan 2023 13:34:45 +0530 Subject: [PATCH 3/3] refacored the code --- scripts/apps/ingest/directives/IngestUserDashboard.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/apps/ingest/directives/IngestUserDashboard.ts b/scripts/apps/ingest/directives/IngestUserDashboard.ts index fda291c558..f963a60c82 100644 --- a/scripts/apps/ingest/directives/IngestUserDashboard.ts +++ b/scripts/apps/ingest/directives/IngestUserDashboard.ts @@ -29,9 +29,11 @@ export function IngestUserDashboard(api, userList, privileges, moment) { var resources = ['ingest']; - if (scope.item.content_types.includes('event') || scope.item.content_types.includes('planning')) { - resources.push(scope.item.content_types.includes('event') && 'events'); - resources.push(scope.item.content_types.includes('planning') && 'planning'); + if (scope.item.content_types.includes('event')) { + resources.push('events'); + } + if (scope.item.content_types.includes('planning')) { + resources.push('planning'); } resources.map((resource) => api.query(resource, criteria).then((result) => { scope.ingested_count += result._meta.total;