Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow user scope to view old events #153

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

joonatanaatos
Copy link

No description provided.

@joonatanaatos joonatanaatos force-pushed the allow-user-scope-to-view-old-events branch from 7202a9f to e270915 Compare October 24, 2024 13:17
@joonatanaatos joonatanaatos force-pushed the allow-user-scope-to-view-old-events branch from e270915 to 170844c Compare October 24, 2024 14:02
Comment on lines -214 to -227
// and either:
[Op.or]: {
// closed less than a week ago
registrationEndDate: {
[Op.gt]: moment().subtract(7, "days").toDate(),
},
// or happened less than a week ago
date: {
[Op.gt]: moment().subtract(7, "days").toDate(),
},
endDate: {
[Op.gt]: moment().subtract(7, "days").toDate(),
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll still want a hard limit for regular users

@@ -24,8 +24,20 @@ function eventOrder(): Order {
export const eventsListForUserCached = createCache({
maxAgeMs: 1000,
maxPendingAgeMs: 2000,
async get(category?: string) {
const where = category ? { category } : {};
async get(options: { category?: string; since?: Date }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work with the current caching system, which compares the function argument with Object.is (using a Map)

}
if (since) {
filters.date = {
[Op.gt]: since,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Op.gte would probably be more exact

Comment on lines +41 to +45
since: Type.Optional(
Type.Date({
description: "If set, only events starting after this date are included.",
}),
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type.Date is a typebox extension, it doesn't actually parse the dates. You'll need to use Type.String with format: "date-time" and parse yourself (like we do in e.g. updateEvent)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants