fix integration handler to use first as number

This commit is contained in:
Hongbo Wu 2023-12-06 14:44:07 +08:00
parent 9e1c656506
commit dff2376df3
3 changed files with 5 additions and 6 deletions

View file

@ -39,7 +39,6 @@ enum HasFilter {
export interface SearchArgs {
from?: number
size?: number
sort?: Sort
includePending?: boolean | null
includeDeleted?: boolean
includeContent?: boolean
@ -389,14 +388,14 @@ export const buildQuery = (
// validate date
if (start && start !== '*') {
startDate = new Date(start)
if (!startDate.getTime()) {
if (isNaN(startDate.getTime())) {
throw new Error('Invalid start date.')
}
}
if (end && end !== '*') {
endDate = new Date(end)
if (!endDate.getTime()) {
if (isNaN(endDate.getTime())) {
throw new Error('Invalid end date.')
}
}
@ -695,7 +694,7 @@ export const searchLibraryItems = async (
const count = await queryBuilder.getCount()
// default order by saved at descending
if (orders.length === 0) {
if (!orders.find((order) => order.by === 'library_item.saved_at')) {
orders.push({
by: 'library_item.saved_at',
order: SortOrder.DESCENDING,

View file

@ -97,7 +97,7 @@ export const exporter = Sentry.GCPFunction.wrapHttpFunction(
const client = getIntegrationClient(integrationName)
// get paginated items from the backend
const first = '50'
const first = 50
let hasMore = true
let after = '0'
while (hasMore) {

View file

@ -44,7 +44,7 @@ export const search = async (
token: string,
highlightOnly: boolean,
updatedSince: Date,
first = '50',
first = 50,
after = '0'
): Promise<SearchResponse | null> => {
const query = `updated:${updatedSince.toISOString()} ${