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

Add /next-hour endpoint #57

Closed
wants to merge 2 commits into from

Conversation

ebanner
Copy link
Contributor

@ebanner ebanner commented Jul 26, 2024

In order to have 60 minute event reminders (TampaDevs/events-slack-push#2), this PR adds a /next-hour endpoint to show meetups happening in the next hour

@ebanner ebanner marked this pull request as draft July 26, 2024 13:53
@@ -88,6 +111,14 @@
return res;
}

if (url.pathname == '/next-hour') {
for (const [key, value] of Object.entries(eventData)) {
const upcomingEvents = value.eventSearch.edges.filter(isLessThanOneHourIntoFuture)

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (95% of all statements in
the enclosing function
have an explicit semicolon).
@@ -88,6 +111,14 @@
return res;
}

if (url.pathname == '/next-hour') {
for (const [key, value] of Object.entries(eventData)) {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable key.
@ebanner
Copy link
Contributor Author

ebanner commented Jul 26, 2024

Closing because it seems unnecessary to add an endpoint since we're hitting the API pretty infrequently and we can just do the filtering on the ruby/client side

@chtzvt
Copy link
Member

chtzvt commented Jul 28, 2024

@ebanner I agree with your previous comment, but I do think that date-based filters would be a useful addition to the API.

That said, I would recommend a slightly modified approach to what was included in this PR-- rather than a single endpoint that can be only for a particular use case (events within the next hour), what I'd prefer to see would look like a pair of query parameter filters:

  • within_hours: Specifies an integer number of hours that upcoming events must fall within (the next 1 hour, the next 48 hours, etc), and
  • within_days: Specifies an integer number of days to filter the upcoming events list.

With these:

  • The upcoming hourly event reminders are satisfied:
    • https://events.api.tampa.dev/?within_hours=1
  • So too are the weekly summaries:
    • https://events.api.tampa.dev/?within_days=14

This not only satisfies the original use case, but it also provides a pretty flexible utility filter that lets downstream consumers avoid doing at least some (if not most of) the date-based filtering themselves.

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