@@ -8,7 +8,6 @@ import { GithubService } from "src/github/service";
88import { LoggerService } from "src/logger/service" ;
99import { ProjectRepository } from "src/project/repository" ;
1010import { RepositoryRepository } from "src/repository/repository" ;
11- import { SearchItem } from "src/search/types" ;
1211import { SearchService } from "src/search/service" ;
1312import { Service } from "typedi" ;
1413
@@ -70,17 +69,13 @@ export class DigestCron {
7069
7170 const projectsFromDataFolder = await this . dataService . listProjects ( ) ;
7271
73- const searchProjectItems : SearchItem [ ] = [ ] ;
74- const searchContributorItems : SearchItem [ ] = [ ] ;
75- const searchContributionItems : SearchItem [ ] = [ ] ;
76-
7772 for ( const project of projectsFromDataFolder ) {
7873 const [ { id : projectId } ] = await this . projectsRepository . upsert ( {
7974 ...project ,
8075 runId,
8176 id : project . slug ,
8277 } ) ;
83- searchProjectItems . push ( {
78+ this . searchService . upsert ( "project" , {
8479 id : project . slug . replace ( / [ . ] / g, "-" ) , // MeiliSearch doesn't allow dots in ids
8580 title : project . name ,
8681 type : "project" ,
@@ -130,7 +125,7 @@ export class DigestCron {
130125 runId,
131126 id : `${ provider } -${ githubUser . login } ` ,
132127 } ) ;
133- searchContributorItems . push ( {
128+ this . searchService . upsert ( "contributor" , {
134129 id : `${ provider } -${ githubUser . login } ` ,
135130 title : githubUser . name || githubUser . login ,
136131 type : "contributor" ,
@@ -158,7 +153,7 @@ export class DigestCron {
158153 contributorId,
159154 id : `${ provider } -${ issue . id } ` ,
160155 } ) ;
161- searchContributionItems . push ( {
156+ this . searchService . upsert ( "contribution" , {
162157 id : `${ provider } -${ issue . id } ` ,
163158 title : issue . title ,
164159 type : "contribution" ,
@@ -218,17 +213,6 @@ export class DigestCron {
218213 await this . contributorsRepository . deleteAllButWithRunId ( runId ) ;
219214 await this . repositoriesRepository . deleteAllButWithRunId ( runId ) ;
220215 await this . projectsRepository . deleteAllButWithRunId ( runId ) ;
221- await this . searchService . deleteAllDocuments ( "project" ) ;
222- await this . searchService . deleteAllDocuments ( "contribution" ) ;
223- await this . searchService . deleteAllDocuments ( "contributor" ) ;
224- } catch ( error ) {
225- captureException ( error , { tags : { type : "CRON" } } ) ;
226- }
227-
228- try {
229- await this . searchService . index ( "project" , searchProjectItems ) ;
230- await this . searchService . index ( "contribution" , searchContributionItems ) ;
231- await this . searchService . index ( "contributor" , searchContributorItems ) ;
232216 } catch ( error ) {
233217 captureException ( error , { tags : { type : "CRON" } } ) ;
234218 }
0 commit comments