Skip to content

Commit

Permalink
Server-side sort and filter pickup and destination (#847)
Browse files Browse the repository at this point in the history
* Adding pickup and destionation to ttm task state model for filter and sorting purposes, generated query api

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>

* Lint

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>

---------

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth authored Nov 29, 2023
1 parent 81ebbe3 commit d85661b
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 12 deletions.
60 changes: 60 additions & 0 deletions packages/api-client/lib/openapi/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9131,8 +9131,12 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
* @summary Query Task States
* @param {string} [taskId] comma separated list of task ids
* @param {string} [category] comma separated list of task categories
* @param {string} [requester] comma separated list of requester names
* @param {string} [pickup] comma separated list of pickup names
* @param {string} [destination] comma separated list of destination names
* @param {string} [assignedTo] comma separated list of assigned robot names
* @param {string} [status] comma separated list of statuses
* @param {string} [requestTimeBetween] The period of request time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [startTimeBetween] The period of starting time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [finishTimeBetween] The period of finishing time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000. \&quot;-60000\&quot; - Fetches logs in the last minute.
* @param {number} [limit] defaults to 100
Expand All @@ -9144,8 +9148,12 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
queryTaskStatesTasksGet: async (
taskId?: string,
category?: string,
requester?: string,
pickup?: string,
destination?: string,
assignedTo?: string,
status?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number,
Expand Down Expand Up @@ -9173,6 +9181,18 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
localVarQueryParameter['category'] = category;
}

if (requester !== undefined) {
localVarQueryParameter['requester'] = requester;
}

if (pickup !== undefined) {
localVarQueryParameter['pickup'] = pickup;
}

if (destination !== undefined) {
localVarQueryParameter['destination'] = destination;
}

if (assignedTo !== undefined) {
localVarQueryParameter['assigned_to'] = assignedTo;
}
Expand All @@ -9181,6 +9201,10 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
localVarQueryParameter['status'] = status;
}

if (requestTimeBetween !== undefined) {
localVarQueryParameter['request_time_between'] = requestTimeBetween;
}

if (startTimeBetween !== undefined) {
localVarQueryParameter['start_time_between'] = startTimeBetween;
}
Expand Down Expand Up @@ -9730,8 +9754,12 @@ export const TasksApiFp = function (configuration?: Configuration) {
* @summary Query Task States
* @param {string} [taskId] comma separated list of task ids
* @param {string} [category] comma separated list of task categories
* @param {string} [requester] comma separated list of requester names
* @param {string} [pickup] comma separated list of pickup names
* @param {string} [destination] comma separated list of destination names
* @param {string} [assignedTo] comma separated list of assigned robot names
* @param {string} [status] comma separated list of statuses
* @param {string} [requestTimeBetween] The period of request time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [startTimeBetween] The period of starting time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [finishTimeBetween] The period of finishing time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000. \&quot;-60000\&quot; - Fetches logs in the last minute.
* @param {number} [limit] defaults to 100
Expand All @@ -9743,8 +9771,12 @@ export const TasksApiFp = function (configuration?: Configuration) {
async queryTaskStatesTasksGet(
taskId?: string,
category?: string,
requester?: string,
pickup?: string,
destination?: string,
assignedTo?: string,
status?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number,
Expand All @@ -9755,8 +9787,12 @@ export const TasksApiFp = function (configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.queryTaskStatesTasksGet(
taskId,
category,
requester,
pickup,
destination,
assignedTo,
status,
requestTimeBetween,
startTimeBetween,
finishTimeBetween,
limit,
Expand Down Expand Up @@ -10165,8 +10201,12 @@ export const TasksApiFactory = function (
* @summary Query Task States
* @param {string} [taskId] comma separated list of task ids
* @param {string} [category] comma separated list of task categories
* @param {string} [requester] comma separated list of requester names
* @param {string} [pickup] comma separated list of pickup names
* @param {string} [destination] comma separated list of destination names
* @param {string} [assignedTo] comma separated list of assigned robot names
* @param {string} [status] comma separated list of statuses
* @param {string} [requestTimeBetween] The period of request time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [startTimeBetween] The period of starting time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [finishTimeBetween] The period of finishing time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000. \&quot;-60000\&quot; - Fetches logs in the last minute.
* @param {number} [limit] defaults to 100
Expand All @@ -10178,8 +10218,12 @@ export const TasksApiFactory = function (
queryTaskStatesTasksGet(
taskId?: string,
category?: string,
requester?: string,
pickup?: string,
destination?: string,
assignedTo?: string,
status?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number,
Expand All @@ -10191,8 +10235,12 @@ export const TasksApiFactory = function (
.queryTaskStatesTasksGet(
taskId,
category,
requester,
pickup,
destination,
assignedTo,
status,
requestTimeBetween,
startTimeBetween,
finishTimeBetween,
limit,
Expand Down Expand Up @@ -10625,8 +10673,12 @@ export class TasksApi extends BaseAPI {
* @summary Query Task States
* @param {string} [taskId] comma separated list of task ids
* @param {string} [category] comma separated list of task categories
* @param {string} [requester] comma separated list of requester names
* @param {string} [pickup] comma separated list of pickup names
* @param {string} [destination] comma separated list of destination names
* @param {string} [assignedTo] comma separated list of assigned robot names
* @param {string} [status] comma separated list of statuses
* @param {string} [requestTimeBetween] The period of request time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [startTimeBetween] The period of starting time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000.
* @param {string} [finishTimeBetween] The period of finishing time to fetch, in unix millis. This must be a comma separated string, \&#39;X,Y\&#39; to fetch between X millis and Y millis inclusive. Example: \&quot;1000,2000\&quot; - Fetches logs between unix millis 1000 and 2000. \&quot;-60000\&quot; - Fetches logs in the last minute.
* @param {number} [limit] defaults to 100
Expand All @@ -10639,8 +10691,12 @@ export class TasksApi extends BaseAPI {
public queryTaskStatesTasksGet(
taskId?: string,
category?: string,
requester?: string,
pickup?: string,
destination?: string,
assignedTo?: string,
status?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number,
Expand All @@ -10652,8 +10708,12 @@ export class TasksApi extends BaseAPI {
.queryTaskStatesTasksGet(
taskId,
category,
requester,
pickup,
destination,
assignedTo,
status,
requestTimeBetween,
startTimeBetween,
finishTimeBetween,
limit,
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models';

export const version = {
rmfModels: rmfModelVer,
rmfServer: '1970313b2544aa6fb1ee65c9356f2eface9b174b',
rmfServer: '4f6e8567a0a3a44896f60898e84130c2be8a94c7',
openapiGenerator: '6.2.1',
};
46 changes: 46 additions & 0 deletions packages/api-client/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,39 @@ export default {
name: 'category',
in: 'query',
},
{
description: 'comma separated list of requester names',
required: false,
schema: {
title: 'Requester',
type: 'string',
description: 'comma separated list of requester names',
},
name: 'requester',
in: 'query',
},
{
description: 'comma separated list of pickup names',
required: false,
schema: {
title: 'Pickup',
type: 'string',
description: 'comma separated list of pickup names',
},
name: 'pickup',
in: 'query',
},
{
description: 'comma separated list of destination names',
required: false,
schema: {
title: 'Destination',
type: 'string',
description: 'comma separated list of destination names',
},
name: 'destination',
in: 'query',
},
{
description: 'comma separated list of assigned robot names',
required: false,
Expand All @@ -875,6 +908,19 @@ export default {
name: 'status',
in: 'query',
},
{
description:
'\n The period of request time to fetch, in unix millis.\n\n This must be a comma separated string, \'X,Y\' to fetch between X millis and Y millis inclusive.\n\n Example:\n "1000,2000" - Fetches logs between unix millis 1000 and 2000.\n ',
required: false,
schema: {
title: 'Request Time Between',
type: 'string',
description:
'\n The period of request time to fetch, in unix millis.\n\n This must be a comma separated string, \'X,Y\' to fetch between X millis and Y millis inclusive.\n\n Example:\n "1000,2000" - Fetches logs between unix millis 1000 and 2000.\n ',
},
name: 'request_time_between',
in: 'query',
},
{
description:
'\n The period of starting time to fetch, in unix millis.\n\n This must be a comma separated string, \'X,Y\' to fetch between X millis and Y millis inclusive.\n\n Example:\n "1000,2000" - Fetches logs between unix millis 1000 and 2000.\n ',
Expand Down
31 changes: 31 additions & 0 deletions packages/api-server/api_server/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,37 @@ def between_query(
return period


def request_time_between_query(
request_time_between: str = Query(
None,
description="""
The period of request time to fetch, in unix millis.
This must be a comma separated string, 'X,Y' to fetch between X millis and Y millis inclusive.
Example:
"1000,2000" - Fetches logs between unix millis 1000 and 2000.
""",
),
now: int = Depends(clock.now),
) -> Tuple[datetime, datetime] | None:
if request_time_between is None:
return None
if request_time_between.startswith("-"):
# Cap at 0 millis
period = (
datetime.fromtimestamp(0),
datetime.fromtimestamp(now / 1000),
)
else:
parts = request_time_between.split(",")
period = (
datetime.fromtimestamp(int(parts[0]) / 1000),
datetime.fromtimestamp(int(parts[1]) / 1000),
)
return period


def start_time_between_query(
start_time_between: str = Query(
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class TaskState(Model):
unix_millis_request_time = DatetimeField(null=True, index=True)
requester = CharField(255, null=True, index=True)
unix_millis_warn_time = DatetimeField(null=True, index=True)
pickup = CharField(255, null=True, index=True)
destination = CharField(255, null=True, index=True)


class TaskEventLog(Model):
Expand Down
Loading

0 comments on commit d85661b

Please sign in to comment.