Skip to content

Conversation

@rafalfilarecki
Copy link
Collaborator

Implement Server-Side Pagination and Enhance Car Search Filters

Overview

This update introduces server-side pagination to improve the performance of car search results while addressing critical issues with the filtering functionality.

Server-Side Pagination

  • New Backend Method: Added GetPaginatedCarsAsync in CarRepository for efficient data retrieval.
  • Page Size: Limited to 5 items per request to optimize performance.
  • Pagination Metadata: API responses now include metadata:
    {
        "cars": [...],
        "totalCount": number,
        "currentPage": number,
        "pageSize": number,
        "totalPages": number
    }
  • Frontend Enhancements:
    • Smooth pagination UI with page indicators.
    • Automatically scrolls to top on page change for better user experience.

Search Filters Improvements

  • Filter Options Enhancement:
    • Added a new endpoint (GET /api/Cars/filter-options) to fetch complete filter options (brands, models, years, fuel types, locations).
    • Dropdowns now show all available options, regardless of the current page of results.

Testing

The following scenarios have been tested:

  • Pagination across multiple pages with active filters.
  • Dynamic model dropdown updates when selecting brands.
  • Correct display of filter options regardless of current results.
  • Edge cases like empty results, last-page navigation, and filter combinations.

Copy link
Owner

@KwiatkowskiML KwiatkowskiML left a comment

Choose a reason for hiding this comment

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

LGTM

@KwiatkowskiML KwiatkowskiML merged commit b794327 into dev Jan 17, 2025
1 check passed
KwiatkowskiML added a commit that referenced this pull request Jan 17, 2025
* initial database implementation

* database schema

* additional fields in cars table: horsepower, engine capacity and fuel type

* add licence_plate to cars table

* add contact to integrator

* database v0.1

* update doc

* A huge mess - WIP

* functioning database api

* dev doc

* print db schema

* car and carprovider dtos

* Simple React Frontend (#4)

* A React frontend with a call to backend

* Authorization (#6)

* simple react frontend

* frontend auth working

* update created_at typed in database, make authorization work in backend, hide appsettings with secrets.

* readme and logout button

* update data models

* misspell

* remove lock json

* update gitignore

* fix readme

* fix README

* template->example env

* Generating offer endpoint (#9)

* database offers, base_price, insurances
*  get-offer endpoint

* Searchbar and filters (#7)

* simple react frontend

* frontend auth working

* update created_at typed in database, make authorization work in backend, hide appsettings with secrets.

* readme and logout button

* misspell

* fix readme

* Basic search functionality

* added filters

* fixed searching

* added pagination and changed reults layout

* improved file tree

* creating offer and redirecting to details page

* car details page

* changed place of getting offer

---------

Co-authored-by: WojciechMat <wmatsad@gmail.com>

* 10 get user id api and choose offer (#14)

* user controller and rental dto

* get user id by email

* authorization

* get offer fix

* get offer returning existing offers

* rentals refactor

* rentals refactor working api

* choose offer yet to finish

* Create Rental Endpoint (#17)

* Sending confirmation emails (#18)

* Making Confirmation Page Work Better (#19)

* fix the link page, make sure there are no duplicates in the database

* registration form and 10 minutes expiration

* 21 refactor repository (#25)

* mappers refactor

* repositiores refactor carscontroller2 working

* user controller v2

* get offer

* mappers turned static

* rentals controller

* auth controller 2

* getting rid of warnings

* removing unnecesary filter from get cars

* user controller small fix

* offers controller update

* unused endpoint

* api routes update, yet to test rentals and add auth

* auth controller

* bugfix rentals

* removed deprecated controllers

* transition to new controllers - not working yet

* rental confirmation bugfix

* final refactor and moved files

* 26 workers api (#28)

* rentals update

* all rentals

* database update

* get offer bugfix and datamodel update not tested yet

* get rentals bugfix

* get customer

* Update WebAPI/Controllers/CustomerController.cs

Co-authored-by: Wojciech Matejuk <74838859+WojciechMat@users.noreply.github.com>

* Update WebAPI/Controllers/CustomerController.cs

Co-authored-by: Wojciech Matejuk <74838859+WojciechMat@users.noreply.github.com>

* Update WebAPI/Controllers/WorkerController.cs

Co-authored-by: Wojciech Matejuk <74838859+WojciechMat@users.noreply.github.com>

* sql adjastment

* update of retrieving values from rental status table - yet to be finished

* simple changing of rental's status

* simple return logic fix

* filtering fixed

* basic return

* returns almost done yet to add all values to return object

* process return completed

* filtering the rentals in worker's controller

* finishing touches

---------

Co-authored-by: Wojciech Matejuk <74838859+WojciechMat@users.noreply.github.com>

* 22 wokrers view (#33)

Added workers view with return dialog, enabling workers to finalise returns.
Enabled Customers to return rented cars in Rental History.
---------

Authored-by: Rafal Filarecki <rafalfilarecki@gmail.com>

* 23 gcp deployment (#27)

* use environment variables for security and enabling deployment, remove old unnecessary data, add Dockerfile and stratup script

* almost-full deployment

* updated firebase rewrites so that it renders confrimation page, vite.config.js configured for local development

* frontend deployment documentation

* update doc with list of APIs to enable in GCP

* better example

* storage car images bucket

* Fully working storage bucket images in deployed version

* Fix example data after merge

* update doc: remove unnecessary step

* More logging, updated cors, fixed firebase configuration, specifically disable caching for current user api call

* 39 refactor price calculator (#47)

* calculate price interface

* chain of responsibilities pattern

* 45 sending confirmation mails after succesfull rental (#50)

* email service update, sending rental success mails, not working on local host and not tested yet

* removed unnecessary logs

* doubled api calls issue resolved

* sending email with placeholder link

* unnecessary logs deletion

* return started email confirmation

* sending invoice

* invioce fix

* 24 workers view (#51)

* workers view filtering and searching by brand and model using api

* employee user has access only to /worker/rentals

* Revert "24 workers view (#51)" (#57)

This reverts commit ef863ae.

* offer deletion service (#53)

* offer deletion service

* offer removal constants

* 35 prepare test scenarios (#56)

* PriceCalculatorTests

* RentalConfirmationService tests

* CarRepository tests

* Offers repository tests

* Rental repository unit tests

* user repository test

* workflow setup (#60)

* 24 workers view (#58)

* workers view filtering and searching by brand and model using api

* employee user has access only to /worker/rentals

* fixed confirmation email redirect

* added simple car availability in car price dialog

* null reference fix

* removed debug logs and translated polish to english

* improved worker rentals view and rental car cards, added brand and model filters instead of search bar

---------

Co-authored-by: kwiatkowskim <kwiatkowski.michal.2003@gmail.com>

* 43 access without logging in (#62)

* workers view filtering and searching by brand and model using api

* employee user has access only to /worker/rentals

* removed debug logs and translated polish to english

* improved worker rentals view and rental car cards, added brand and model filters instead of search bar

* basic access without logging; needs to be improved

* worker has no access to the browser

* unlogged user has access to a car details page, after logging in, the user is redirected to the car details page

* changed redirect to /login after logout

* 36 photo upload (#52)

* Upload photo to the cloud storage (local)

* deploy script

* add tests do dev deployment script

* return details with photo on worker's view

* added storage constants

---------

Co-authored-by: kwiatkowskim <kwiatkowski.michal.2003@gmail.com>

* 41 fix car search in the frontend (#63)

* filtering cars using api

* searching cars using api

* searching only by model available

* changed placeholder text

* 55 pagination (#64)

* added pagination to the browser

* fixed filter bug

* added order by before skiping in pagination to make sure that the returned data is in the same order

* added pagination in users rental history

* fixed car details and changed 'return car' button style

* sending emails restored

* added missing using statement

* fixed worker's view filters

* fixed browser model filtering

* added number of pages to pagination in the browser and rental history

* getting insuraces using WebAPI

* gps and child seat fix

* order by

---------

Co-authored-by: kwiatkowskim <kwiatkowski.michal.2003@gmail.com>

* 44 date of birth in user table (#69)

* initail migration

* initial migration sql script

* change age to birth date migration script

* context update and tests fixed

* authorization update

* Rental status fix

* Revert "44 date of birth in user table (#69)"

This reverts commit 495ff1f.

* initail migration

* initial migration sql script

* change age to birth date migration script

* context update and tests fixed

* authorization update

* Rental status fix

* 49 security and prod (#67)

* control car image storage through environment variables

* prod configuration and deployment pipeline

* update example

* make sure caching works

---------

Co-authored-by: WojciechMat <wmatsad@gmail.com>
Co-authored-by: Wojciech Matejuk <74838859+WojciechMat@users.noreply.github.com>
Co-authored-by: Rafał Filarecki <147185416+rafalfilarecki@users.noreply.github.com>
@KwiatkowskiML KwiatkowskiML deleted the 55-pagination branch February 18, 2025 23:42
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.

3 participants