Skip to content

Commit d4786bd

Browse files
committed
imp(): get rid of event id in repetitionsPortion
1 parent 8e38bac commit d4786bd

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/models/eventsFactory.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ class EventsFactory extends Factory {
149149
_id: new ObjectID(id),
150150
});
151151

152-
return searchResult ? new Event(searchResult) : null;
152+
const event = searchResult ? new Event(searchResult) : null;
153+
154+
return event
153155
}
154156

155157
/**
@@ -442,7 +444,7 @@ class EventsFactory extends Factory {
442444
*
443445
* @return {EventRepetitionsPortionSchema}
444446
*/
445-
async getEventRepetitions(eventId, originalEventId, limit = 10, cursor = null) {
447+
async getEventRepetitions(originalEventId, limit = 10, cursor = null) {
446448
limit = this.validateLimit(limit);
447449

448450
cursor = cursor ? new ObjectID(cursor) : null;
@@ -536,6 +538,11 @@ class EventsFactory extends Factory {
536538
_id: ObjectID(originalEventId),
537539
});
538540

541+
/**
542+
* All events have same type with originalEvent id
543+
*/
544+
originalEvent.originalEventId = originalEventId;
545+
539546
return originalEvent || null;
540547
}
541548

src/resolvers/event.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ module.exports = {
2222
/**
2323
* Returns repetitions portion of the event
2424
*
25-
* @param {String} eventId - id of the event got from the partent graph node (event)
2625
* @param {String} projectId - id of the project got from the parent node (event)
26+
* @param {String} originalEventId - id of the original event of the repetitions to get, got from parent node (event)
2727
* @param {Number} limit - argument of the query, maximal count of the repetitions in one portion
2828
* @param {Number|null} cursor - pointer to the next portion of repetition, could be null if we want to get first portion
2929
*
3030
* @return {RepetitionsPortion}
3131
*/
32-
async repetitionsPortion({ _id: eventId, projectId, originalEventId }, { limit, cursor }) {
32+
async repetitionsPortion({ projectId, originalEventId}, { limit, cursor }) {
3333
const factory = new EventsFactory(projectId);
3434

35-
return factory.getEventRepetitions(eventId, originalEventId, limit, cursor);
35+
return factory.getEventRepetitions(originalEventId, limit, cursor);
3636
},
3737

3838
/**

src/resolvers/project.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,13 @@ module.exports = {
289289
* @returns {EventRepetitionSchema}
290290
*/
291291
async event(project, { eventId: repetitionId, originalEventId }) {
292+
console.log(`event resolver in project: ${repetitionId}, ${originalEventId}`)
293+
292294
const factory = new EventsFactory(project._id);
293295
const repetition = await factory.getEventRepetition(repetitionId, originalEventId);
294296

297+
console.log('repetition', repetition)
298+
295299
if (!repetition) {
296300
return null;
297301
}

0 commit comments

Comments
 (0)