Skip to content

Commit

Permalink
cant see what in the past
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampouse committed Jan 7, 2025
1 parent d496e77 commit fb8297f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/api/EndPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ export const getEvents = async ({
}) => {
try {
const user = await GetUser({ event });

console.log("you cant be null ", user);
if (user === null || user === undefined) {
return { success: false, data: null, error: "Failed to get events" };
}

const data = await QueryEvents({
event,
options: { ...options, byUser: user?.ID },
options: { ...options, byUser: user.ID },
});

if (data === null) {
Expand Down
8 changes: 5 additions & 3 deletions src/api/Query.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Users, Events, Requests, Places } from "../../drizzle/schema";
import type { Session } from "./drizzled";
import { eq, and, ne, or, not, exists } from "drizzle-orm";
import { eq, and, ne, or, not, exists, gte } from "drizzle-orm";
import type { Requested } from "./drizzled";
import { drizzler } from "./drizzled";
import type { UpdateUserForm, CreateEventForm } from "~/api/Forms";
Expand Down Expand Up @@ -249,6 +249,7 @@ export type QueryEventOptions = {
to?: Date;
byUser?: number;
active?: boolean;
fromDateTime?: Date;
};

export const QueryEvent = async (params: {
Expand All @@ -275,13 +276,13 @@ export const QueryEvent = async (params: {
image: Events.ImageURL,
})
.from(Events)
.where(eq(Events.EventID, params.id))
.where(and(eq(Events.EventID, params.id)))

.execute()
.catch((e) => {
console.log(e);
return null;
});

if (event && event.length > 0) {
const user = await Client.select()
.from(Users)
Expand Down Expand Up @@ -338,6 +339,7 @@ export const QueryEvents = async (params: {
),
),
ne(Events.UserID, params.options.byUser as number),
gte(Events.Date, new Date().toISOString()),
),
)
.limit(params.options.limit ?? 3)
Expand Down

0 comments on commit fb8297f

Please sign in to comment.