File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -313,13 +313,20 @@ export default class GrouperWorker extends Worker {
313313 * @returns EventPatterns object with projectId and list of patterns
314314 */
315315 private async getProjectPatterns ( projectId : string ) : Promise < string [ ] > {
316- const project = await this . accountsDb . getConnection ( )
317- . collection ( 'projects' )
318- . findOne ( {
319- _id : new mongodb . ObjectId ( projectId ) ,
320- } ) ;
316+ return this . cache . get ( `project:${ projectId } :patterns` , async ( ) => {
317+ const project = await this . accountsDb . getConnection ( )
318+ . collection ( 'projects' )
319+ . findOne ( {
320+ _id : new mongodb . ObjectId ( projectId ) ,
321+ } ) ;
321322
322- return project . eventGroupingPatterns ;
323+ return project ?. eventGroupingPatterns || [ ] ;
324+ } ,
325+ /**
326+ * Cache project patterns for 5 minutes since they don't change frequently
327+ */
328+ /* eslint-disable-next-line @typescript-eslint/no-magic-numbers */
329+ 5 * TimeMs . MINUTE / MS_IN_SEC ) ;
323330 }
324331
325332 /**
You can’t perform that action at this time.
0 commit comments