-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: dev
Are you sure you want to change the base?
Conversation
7202a9f
to
e270915
Compare
e270915
to
170844c
Compare
// 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(), | ||
}, | ||
}, |
There was a problem hiding this comment.
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 }) { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
since: Type.Optional( | ||
Type.Date({ | ||
description: "If set, only events starting after this date are included.", | ||
}), | ||
), |
There was a problem hiding this comment.
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
)
No description provided.