Skip to content

Commit

Permalink
refactor: rename createdAtFrom/To to from/to (#7773)
Browse files Browse the repository at this point in the history
Update the query parameter of the new event search API to match the
query parameters of the insights API
  • Loading branch information
thomasheartman authored Aug 6, 2024
1 parent f966523 commit 76bc7bf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions frontend/src/openapi/models/searchEventsParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export type SearchEventsParams = {
/**
* The starting date of the creation date range in IS:yyyy-MM-dd format
*/
createdAtFrom?: string;
from?: string;
/**
* The ending date of the creation date range in IS:yyyy-MM-dd format
*/
createdAtTo?: string;
to?: string;
/**
* The number of features to skip when returning a page. By default it is set to 0.
*/
Expand Down
14 changes: 4 additions & 10 deletions src/lib/features/events/event-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,8 @@ export default class EventService {
convertToDbParams = (params: IEventSearchParams): IQueryParam[] => {
const queryParams: IQueryParam[] = [];

if (params.createdAtFrom) {
const parsed = parseSearchOperatorValue(
'created_at',
params.createdAtFrom,
);
if (params.from) {
const parsed = parseSearchOperatorValue('created_at', params.from);
if (parsed) {
queryParams.push({
field: parsed.field,
Expand All @@ -160,11 +157,8 @@ export default class EventService {
}
}

if (params.createdAtTo) {
const parsed = parseSearchOperatorValue(
'created_at',
params.createdAtTo,
);
if (params.to) {
const parsed = parseSearchOperatorValue('created_at', params.to);
if (parsed) {
queryParams.push({
field: parsed.field,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/openapi/spec/event-search-query-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const eventSearchQueryParameters = [
in: 'query',
},
{
name: 'createdAtFrom',
name: 'from',
schema: {
type: 'string',
example: 'IS:2024-01-01',
Expand All @@ -68,7 +68,7 @@ export const eventSearchQueryParameters = [
in: 'query',
},
{
name: 'createdAtTo',
name: 'to',
schema: {
type: 'string',
example: 'IS:2024-01-31',
Expand Down
4 changes: 2 additions & 2 deletions src/lib/types/stores/event-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export interface IEventSearchParams {
project?: string;
query?: string;
feature?: string;
createdAtFrom?: string;
createdAtTo?: string;
from?: string;
to?: string;
createdBy?: string;
type?: string;
offset: number;
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/api/admin/event-search.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ test('should filter events by created date range', async () => {
const today = new Date();

const { body } = await searchEvents({
createdAtFrom: `IS:${today.toISOString().split('T')[0]}`,
from: `IS:${today.toISOString().split('T')[0]}`,
});

expect(body).toMatchObject({
Expand Down

0 comments on commit 76bc7bf

Please sign in to comment.