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: add reminders/upcoming API #5783

Merged
merged 1 commit into from
Jan 6, 2022

Conversation

nhymxu
Copy link

@nhymxu nhymxu commented Dec 20, 2021

Close #5778

Docs close monicahq/marketing_site#642

General checks

  • Make sure that the change you propose is the smallest possible.
  • The name of the PR should follow the conventional commits guideline that the project follows.

Backend/models changes

  • The API has been updated.
  • API's documentation has been added by submitting a pull request in the marketing website repository.
  • Tests have been added for the new code.

Usage

  1. Get upcoming reminders for current month
GET /api/reminders/upcoming

or

GET /api/reminders/upcoming/0
  1. Get upcoming reminders for next month (month+1)
GET /api/reminders/upcoming/1
  1. Get upcoming reminders for next n month (month+n)
GET /api/reminders/upcoming/n

Comment on lines 168 to 181
public function upcoming(Request $request, int $month = 0)
{
try {
$reminders = AccountHelper::getUpcomingRemindersForMonth(
auth()->user()->account,
$month
)->pluck('reminder');
} catch (QueryException $e) {
return $this->respondInvalidQuery();
}

return ReminderResource::collection($reminders);
}
Copy link
Author

Choose a reason for hiding this comment

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

I'm thinking about copy content of AccountHelper::getUpcomingRemindersForMonth() to here,
and replace ->get() with ->pagination().

But it's more complicated, and ?limit=xxx not work correctly as I expected.
So I create simple PR like this, get all upcoming event in target month.

If anyone have better idea, feel free to tell me.

@nhymxu nhymxu marked this pull request as ready for review December 20, 2021 15:01
Copy link
Member

@asbiin asbiin left a comment

Choose a reason for hiding this comment

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

Thank you @nhymxu this is great.
See my comment.

@nhymxu
Copy link
Author

nhymxu commented Jan 3, 2022

@asbiin
I rebased and force push to resolve conflict on api.php file.

About your comment, please consider my idea.
If you still want limit $month. Please confirm again, I will add it ASAP.

Thank you

@asbiin asbiin merged commit a3e9b79 into monicahq:master Jan 6, 2022
@github-actions
Copy link

🎉 This PR is included in version 3.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upcoming event for reminders api
2 participants