1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-19 00:15:43 +01:00

refactor: rename createdAtFrom/To to from/to (#7773)

Update the query parameter of the new event search API to match the
query parameters of the insights API
This commit is contained in:
Thomas Heartman 2024-08-06 15:02:44 +02:00 committed by GitHub
parent f9665233cc
commit 76bc7bf250
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 17 deletions

View File

@ -28,11 +28,11 @@ export type SearchEventsParams = {
/** /**
* The starting date of the creation date range in IS:yyyy-MM-dd format * 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 * 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. * The number of features to skip when returning a page. By default it is set to 0.
*/ */

View File

@ -146,11 +146,8 @@ export default class EventService {
convertToDbParams = (params: IEventSearchParams): IQueryParam[] => { convertToDbParams = (params: IEventSearchParams): IQueryParam[] => {
const queryParams: IQueryParam[] = []; const queryParams: IQueryParam[] = [];
if (params.createdAtFrom) { if (params.from) {
const parsed = parseSearchOperatorValue( const parsed = parseSearchOperatorValue('created_at', params.from);
'created_at',
params.createdAtFrom,
);
if (parsed) { if (parsed) {
queryParams.push({ queryParams.push({
field: parsed.field, field: parsed.field,
@ -160,11 +157,8 @@ export default class EventService {
} }
} }
if (params.createdAtTo) { if (params.to) {
const parsed = parseSearchOperatorValue( const parsed = parseSearchOperatorValue('created_at', params.to);
'created_at',
params.createdAtTo,
);
if (parsed) { if (parsed) {
queryParams.push({ queryParams.push({
field: parsed.field, field: parsed.field,

View File

@ -57,7 +57,7 @@ export const eventSearchQueryParameters = [
in: 'query', in: 'query',
}, },
{ {
name: 'createdAtFrom', name: 'from',
schema: { schema: {
type: 'string', type: 'string',
example: 'IS:2024-01-01', example: 'IS:2024-01-01',
@ -68,7 +68,7 @@ export const eventSearchQueryParameters = [
in: 'query', in: 'query',
}, },
{ {
name: 'createdAtTo', name: 'to',
schema: { schema: {
type: 'string', type: 'string',
example: 'IS:2024-01-31', example: 'IS:2024-01-31',

View File

@ -9,8 +9,8 @@ export interface IEventSearchParams {
project?: string; project?: string;
query?: string; query?: string;
feature?: string; feature?: string;
createdAtFrom?: string; from?: string;
createdAtTo?: string; to?: string;
createdBy?: string; createdBy?: string;
type?: string; type?: string;
offset: number; offset: number;

View File

@ -228,7 +228,7 @@ test('should filter events by created date range', async () => {
const today = new Date(); const today = new Date();
const { body } = await searchEvents({ const { body } = await searchEvents({
createdAtFrom: `IS:${today.toISOString().split('T')[0]}`, from: `IS:${today.toISOString().split('T')[0]}`,
}); });
expect(body).toMatchObject({ expect(body).toMatchObject({