Skip to content

Simplify list-filtering DTOs #2502

Description

@acelaya

The app defines a number of DTOs /data objects that are used to encapsulate and validate all the parameters used to filter lists of entities (short URLs, visits, etc).

They are kindof useful, but they also introduce more levels of indirection.

The problem gets worst considering there are usually two levels of DTOs, those closer to the action, which include validation, and usually handle itemsPerPage and page together with the rest of filtering arguments, and then a second level closer to the DB abstraction/repository which handles limit and offset and does not validate the arguments.

Converting the first level into the second level becomes cumbersome and adds a lot of boilerplate code.

The problem is even worst considering we usually have two objects per use case in the lower level, one with limit and offset for lists of entities, and one without it to count lists of entities. This means we have at least three DTOs per use case.

Proposal

I would explore the option to merge all objects for the same use case, and see if it makes things better or worst.

We could have objects which can be created from pagination params or limit and offset, and internally do the conversion to the latter if needed.

We could also avoid splitting objects for listing and counting, and simply ignore limit/offset for the latter. This could be unintuitive though, so let's see.

Starting with a POC refactoring one of the use cases would be a good starting point.

Activity

  1. added this to the milestone on Oct 28, 2025
  2. moved this to Todo in Shlinkon Oct 28, 2025
  3. modified the milestones: , 5.0.0 on Nov 1, 2025
  4. added this to Shlink and removed this from Shlinkon Nov 1, 2025
  5. moved this to Todo in Shlinkon Nov 8, 2025
  6. modified the milestones: 5.0.0, 5.1.0 on Jan 9, 2026
  7. moved this from Todo to No status in Shlinkon Jan 9, 2026
  8. moved this to In Progress in Shlinkon Mar 18, 2026
  9. moved this from In Progress to Todo in Shlinkon Mar 18, 2026
  10. modified the milestones: 5.1.0, 5.2.0 on Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions