-
Notifications
You must be signed in to change notification settings - Fork 2
feat(api): add assignee filter to project daily events search #634
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 all commits
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 |
|---|---|---|
|
|
@@ -583,7 +583,7 @@ module.exports = { | |
| * | ||
| * @return {Promise<RecentEventSchema[]>} | ||
| */ | ||
| async dailyEventsPortion(project, { limit, nextCursor, sort, filters, search, release }, context) { | ||
| async dailyEventsPortion(project, { limit, nextCursor, sort, filters, search, release, assignee }, context) { | ||
|
||
| if (search) { | ||
| if (search.length > MAX_SEARCH_QUERY_LENGTH) { | ||
| search = search.slice(0, MAX_SEARCH_QUERY_LENGTH); | ||
|
|
@@ -592,7 +592,15 @@ module.exports = { | |
|
|
||
| const factory = getEventsFactory(context, project._id); | ||
|
|
||
| const dailyEventsPortion = await factory.findDailyEventsPortion(limit, nextCursor, sort, filters, search, release); | ||
| const dailyEventsPortion = await factory.findDailyEventsPortion( | ||
| limit, | ||
| nextCursor, | ||
| sort, | ||
| filters, | ||
| search, | ||
| release, | ||
| assignee | ||
| ); | ||
|
|
||
| return dailyEventsPortion; | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -123,6 +123,10 @@ input EventsFiltersInput { | |||||||||
| If True, includes events with ignored mark to the output | ||||||||||
| """ | ||||||||||
| ignored: Boolean | ||||||||||
| """ | ||||||||||
| Includes only events assigned to passed user id | ||||||||||
| """ | ||||||||||
| assignee: ID | ||||||||||
|
Comment on lines
+126
to
+129
|
||||||||||
| """ | |
| Includes only events assigned to passed user id | |
| """ | |
| assignee: ID |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import '../../src/env-test'; | ||
|
|
||
| jest.mock('../../src/integrations/github/service', () => require('../__mocks__/github-service')); | ||
|
|
||
| jest.mock('../../src/resolvers/helpers/eventsFactory', () => ({ | ||
| __esModule: true, | ||
| default: jest.fn(), | ||
| })); | ||
|
|
||
| // @ts-expect-error - CommonJS module, TypeScript can't infer types properly | ||
| import projectResolverModule from '../../src/resolvers/project'; | ||
| import getEventsFactory from '../../src/resolvers/helpers/eventsFactory'; | ||
|
|
||
| const projectResolver = projectResolverModule as { | ||
| Project: { | ||
| dailyEventsPortion: (...args: unknown[]) => Promise<unknown>; | ||
| }; | ||
| }; | ||
|
|
||
| describe('Project resolver dailyEventsPortion', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('should pass assignee filter to events factory', async () => { | ||
| const findDailyEventsPortion = jest.fn().mockResolvedValue({ | ||
| nextCursor: null, | ||
| dailyEvents: [], | ||
| }); | ||
| (getEventsFactory as unknown as jest.Mock).mockReturnValue({ | ||
| findDailyEventsPortion, | ||
| }); | ||
|
|
||
| const project = { _id: 'project-1' }; | ||
| const args = { | ||
| limit: 50, | ||
| nextCursor: null, | ||
| sort: 'BY_DATE', | ||
| filters: { ignored: true }, | ||
| search: 'TypeError', | ||
| release: '1.0.0', | ||
| assignee: 'user-123', | ||
| }; | ||
|
|
||
| await projectResolver.Project.dailyEventsPortion(project, args, {}); | ||
|
|
||
| expect(findDailyEventsPortion).toHaveBeenCalledWith( | ||
| 50, | ||
| null, | ||
| 'BY_DATE', | ||
| { ignored: true }, | ||
| 'TypeError', | ||
| '1.0.0', | ||
| 'user-123' | ||
| ); | ||
| }); | ||
|
|
||
| it('should keep old call shape when assignee is not provided', async () => { | ||
| const findDailyEventsPortion = jest.fn().mockResolvedValue({ | ||
| nextCursor: null, | ||
| dailyEvents: [], | ||
| }); | ||
|
Comment on lines
+58
to
+62
|
||
| (getEventsFactory as unknown as jest.Mock).mockReturnValue({ | ||
| findDailyEventsPortion, | ||
| }); | ||
|
|
||
| const project = { _id: 'project-1' }; | ||
| const args = { | ||
| limit: 10, | ||
| nextCursor: null, | ||
| sort: 'BY_DATE', | ||
| filters: {}, | ||
| search: '', | ||
| release: undefined, | ||
| }; | ||
|
|
||
| await projectResolver.Project.dailyEventsPortion(project, args, {}); | ||
|
|
||
| expect(findDailyEventsPortion).toHaveBeenCalledWith( | ||
| 10, | ||
| null, | ||
| 'BY_DATE', | ||
| {}, | ||
| '', | ||
| undefined, | ||
| undefined | ||
| ); | ||
| }); | ||
| }); | ||
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.
EventsFiltersInputnow includesassignee, but this code explicitly keeps only mark keys fromfilters. As a result,filters: { assignee: ... }will be silently ignored. Consider either plumbing assignee through viafilters.assignee(and dropping the separateassigneeargument), or removingassigneefromEventsFiltersInputto avoid a misleading API.