Skip to content

Commit 17c654a

Browse files
committed
chore(): clean up
1 parent 0aa318d commit 17c654a

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

src/models/eventsFactory.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class EventsFactory extends Factory {
149149
* Returns events that grouped by day
150150
*
151151
* @param {Number} limit - events count limitations
152-
* @param {String} paginatoinCursor - pointer to the first daily event to be selected
152+
* @param {String} paginationCursor - pointer to the first daily event to be selected
153153
* @param {'BY_DATE' | 'BY_COUNT'} sort - events sort order
154154
* @param {EventsFilters} filters - marks by which events should be filtered
155155
* @param {String} search - Search query
@@ -158,7 +158,7 @@ class EventsFactory extends Factory {
158158
*/
159159
async findRecentDailyEventsWithEventAndRepetition(
160160
limit = 10,
161-
paginationCursor = '',
161+
paginationCursor = null,
162162
sort = 'BY_DATE',
163163
filters = {},
164164
search = ''
@@ -197,8 +197,8 @@ class EventsFactory extends Factory {
197197
{
198198
$match: paginationCursor ? {
199199
_id: {
200-
$gte: new ObjectID(paginationCursor),
201-
}
200+
$lte: new ObjectID(paginationCursor),
201+
},
202202
} : {},
203203
},
204204
{
@@ -266,7 +266,7 @@ class EventsFactory extends Factory {
266266
localField: 'lastRepetitionId',
267267
foreignField: '_id',
268268
as: 'repetition',
269-
}
269+
},
270270
},
271271
/**
272272
* Desctruct event and repetition arrays since there are only one document in both arrays
@@ -293,32 +293,23 @@ class EventsFactory extends Factory {
293293

294294
const result = await cursor.toArray();
295295

296-
let lastEvent;
297-
298-
if (result.length === limit + 1) {
299-
lastEvent = result.pop();
300-
}
296+
const nextCursor = result.pop()._id;
301297

302298
const composedResult = result.map(dailyEvent => {
303299
const repetition = dailyEvent.repetition;
304300
const event = dailyEvent.event;
305301

306-
console.log('current projectId is ', this.projectId);
307-
308302
return {
309303
...dailyEvent,
310304
id: dailyEvent._id.toString(),
311305
_id: undefined,
312306
event: this._composeEventWithRepetition(event, repetition),
313307
repetition: undefined,
314-
}
315-
})
316-
317-
console.log('result', composedResult)
308+
};
309+
});
318310

319-
320311
return {
321-
nextCursor: lastEvent ? lastEvent._id.toString() : null,
312+
nextCursor: nextCursor,
322313
dailyEvents: composedResult,
323314
};
324315
}
@@ -696,7 +687,7 @@ class EventsFactory extends Factory {
696687
_id: new ObjectID(eventId),
697688
});
698689

699-
console.log('repetition found', repetition)
690+
console.log('repetition found', repetition);
700691

701692
/**
702693
* If repetition is not found by eventId, try to find it by eventId
@@ -707,14 +698,14 @@ class EventsFactory extends Factory {
707698
_id: new ObjectID(eventId),
708699
});
709700

710-
console.log('no repetition found, fetched by original event id', originalEvent);
701+
console.log('no repetition found, fetched by original event id', originalEvent);
711702
} else {
712703
originalEvent = await this.getCollection(this.TYPES.EVENTS)
713704
.findOne({
714705
groupHash: repetition.groupHash,
715706
});
716707

717-
console.log('repetition found, fetched by groupHash', originalEvent);
708+
console.log('repetition found, fetched by groupHash', originalEvent);
718709
}
719710

720711
return originalEvent;

src/models/projectsFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class ProjectsFactory extends AbstractModelFactory<ProjectDBSchem
3535
* @param id - user id
3636
*/
3737
public async findById(id: string): Promise<ProjectModel | null> {
38-
console.log('id in data loader', id)
38+
console.log('id in data loader', id);
3939

4040
const projectData = await this.dataLoaders.projectById.load(id);
4141

src/resolvers/event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = {
4444
* @return {Promise<UserModel[]> | null}
4545
*/
4646
async visitedBy({ visitedBy, projectId }, _args, { factories, user }) {
47-
console.log('visitedBy, projectId', visitedBy, projectId)
47+
console.log('visitedBy, projectId', visitedBy, projectId);
4848

4949
/**
5050
* Crutch for Demo Workspace

src/resolvers/project.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const EventsFactory = require('../models/eventsFactory');
88
const ProjectToWorkspace = require('../models/projectToWorkspace');
99
const { dateFromObjectId } = require('../utils/dates');
1010
const ProjectModel = require('../models/project').default;
11-
const { composeEventPayloadWithRepetition } = require('../utils/merge');
1211

1312
const EVENTS_GROUP_HASH_INDEX_NAME = 'groupHashUnique';
1413
const REPETITIONS_GROUP_HASH_INDEX_NAME = 'groupHash_hashed';
@@ -356,10 +355,6 @@ module.exports = {
356355

357356
const dailyEventsPortion = await factory.findRecentDailyEventsWithEventAndRepetition(limit, nextCursor, sort, filters, search);
358357

359-
console.log('daily events portion composed, ...[event]', dailyEventsPortion);
360-
361-
// this.dailyEventsPortion.dailyEvents.forEach(dailyEvent)
362-
363358
return dailyEventsPortion;
364359
},
365360

0 commit comments

Comments
 (0)