@@ -5,17 +5,17 @@ const sendPersonalNotification = require('../utils/personalNotifications').defau
55/**
66 * Returns a per-request, per-project EventsFactory instance
77 * Uses context.eventsFactoryCache to memoize by projectId
8- * @param { any } context - GraphQL resolver context
9- * @param {string|ObjectID } ctorProjectId - value passed to EventsFactory constructor
10- * @param {string|ObjectID } keyProjectId - value used as cache key (string id is preferred)
11- * @returns {EventsFactory }
8+ *
9+ * @param {ResolverContextBase } context - resolver context
10+ * @param {string } projectId - project id to get EventsFactory instance for
11+ * @returns {EventsFactory } - EventsFactory instance bound to a specific project object
1212 */
13- function getEventsFactoryForProjectId ( context , ctorProjectId , keyProjectId ) {
13+ function getEventsFactoryForProjectId ( context , projectId ) {
1414 const cache = context . eventsFactoryCache || ( context . eventsFactoryCache = new Map ( ) ) ;
15- const cacheKey = ( keyProjectId || ctorProjectId ) . toString ( ) ;
15+ const cacheKey = projectId . toString ( ) ;
1616
1717 if ( ! cache . has ( cacheKey ) ) {
18- cache . set ( cacheKey , new EventsFactory ( ctorProjectId ) ) ;
18+ cache . set ( cacheKey , new EventsFactory ( projectId ) ) ;
1919 }
2020
2121 return cache . get ( cacheKey ) ;
@@ -49,7 +49,7 @@ module.exports = {
4949 * @return {RepetitionsPortion }
5050 */
5151 async repetitionsPortion ( { projectId, originalEventId } , { limit, cursor } , context ) {
52- const factory = getEventsFactoryForProjectId ( context , projectId , projectId ) ;
52+ const factory = getEventsFactoryForProjectId ( context , projectId ) ;
5353
5454 return factory . getEventRepetitions ( originalEventId , limit , cursor ) ;
5555 } ,
@@ -104,7 +104,7 @@ module.exports = {
104104 * @returns {Promise<ProjectChartItem[]> }
105105 */
106106 async chartData ( { projectId, groupHash } , { days, timezoneOffset } , context ) {
107- const factory = getEventsFactoryForProjectId ( context , new ObjectID ( projectId ) , projectId ) ;
107+ const factory = getEventsFactoryForProjectId ( context , projectId ) ;
108108
109109 return factory . findChartData ( days , timezoneOffset , groupHash ) ;
110110 } ,
@@ -117,7 +117,7 @@ module.exports = {
117117 * @returns {Promise<Release> }
118118 */
119119 async release ( { projectId, id : eventId } , _args , context ) {
120- const factory = getEventsFactoryForProjectId ( context , new ObjectID ( projectId ) , projectId ) ;
120+ const factory = getEventsFactoryForProjectId ( context , projectId ) ;
121121 const release = await factory . getEventRelease ( eventId ) ;
122122
123123 return release ;
@@ -134,7 +134,7 @@ module.exports = {
134134 * @return {Promise<boolean> }
135135 */
136136 async visitEvent ( _obj , { projectId, eventId } , { user, ...context } ) {
137- const factory = getEventsFactoryForProjectId ( context , projectId , projectId ) ;
137+ const factory = getEventsFactoryForProjectId ( context , projectId ) ;
138138
139139 const { result } = await factory . visitEvent ( eventId , user . id ) ;
140140
@@ -151,7 +151,7 @@ module.exports = {
151151 * @return {Promise<boolean> }
152152 */
153153 async toggleEventMark ( _obj , { project, eventId, mark } , context ) {
154- const factory = getEventsFactoryForProjectId ( context , project , project ) ;
154+ const factory = getEventsFactoryForProjectId ( context , project ) ;
155155
156156 const { result } = await factory . toggleEventMark ( eventId , mark ) ;
157157
@@ -176,7 +176,7 @@ module.exports = {
176176 */
177177 async updateAssignee ( _obj , { input } , { factories, user, ...context } ) {
178178 const { projectId, eventId, assignee } = input ;
179- const factory = getEventsFactoryForProjectId ( context , projectId , projectId ) ;
179+ const factory = getEventsFactoryForProjectId ( context , projectId ) ;
180180
181181 const userExists = await factories . usersFactory . findById ( assignee ) ;
182182
@@ -227,7 +227,7 @@ module.exports = {
227227 */
228228 async removeAssignee ( _obj , { input } , context ) {
229229 const { projectId, eventId } = input ;
230- const factory = getEventsFactoryForProjectId ( context , projectId , projectId ) ;
230+ const factory = getEventsFactoryForProjectId ( context , projectId ) ;
231231
232232 const { result } = await factory . updateAssignee ( eventId , '' ) ;
233233
0 commit comments