-
Notifications
You must be signed in to change notification settings - Fork 2
Add filtering by date range #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
8a7d63a
1bd29cd
cfc7e12
2672e6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ uploads | |
| globalConfig.json | ||
| coverage | ||
| tls | ||
| .history | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -23,9 +23,11 @@ const { ObjectID } = require('mongodb'); | |||
|
|
||||
| /** | ||||
| * @typedef {Object} EventsFilters | ||||
| * @property {boolean} [starred] - if true, events with 'starred' mark should be included to the output | ||||
| * @property {boolean} [resolved] - if true, events with 'resolved' should be included to the output | ||||
| * @property {boolean} [ignored] - if true, events with 'ignored' mark should be included to the output | ||||
| * @property {boolean} [starred] | ||||
| * @property {boolean} [resolved] | ||||
| * @property {boolean} [ignored] | ||||
| * @property {string|number} [dateFrom] | ||||
| * @property {string|number} [dateTo] | ||||
| */ | ||||
|
|
||||
| /** | ||||
|
|
@@ -149,8 +151,8 @@ class EventsFactory extends Factory { | |||
| * @param {Number} limit - events count limitations | ||||
| * @param {Number} skip - certain number of documents to skip | ||||
| * @param {'BY_DATE' | 'BY_COUNT'} sort - events sort order | ||||
| * @param {EventsFilters} filters - marks by which events should be filtered | ||||
| * @param {String} search - Search query | ||||
| * @param {EventsFilters} filters - filter object | ||||
| * @param {String} search - search query | ||||
| * | ||||
| * @return {RecentEventSchema[]} | ||||
| */ | ||||
|
|
@@ -165,9 +167,6 @@ class EventsFactory extends Factory { | |||
| throw new Error('Search parameter must be a string'); | ||||
| } | ||||
|
|
||||
| /** | ||||
| * Check if pattern is safe RegExp | ||||
| */ | ||||
|
Comment on lines
225
to
227
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected jsdoc removal |
||||
| if (!safe(search)) { | ||||
| throw new Error('Invalid regular expression pattern'); | ||||
| } | ||||
|
|
@@ -231,13 +230,41 @@ class EventsFactory extends Factory { | |||
| } | ||||
| : {}; | ||||
|
|
||||
| const matchFilter = filters | ||||
| ? Object.fromEntries( | ||||
| Object | ||||
| .entries(filters) | ||||
| .map(([mark, exists]) => [`event.marks.${mark}`, { $exists: exists } ]) | ||||
| ) | ||||
| : {}; | ||||
| const matchFilter = { | ||||
| ...searchFilter, | ||||
| }; | ||||
|
|
||||
| // Filter by marks (event.marks.{key}) | ||||
|
||||
| // Filter by marks (event.marks.{key}) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave jsdoc please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant jsdoc removal