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 (NEXP): add page instead of offset as pagination request option #243

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

Conversation

Rutito2010
Copy link
Contributor

@Rutito2010 Rutito2010 commented Mar 25, 2024

📜 Description

To avoid force the frontend to calculate and offset to select a page of a pagination we move that logic to the backend

option [page] as added to Pagination object

in case that page param come we use it to calculate the correct offset and return a response to the frontend

this param has priority over "offset" param

its still an optional param so paginate its still able to work with limit and offset

if it come we take the page parameter and multiply by limit to know how much offset we need on the db query

**Notes:
Only works on Mongo queries

🧪 Accept Criteria Tests

adding a page param on should return the correct offset number

if a no existent page is passed return an empty array

🔮 Last Notes

📋 Author Checklist

  • Review my on PR.

📋Reviewer Checklist

  • There is no hardcoding in the code.
  • The tests cover various aspects of functionality.
  • There is no any type in the code.
  • The target branch is main.

@Rutito2010 Rutito2010 requested a review from Murzbul March 25, 2024 21:38
Copy link
Contributor

@Murzbul Murzbul left a comment

Choose a reason for hiding this comment

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

No entiendo los cambios de codigo que te marqué.

@@ -19,7 +17,7 @@ class ItemMikroORMRepository extends BaseMikroORMRepository<IItemDomain> impleme
super(Item.name, ItemSchema);
}

async list(criteria: ICriteria): Promise<IPaginator>
async list(criteria: ICriteria): Promise<any>
Copy link
Contributor

Choose a reason for hiding this comment

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

??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actualmente el list no devuelve un IPaginator (en el de mongoose tambien estaba asi sin que lo tocara)
en cambio ambos devuelven un ResponsePayload de tipo

interface ResponsePayload { data: unknown; metadata?: unknown; }

Deberia cambiar el tipado del list (lo cual significa modificarlo en todos los dominios como en file y otras)? o mantengo el any

@@ -25,7 +25,7 @@ class CreateMikroORMConnection implements ICreateConnection
{
orm = await MikroORM.init({
entities: this.entities,
clientUrl: this.config.DB_URI,
clientUrl: this.config.uri,
Copy link
Contributor

Choose a reason for hiding this comment

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

???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

En este caso no me tomaba el DB_URI lo cual entiendo que era la forma anterior de invocar los params del .env, ahi adapte para recibirlo por constructor en el factory insertarlo como variable privada en el objeto y utilizarla de ahi, cuando resolvamos lo del tipado del pagiantor subo ambas

Copy link

sonarcloud bot commented Apr 5, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
33.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

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.

None yet

2 participants