Skip to content
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

ASAP-810 Reorder Events in GP2 Dashboard #4484

Merged
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
12 changes: 8 additions & 4 deletions apps/gp2-frontend/src/events/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ describe('getAlgoliaEvents', () => {
});
const options: EventListOptions = {
filters: new Set<string>(),
after: new Date('1-1-2020').toDateString(),
before: undefined,
after: undefined,
before: new Date('1-1-2020').toDateString(),
pageSize: PAGE_SIZE,
currentPage: 0,
searchQuery: '',
Expand All @@ -75,6 +75,7 @@ describe('getAlgoliaEvents', () => {
['event'],
'test',
expect.objectContaining({ hitsPerPage: 10, page: 0 }),
true,
);
});

Expand All @@ -89,6 +90,7 @@ describe('getAlgoliaEvents', () => {
['event'],
'',
expect.objectContaining({ hitsPerPage: 20, page: 1 }),
true,
);
});

Expand All @@ -104,8 +106,9 @@ describe('getAlgoliaEvents', () => {
['event'],
'',
expect.objectContaining({
filters: 'endDateTimestamp > 1577836800 AND eventTypes:"GP2 Hub"',
filters: 'endDateTimestamp < 1577836800 AND eventTypes:"GP2 Hub"',
}),
true,
);
});

Expand All @@ -122,8 +125,9 @@ describe('getAlgoliaEvents', () => {
'',
expect.objectContaining({
filters:
'endDateTimestamp > 1577836800 AND eventTypes:"GP2 Hub" OR eventTypes:"Projects"',
'endDateTimestamp < 1577836800 AND eventTypes:"GP2 Hub" OR eventTypes:"Projects"',
}),
true,
);
});

Expand Down
15 changes: 10 additions & 5 deletions apps/gp2-frontend/src/events/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ export const getEvents = async (
const filters = getAllFilters(options);

return client
.search(['event'], options.searchQuery, {
filters,
page: options.currentPage ?? 0,
hitsPerPage: options.pageSize ?? 10,
})
.search(
['event'],
options.searchQuery,
{
filters,
page: options.currentPage ?? 0,
hitsPerPage: options.pageSize ?? 10,
},
!!options.before,
)
.catch((error: Error) => {
throw new Error(`Could not search: ${error.message}`);
});
Expand Down
Loading