Skip to content

Commit 60d22ed

Browse files
committed
revevert factory changes
1 parent 995c181 commit 60d22ed

File tree

2 files changed

+12
-31
lines changed

2 files changed

+12
-31
lines changed

src/models/eventsFactory.js

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getMidnightWithTimezoneOffset, getUTCMidnight } from '../utils/dates';
2-
import { composeFullRepetitionEvent } from '../utils/merge';
32
import { groupBy } from '../utils/grouper';
43
import safe from 'safe-regex';
54

@@ -423,14 +422,6 @@ class EventsFactory extends Factory {
423422
.skip(skip)
424423
.toArray();
425424

426-
repetitions.forEach(repetition => {
427-
repetition.payload = composeFullRepetitionEvent(eventOriginal, repetition).payload;
428-
429-
if ('delta' in repetition) {
430-
delete repetition.delta;
431-
}
432-
});
433-
434425
const isLastPortion = repetitions.length < limit && skip === 0;
435426

436427
/**
@@ -464,30 +455,10 @@ class EventsFactory extends Factory {
464455
* @todo move to Repetitions(?) model
465456
*/
466457
async getEventRepetition(repetitionId) {
467-
const repetition = await this.getCollection(this.TYPES.REPETITIONS)
458+
return this.getCollection(this.TYPES.REPETITIONS)
468459
.findOne({
469-
_id: ObjectID(repetitionId),
460+
_id: new ObjectID(repetitionId),
470461
});
471-
472-
if (!repetition) {
473-
return null;
474-
}
475-
476-
const event = await this.findOneByQuery({
477-
groupHash: repetition.groupHash,
478-
});
479-
480-
if (!event) {
481-
return null;
482-
}
483-
484-
repetition.payload = composeFullRepetitionEvent(event, repetition).payload;
485-
486-
if ('delta' in repetition) {
487-
delete repetition.delta;
488-
}
489-
490-
return repetition;
491462
}
492463

493464
/**
@@ -498,6 +469,10 @@ class EventsFactory extends Factory {
498469
async getEventLastRepetition(eventId) {
499470
const repetitions = await this.getEventRepetitions(eventId, 1);
500471

472+
if (repetitions.length === 0) {
473+
return null;
474+
}
475+
501476
return repetitions.shift();
502477
}
503478

src/typeDefs/event.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ type Repetition {
255255
"""
256256
payload: RepetitionPayload
257257
258+
"""
259+
Delta of the event's payload, stringified JSON
260+
"""
261+
delta: String
262+
263+
258264
"""
259265
Event timestamp
260266
"""

0 commit comments

Comments
 (0)