From 4b8bd742683e3ffc207779a443edf10542122b1f Mon Sep 17 00:00:00 2001 From: Janith Rathnayaka Date: Tue, 22 Oct 2024 13:12:30 +0530 Subject: [PATCH 1/3] add from_date for count --- apps/triage/src/app/app.service.ts | 2 +- libs/unitedwave-client/src/lib/unitedwave-client.service.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/triage/src/app/app.service.ts b/apps/triage/src/app/app.service.ts index 4538d508..ff9b671e 100644 --- a/apps/triage/src/app/app.service.ts +++ b/apps/triage/src/app/app.service.ts @@ -44,7 +44,7 @@ export class AppService { startTime = lastMeedanReport[0].node?.tasks?.edges?.find(task => task.node?.label === this.config.originalPostTimeField).node?.first_response_value } } - const postsCount = await this.unitedwaveClient.getPostsCount().toPromise(); + const postsCount = await this.unitedwaveClient.getPostsCount(startTime).toPromise(); this.logger.log('Latest unitedwaveClient count', postsCount) const postsPerPage = 50; const pageCount = Math.ceil(Number(postsCount) / postsPerPage); diff --git a/libs/unitedwave-client/src/lib/unitedwave-client.service.ts b/libs/unitedwave-client/src/lib/unitedwave-client.service.ts index 02eb1612..b86dba13 100644 --- a/libs/unitedwave-client/src/lib/unitedwave-client.service.ts +++ b/libs/unitedwave-client/src/lib/unitedwave-client.service.ts @@ -24,11 +24,14 @@ export class UnitedwaveClientService{ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; } - getPostsCount(filter?:string) { + getPostsCount(startDate?: string,filter?:string) { let query = this.config.endpoints.count + `?user[name]=${this.config.username}&user[secret]=${this.config.password}`; if(filter) { query += `&clip[filters]=${filter}` } + if (startDate) { + query += `&clip[from_date]=${startDate}` + } return this.http.post(query).pipe( map(res => res.data), retry(3), From bdbc5f980a29eaa703af915f903fc13a2d86ce26 Mon Sep 17 00:00:00 2001 From: Janith Rathnayaka Date: Tue, 22 Oct 2024 13:40:24 +0530 Subject: [PATCH 2/3] add keyword to title --- apps/triage/src/app/app.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/triage/src/app/app.service.ts b/apps/triage/src/app/app.service.ts index ff9b671e..3183369d 100644 --- a/apps/triage/src/app/app.service.ts +++ b/apps/triage/src/app/app.service.ts @@ -55,10 +55,11 @@ export class AppService { const list = await this.unitedwaveClient.getPosts(page,startTime).toPromise(); for (let i = list.length - 1; i >= 0; i--) { const post = list[i]; + const title = `${post?.clip_name || ''}${post?.clip_name && post?.keywords ? ' ' : ''}${post?.keywords || ''}`; //check duplication const isDuplicate = this.isDuplicatePost(post, createdPosts); if (!isDuplicate) { - const item = await this.checkClient.createItemFromRadio(post?.clip_url, post?.clip_name, post?.source_text, post?.date_reported).toPromise(); + const item = await this.checkClient.createItemFromRadio(post?.clip_url, title, post?.source_text, post?.date_reported).toPromise(); if(!item.error) { createdItems = [...createdItems, item]; createdPosts = [...createdPosts, post]; From 3bf86d67d3cac29176ef64fa96a47ca4ded6acf9 Mon Sep 17 00:00:00 2001 From: Janith Rathnayaka Date: Tue, 22 Oct 2024 14:19:02 +0530 Subject: [PATCH 3/3] add radio title date_reported --- apps/triage/src/app/app.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/triage/src/app/app.service.ts b/apps/triage/src/app/app.service.ts index 3183369d..19852a78 100644 --- a/apps/triage/src/app/app.service.ts +++ b/apps/triage/src/app/app.service.ts @@ -55,8 +55,10 @@ export class AppService { const list = await this.unitedwaveClient.getPosts(page,startTime).toPromise(); for (let i = list.length - 1; i >= 0; i--) { const post = list[i]; - const title = `${post?.clip_name || ''}${post?.clip_name && post?.keywords ? ' ' : ''}${post?.keywords || ''}`; - //check duplication + const title = [post?.clip_name, post?.keywords, post?.date_reported] + .filter(Boolean) + .join(' - '); + // check duplication const isDuplicate = this.isDuplicatePost(post, createdPosts); if (!isDuplicate) { const item = await this.checkClient.createItemFromRadio(post?.clip_url, title, post?.source_text, post?.date_reported).toPromise();