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

Popular Events Hook #66

Open
johanneslil opened this issue Jun 18, 2021 · 2 comments
Open

Popular Events Hook #66

johanneslil opened this issue Jun 18, 2021 · 2 comments
Labels
feature New features hook React Hooks

Comments

@johanneslil
Copy link
Member

To fetch popular events from the server we need an associated hook. Passing arguments could be:

  • nation, optional (defaults to all nations)
  • category, optional (defaults to all categories)
  • amount (this should have a limit ofc)
  • end_date (defining the timespan from today until the latest allowed date of an event. Also, find a better name for this one maybe)
@johanneslil johanneslil added the hook React Hooks label Jun 18, 2021
@Frewacom
Copy link
Member

Frewacom commented Jun 18, 2021

Do you think adding an additional parameter to the existing useEvents hook would suffice? It already has support for all of the options that you mention (and some more).

Usage would be something like this:

// Pass in null as first argument to fetch for all nations,
// or you can specify an array of nations to exclude using `excludeOids`
const result = useEvents(null, {
    // before: new Date(..),
    // after: new Date(..),
    // or whatever time filtering you want to use 
    // 
    // Specify the initial amount of events to load (per page) 
    amount: 5,
    //
    // This will be the new parameter
    sortBy: 'popularity' 
})

The sortBy option will default to none (just like the current hook) and will allow you to manually specify how you want the events ordered. Doing it like this means that we can easily add new types of sorting for events in the future.

@Frewacom Frewacom added the feature New features label Jun 18, 2021
@johanneslil
Copy link
Member Author

Great idea! That simplifies things in several ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New features hook React Hooks
Projects
None yet
Development

No branches or pull requests

2 participants