socket setup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { desc, lte, sql } from "drizzle-orm";
|
||||
import { desc, gte, sql } from "drizzle-orm";
|
||||
import { Router } from "express";
|
||||
import { open } from "inspector/promises";
|
||||
import { db } from "../db/db.controller.js";
|
||||
import { opendockApt } from "../db/schema/opendock.schema.js";
|
||||
import { apiReturn } from "../utils/returnHelper.utils.js";
|
||||
@@ -11,11 +10,18 @@ const r = Router();
|
||||
r.get("/", async (_, res) => {
|
||||
//const limit
|
||||
|
||||
const { data, error } = await tryCatch(
|
||||
const daysCreated = 30;
|
||||
|
||||
const { data } = await tryCatch(
|
||||
db
|
||||
.select()
|
||||
.from(opendockApt)
|
||||
.where(lte(opendockApt.createdAt, sql.raw(`NOW() - INTERVAL '30 days'`)))
|
||||
.where(
|
||||
gte(
|
||||
opendockApt.createdAt,
|
||||
sql.raw(`NOW() - INTERVAL '${daysCreated} days'`),
|
||||
),
|
||||
)
|
||||
.orderBy(desc(opendockApt.createdAt))
|
||||
.limit(500),
|
||||
);
|
||||
@@ -25,7 +31,7 @@ r.get("/", async (_, res) => {
|
||||
level: "info",
|
||||
module: "opendock",
|
||||
subModule: "apt",
|
||||
message: "The first x Apt",
|
||||
message: `The first ${data?.length} Apt(s) that were created in the last ${daysCreated} `,
|
||||
data: data ?? [],
|
||||
status: 200,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user