Skip to content

Commit 764a02f

Browse files
feat: add an index for payload.release & update pipeline (#582)
* feat: add an index for payload.release & update pipeline * Bump version up to 1.2.20 * fix: group hash index * fix: lint --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 443be89 commit 764a02f

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hawk.api",
3-
"version": "1.2.19",
3+
"version": "1.2.20",
44
"main": "index.ts",
55
"license": "BUSL-1.1",
66
"scripts": {

src/resolvers/project.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const EVENTS_GROUP_HASH_INDEX_NAME = 'groupHashUnique';
1414
const REPETITIONS_GROUP_HASH_INDEX_NAME = 'groupHash_hashed';
1515
const REPETITIONS_USER_ID_INDEX_NAME = 'userId';
1616
const EVENTS_TIMESTAMP_INDEX_NAME = 'timestamp';
17+
const EVENTS_PAYLOAD_RELEASE_INDEX_NAME = 'payloadRelease';
1718
const GROUPING_TIMESTAMP_INDEX_NAME = 'groupingTimestamp';
1819
const GROUPING_TIMESTAMP_AND_LAST_REPETITION_TIME_AND_ID_INDEX_NAME = 'groupingTimestampAndLastRepetitionTimeAndId';
1920
const GROUPING_TIMESTAMP_AND_GROUP_HASH_INDEX_NAME = 'groupingTimestampAndGroupHash';
@@ -127,6 +128,15 @@ module.exports = {
127128
name: GROUPING_TIMESTAMP_AND_LAST_REPETITION_TIME_AND_ID_INDEX_NAME,
128129
});
129130

131+
await projectEventsCollection.createIndex({
132+
'payload.release': 1,
133+
},
134+
{
135+
name: EVENTS_PAYLOAD_RELEASE_INDEX_NAME,
136+
background: true,
137+
sparse: true,
138+
});
139+
130140
await projectEventsCollection.createIndex({
131141
groupHash: 1,
132142
},
@@ -503,14 +513,7 @@ module.exports = {
503513
{ $match: { projectId: project._id.toString() } },
504514
{
505515
$project: {
506-
release: {
507-
$convert: {
508-
input: '$release',
509-
to: 'string',
510-
onError: '',
511-
onNull: '',
512-
},
513-
},
516+
release: '$release',
514517
commitsCount: { $size: { $ifNull: ['$commits', [] ] } },
515518
filesCount: { $size: { $ifNull: ['$files', [] ] } },
516519
_releaseIdSec: { $floor: { $divide: [ { $toLong: { $toDate: '$_id' } }, 1000] } },
@@ -524,14 +527,7 @@ module.exports = {
524527
{
525528
$match: {
526529
$expr: {
527-
$eq: [ {
528-
$convert: {
529-
input: '$payload.release',
530-
to: 'string',
531-
onError: '',
532-
onNull: '',
533-
},
534-
}, '$$rel'],
530+
$eq: ['$payload.release', '$$rel'],
535531
},
536532
},
537533
},

0 commit comments

Comments
 (0)