Skip to content

Commit

Permalink
More fixes, changes and migrations
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Jul 16, 2024
1 parent 13db0e3 commit d027eea
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 101 deletions.
5 changes: 5 additions & 0 deletions packages/api-client/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Alert,
BeaconState,
BuildingMap,
DeliveryAlert,
DispenserState,
DoorState,
FleetState,
Expand Down Expand Up @@ -103,6 +104,10 @@ export class SioClient {
subscribeAlerts(listener: Listener<Alert>): Subscription {
return this.subscribe<Alert>(`/alerts`, listener);
}

subscribeDeliveryAlerts(listener: Listener<DeliveryAlert>): Subscription {
return this.subscribe<DeliveryAlert>('/delivery_alerts', listener);
}
}

export * from './openapi';
56 changes: 43 additions & 13 deletions packages/api-client/lib/openapi/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10526,7 +10526,9 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
* @param {string | null} [assignedTo] comma separated list of assigned robot names
* @param {string | null} [status] comma separated list of statuses
* @param {string | null} [label] comma separated list of labels, each item must be in the form &lt;key&gt;&#x3D;&lt;value&gt;, multiple items will filter tasks with all the labels
* @param {string} [timeBetween] 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} [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 start 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 finish 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 {number | null} [limit] defaults to 100
* @param {number | null} [offset] defaults to 0
* @param {string | null} [orderBy] common separated list of fields to order by, prefix with \&#39;-\&#39; to sort descendingly.
Expand All @@ -10541,7 +10543,9 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
assignedTo?: string | null,
status?: string | null,
label?: string | null,
timeBetween?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number | null,
offset?: number | null,
orderBy?: string | null,
Expand Down Expand Up @@ -10584,8 +10588,16 @@ export const TasksApiAxiosParamCreator = function (configuration?: Configuration
localVarQueryParameter['label'] = label;
}

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

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

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

if (limit !== undefined) {
Expand Down Expand Up @@ -11473,7 +11485,9 @@ export const TasksApiFp = function (configuration?: Configuration) {
* @param {string | null} [assignedTo] comma separated list of assigned robot names
* @param {string | null} [status] comma separated list of statuses
* @param {string | null} [label] comma separated list of labels, each item must be in the form &lt;key&gt;&#x3D;&lt;value&gt;, multiple items will filter tasks with all the labels
* @param {string} [timeBetween] 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} [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 start 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 finish 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 {number | null} [limit] defaults to 100
* @param {number | null} [offset] defaults to 0
* @param {string | null} [orderBy] common separated list of fields to order by, prefix with \&#39;-\&#39; to sort descendingly.
Expand All @@ -11488,7 +11502,9 @@ export const TasksApiFp = function (configuration?: Configuration) {
assignedTo?: string | null,
status?: string | null,
label?: string | null,
timeBetween?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number | null,
offset?: number | null,
orderBy?: string | null,
Expand All @@ -11502,7 +11518,9 @@ export const TasksApiFp = function (configuration?: Configuration) {
assignedTo,
status,
label,
timeBetween,
requestTimeBetween,
startTimeBetween,
finishTimeBetween,
limit,
offset,
orderBy,
Expand Down Expand Up @@ -12013,7 +12031,9 @@ export const TasksApiFactory = function (
* @param {string | null} [assignedTo] comma separated list of assigned robot names
* @param {string | null} [status] comma separated list of statuses
* @param {string | null} [label] comma separated list of labels, each item must be in the form &lt;key&gt;&#x3D;&lt;value&gt;, multiple items will filter tasks with all the labels
* @param {string} [timeBetween] 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} [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 start 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 finish 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 {number | null} [limit] defaults to 100
* @param {number | null} [offset] defaults to 0
* @param {string | null} [orderBy] common separated list of fields to order by, prefix with \&#39;-\&#39; to sort descendingly.
Expand All @@ -12028,7 +12048,9 @@ export const TasksApiFactory = function (
assignedTo?: string | null,
status?: string | null,
label?: string | null,
timeBetween?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number | null,
offset?: number | null,
orderBy?: string | null,
Expand All @@ -12043,7 +12065,9 @@ export const TasksApiFactory = function (
assignedTo,
status,
label,
timeBetween,
requestTimeBetween,
startTimeBetween,
finishTimeBetween,
limit,
offset,
orderBy,
Expand Down Expand Up @@ -12578,7 +12602,9 @@ export class TasksApi extends BaseAPI {
* @param {string | null} [assignedTo] comma separated list of assigned robot names
* @param {string | null} [status] comma separated list of statuses
* @param {string | null} [label] comma separated list of labels, each item must be in the form &lt;key&gt;&#x3D;&lt;value&gt;, multiple items will filter tasks with all the labels
* @param {string} [timeBetween] 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} [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 start 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 finish 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 {number | null} [limit] defaults to 100
* @param {number | null} [offset] defaults to 0
* @param {string | null} [orderBy] common separated list of fields to order by, prefix with \&#39;-\&#39; to sort descendingly.
Expand All @@ -12594,7 +12620,9 @@ export class TasksApi extends BaseAPI {
assignedTo?: string | null,
status?: string | null,
label?: string | null,
timeBetween?: string,
requestTimeBetween?: string,
startTimeBetween?: string,
finishTimeBetween?: string,
limit?: number | null,
offset?: number | null,
orderBy?: string | null,
Expand All @@ -12609,7 +12637,9 @@ export class TasksApi extends BaseAPI {
assignedTo,
status,
label,
timeBetween,
requestTimeBetween,
startTimeBetween,
finishTimeBetween,
limit,
offset,
orderBy,
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// THIS FILE IS GENERATED
export const version = {
rmfServer: 'c9b81b6abf171879765e02019942d41919359d58',
rmfServer: '13db0e386c955fb5ba140f91d27b595875088579',
openapiGenerator: '',
};
30 changes: 28 additions & 2 deletions packages/api-client/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,18 +886,44 @@ export default {
'comma separated list of labels, each item must be in the form <key>=<value>, multiple items will filter tasks with all the labels',
},
{
name: 'time_between',
name: 'request_time_between',
in: 'query',
required: false,
schema: {
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 ',
title: 'Time Between',
title: 'Request Time Between',
},
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: 'start_time_between',
in: 'query',
required: false,
schema: {
type: 'string',
description:
'\n The period of start 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 ',
title: 'Start Time Between',
},
description:
'\n The period of start 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: 'finish_time_between',
in: 'query',
required: false,
schema: {
type: 'string',
description:
'\n The period of finish 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 ',
title: 'Finish Time Between',
},
description:
'\n The period of finish 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: 'limit',
in: 'query',
Expand Down
72 changes: 67 additions & 5 deletions packages/api-server/api_server/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def between_query(
return period


def time_between_query(
time_between: str = Query(
def request_time_between_query(
request_time_between: str = Query(
None,
description="""
The period of request time to fetch, in unix millis.
Expand All @@ -61,16 +61,78 @@ def time_between_query(
),
now: int = Depends(ros_time.now),
) -> tuple[datetime, datetime] | None:
if time_between is None:
if request_time_between is None:
return None
if time_between.startswith("-"):
if request_time_between.startswith("-"):
# Cap at 0 millis
period = (
datetime.fromtimestamp(0),
datetime.fromtimestamp(now / 1000),
)
else:
parts = time_between.split(",")
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,
description="""
The period of start 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(ros_time.now),
) -> tuple[datetime, datetime] | None:
if start_time_between is None:
return None
if start_time_between.startswith("-"):
# Cap at 0 millis
period = (
datetime.fromtimestamp(0),
datetime.fromtimestamp(now / 1000),
)
else:
parts = start_time_between.split(",")
period = (
datetime.fromtimestamp(int(parts[0]) / 1000),
datetime.fromtimestamp(int(parts[1]) / 1000),
)
return period


def finish_time_between_query(
finish_time_between: str = Query(
None,
description="""
The period of finish 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(ros_time.now),
) -> tuple[datetime, datetime] | None:
if finish_time_between is None:
return None
if finish_time_between.startswith("-"):
# Cap at 0 millis
period = (
datetime.fromtimestamp(0),
datetime.fromtimestamp(now / 1000),
)
else:
parts = finish_time_between.split(",")
period = (
datetime.fromtimestamp(int(parts[0]) / 1000),
datetime.fromtimestamp(int(parts[1]) / 1000),
Expand Down
14 changes: 10 additions & 4 deletions packages/api-server/api_server/routes/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
from reactivex import operators as rxops

from api_server import models as mdl
from api_server.dependencies import between_query, pagination_query, time_between_query
from api_server.dependencies import (
between_query,
finish_time_between_query,
pagination_query,
request_time_between_query,
start_time_between_query,
)
from api_server.fast_io import FastIORouter, SubscriptionRequest
from api_server.logging import LoggerAdapter, default_logger, get_logger
from api_server.repositories import RmfRepository, TaskRepository
Expand Down Expand Up @@ -72,7 +78,7 @@ async def query_task_states(
str | None, Query(description="comma separated list of task categories")
] = None,
request_time_between: Annotated[
tuple[datetime, datetime] | None, Depends(time_between_query)
tuple[datetime, datetime] | None, Depends(request_time_between_query)
] = None,
requester: Annotated[
str | None, Query(description="comma separated list of requester names")
Expand All @@ -82,10 +88,10 @@ async def query_task_states(
Query(description="comma separated list of assigned robot names"),
] = None,
start_time_between: Annotated[
tuple[datetime, datetime] | None, Depends(time_between_query)
tuple[datetime, datetime] | None, Depends(start_time_between_query)
] = None,
finish_time_between: Annotated[
tuple[datetime, datetime] | None, Depends(time_between_query)
tuple[datetime, datetime] | None, Depends(finish_time_between_query)
] = None,
status: Annotated[
str | None, Query(description="comma separated list of statuses")
Expand Down
Loading

0 comments on commit d027eea

Please sign in to comment.