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

Adding the endpoint to filter by month and week #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alejandroGonGon
Copy link

About

Filtering by month and week.

@LautaroPardo0210
Copy link
Member

Task linked: CU-20y76fa Add filters to Petitions

Copy link
Member

@nicocadq nicocadq left a comment

Choose a reason for hiding this comment

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

Nice job man! Just left you a little comment

routes/api.php Outdated
Comment on lines 37 to 38
Route::get('/petitions/filter-month', [PetitionController::class, 'filterByMonth']);
Route::get('/petitions/filter-week', [PetitionController::class, 'filterByWeek']);
Copy link
Member

Choose a reason for hiding this comment

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

It should be all at the same endpoint, like:

/petitions?time="week"

or

/petitions?time="month"

Copy link
Author

Choose a reason for hiding this comment

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

Done

Comment on lines 36 to +37
Route::get('/petitions', [PetitionController::class, 'index']);
Route::get('/petitions/filter', [PetitionController::class, 'filter']);
Copy link
Member

Choose a reason for hiding this comment

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

This filter stuff should be done at the endpoint /petitions and the params should be time_period

Copy link
Author

Choose a reason for hiding this comment

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

Done

Comment on lines 26 to 27
if ($time_period === "week") {
$byweek = Petition::whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])->get();
Copy link
Member

Choose a reason for hiding this comment

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

Missing pagination on this responses

Copy link

@agongon agongon Apr 8, 2022

Choose a reason for hiding this comment

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

ODYWBDAIWBTOTKY

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.

5 participants