mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-10 04:00:11 +00:00
get pagecount as well
This commit is contained in:
parent
66e2851c5d
commit
8752bcca28
2 changed files with 20 additions and 6 deletions
|
|
@ -15,10 +15,10 @@ export const queue = async (batch: MessageBatch, env: Env): Promise<void> => {
|
|||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}).then((res) => res.json())) as { limit: number; tweetsCount: number; user: string };
|
||||
}).then((res) => res.json())) as { tweetsLimit: number; tweetsCount: number; user: string };
|
||||
|
||||
if (messages.length > limits.limit - limits.tweetsCount) {
|
||||
messages.splice(limits.limit - limits.tweetsCount);
|
||||
if (messages.length > limits.tweetsLimit - limits.tweetsCount) {
|
||||
messages.splice(limits.tweetsLimit - limits.tweetsCount);
|
||||
}
|
||||
|
||||
if (messages.length === 0) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export async function GET(req: NextRequest) {
|
|||
|
||||
const session = { session: sessionData[0], user: user[0] };
|
||||
|
||||
const count = await db
|
||||
const tweetsCount = await db
|
||||
.select({
|
||||
count: sql<number>`count(*)`.mapWith(Number),
|
||||
})
|
||||
|
|
@ -58,9 +58,23 @@ export async function GET(req: NextRequest) {
|
|||
),
|
||||
);
|
||||
|
||||
const pageCount = await db
|
||||
.select({
|
||||
count: sql<number>`count(*)`.mapWith(Number),
|
||||
})
|
||||
.from(storedContent)
|
||||
.where(
|
||||
and(
|
||||
eq(storedContent.user, session.user.id),
|
||||
eq(storedContent.type, "page"),
|
||||
),
|
||||
);
|
||||
|
||||
return NextResponse.json({
|
||||
tweetsCount: count[0].count,
|
||||
limit: 1000,
|
||||
tweetsCount: tweetsCount[0].count,
|
||||
tweetsLimit: 1000,
|
||||
pageCount: pageCount[0].count,
|
||||
pageLimit: 100,
|
||||
user: session.user.email,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue