debug test error

This commit is contained in:
Hongbo Wu 2023-09-17 22:09:07 +08:00
parent a284884398
commit 2b9a6b26f6
3 changed files with 14 additions and 10 deletions

View file

@ -8,7 +8,7 @@
],
"license": "UNLICENSED",
"scripts": {
"test": "lerna run --no-bail test --ignore @omnivore/web",
"test": "lerna run test --ignore @omnivore/web",
"lint": "lerna run lint --ignore @omnivore/web",
"build": "lerna run build --ignore @omnivore/web",
"bootstrap": "lerna bootstrap",

View file

@ -45,7 +45,7 @@ const isPrivateIP = privateIpLib.default
const getPriorityByRateLimit = async (
userId: string
): Promise<'low' | 'high'> => {
const count = await countByCreatedAt(new Date(Date.now() - 60 * 1000))
const count = await countByCreatedAt(userId, new Date(Date.now() - 60 * 1000))
return count >= 5 ? 'low' : 'high'
}

View file

@ -427,17 +427,21 @@ export const findLibraryItemsByPrefix = async (
}
export const countByCreatedAt = async (
userId: string,
startDate = new Date(0),
endDate = new Date()
): Promise<number> => {
return authTrx(async (tx) =>
tx
.createQueryBuilder(LibraryItem, 'library_item')
.where('library_item.created_at between :startDate and :endDate', {
startDate,
endDate,
})
.getCount()
return authTrx(
async (tx) =>
tx
.createQueryBuilder(LibraryItem, 'library_item')
.where('library_item.created_at between :startDate and :endDate', {
startDate,
endDate,
})
.getCount(),
undefined,
userId
)
}