Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawk.api",
"version": "1.2.19",
"version": "1.2.20",
"main": "index.ts",
"license": "BUSL-1.1",
"scripts": {
Expand Down
28 changes: 12 additions & 16 deletions src/resolvers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const EVENTS_GROUP_HASH_INDEX_NAME = 'groupHashUnique';
const REPETITIONS_GROUP_HASH_INDEX_NAME = 'groupHash_hashed';
const REPETITIONS_USER_ID_INDEX_NAME = 'userId';
const EVENTS_TIMESTAMP_INDEX_NAME = 'timestamp';
const EVENTS_PAYLOAD_RELEASE_INDEX_NAME = 'payloadRelease';
const GROUPING_TIMESTAMP_INDEX_NAME = 'groupingTimestamp';
const GROUPING_TIMESTAMP_AND_LAST_REPETITION_TIME_AND_ID_INDEX_NAME = 'groupingTimestampAndLastRepetitionTimeAndId';
const GROUPING_TIMESTAMP_AND_GROUP_HASH_INDEX_NAME = 'groupingTimestampAndGroupHash';
Expand Down Expand Up @@ -127,6 +128,15 @@ module.exports = {
name: GROUPING_TIMESTAMP_AND_LAST_REPETITION_TIME_AND_ID_INDEX_NAME,
});

await projectEventsCollection.createIndex({
'payload.release': 1,
},
{
name: EVENTS_PAYLOAD_RELEASE_INDEX_NAME,
background: true,
sparse: true,
});

await projectEventsCollection.createIndex({
groupHash: 1,
},
Expand Down Expand Up @@ -503,14 +513,7 @@ module.exports = {
{ $match: { projectId: project._id.toString() } },
{
$project: {
release: {
$convert: {
input: '$release',
to: 'string',
onError: '',
onNull: '',
},
},
release: '$release',
commitsCount: { $size: { $ifNull: ['$commits', [] ] } },
filesCount: { $size: { $ifNull: ['$files', [] ] } },
_releaseIdSec: { $floor: { $divide: [ { $toLong: { $toDate: '$_id' } }, 1000] } },
Expand All @@ -524,14 +527,7 @@ module.exports = {
{
$match: {
$expr: {
$eq: [ {
$convert: {
input: '$payload.release',
to: 'string',
onError: '',
onNull: '',
},
}, '$$rel'],
$eq: ['$payload.release', '$$rel'],
},
},
},
Expand Down
Loading