feat: trending fix

This commit is contained in:
Nevo David 2024-03-10 21:43:24 +07:00
parent 44a0a77615
commit ea2e32fa96
1 changed files with 10 additions and 8 deletions

View File

@ -140,9 +140,11 @@ export class StarsService {
const currentTrending = await this._starsRepository.getTrendingByLanguage( const currentTrending = await this._starsRepository.getTrendingByLanguage(
language language
); );
if (currentTrending?.hash === hash) { if (currentTrending?.hash === hash) {
return; return;
} }
await this.newTrending(language); await this.newTrending(language);
if (currentTrending) { if (currentTrending) {
const list: Array<{ name: string; position: number }> = JSON.parse( const list: Array<{ name: string; position: number }> = JSON.parse(
@ -166,7 +168,7 @@ export class StarsService {
} }
const informNewPeople = arr.filter( const informNewPeople = arr.filter(
(p) => currentTrending?.trendingList?.indexOf(p.name) === -1 (p) => !currentTrending?.trendingList || currentTrending?.trendingList?.indexOf(p.name) === -1
); );
// let people know they are trending // let people know they are trending
@ -193,15 +195,15 @@ export class StarsService {
case Inform.Removed: case Inform.Removed:
return this._notificationsService.inAppNotification( return this._notificationsService.inAppNotification(
org.organizationId, org.organizationId,
'You are not trending on GitHub anymore', `${person.name} is not trending on GitHub anymore`,
`You are not trending anymore in ${language}`, `${person.name} is not trending anymore in ${language}`,
true true
); );
case Inform.New: case Inform.New:
return this._notificationsService.inAppNotification( return this._notificationsService.inAppNotification(
org.organizationId, org.organizationId,
'You are trending on GitHub', `${person.name} is trending on GitHub`,
`You are trending in ${ `${person.name} is trending in ${
language || 'On the main feed' language || 'On the main feed'
} position #${person.position}`, } position #${person.position}`,
true true
@ -209,9 +211,9 @@ export class StarsService {
case Inform.Changed: case Inform.Changed:
return this._notificationsService.inAppNotification( return this._notificationsService.inAppNotification(
org.organizationId, org.organizationId,
'You have changed trending position on GitHub', `${person.name} changed trending position on GitHub`,
`You changed position in ${ `${person.name} changed position in ${
language || 'On the main feed' language || 'on the main feed to position'
} position #${person.position}`, } position #${person.position}`,
true true
); );