Skip to content

Metric filters, expression values, options sort and shared aggregate joins - #2457

Closed
Flo0807 wants to merge 5 commits into
feature/relationship-aggregatesfrom
feature/migration-gaps
Closed

Flo0807 wants to merge 5 commits into
feature/relationship-aggregatesfrom
feature/migration-gaps

Conversation

@Flo0807

@Flo0807 Flo0807 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Closed: the changes moved into the PRs that introduced the APIs they change.

…gates

Backpex.Expr gets +, -, *, /, datetime_diff/3 and to_string/1, and comparisons
take values on both sides, e.g. expr(likes - dislikes > 10). Metrics aggregate
expressions, e.g. {:sum, expr(price * quantity)}. The Ecto adapter and the
in-memory runtime follow the rules of SQL for nil and integer division.

The Ecto adapter joins one subquery for every group of aggregates that only
differ in their value, instead of one per aggregate, e.g. for the name and the
email of the primary partner of a contact.
Backpex.LiveResource.index_query/1 took the fields from the assigns. In an
item or resource action they are the fields of the action, so an export sorted
and searched by the wrong fields. index_query/1 now takes the fields of the
index view of the LiveResource, and index_query/2 the given fields, which the
index view passes.
Backpex.Fields.BelongsTo, HasMany and HasManyThrough take :options_sort, a
sort like Backpex.Query.sort/2 or a function of the assigns that returns one.
Its fields may be computed values of the related items. Before, only the
:options_query of the Ecto adapter could sort the options.
A metric that should cover the items of every status while the index view
shows one status had to rebuild the query from the filter values in data/3.
Metrics now take :ignore_filters, the names of filters that don't limit their
items. The index view computes the metrics that ignore the same filters with
one query, which data/3 receives, too.
@Flo0807 Flo0807 added the breaking-change A breaking change label Oct 29, 2026
@Flo0807
Flo0807 added this pull request to stack #2456 October 29, 2026 12:56
With a bigint, the sum of datetime_diff/3 in a metric was a numeric of
PostgreSQL, so Ecto returned a Decimal. As an integer, its sum is an integer,
like the sum of other integer fields.
@Flo0807

Flo0807 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: the changes moved into the PRs that introduced the APIs they change.

@Flo0807 Flo0807 closed this Oct 29, 2026
@Flo0807 Flo0807 changed the title Close the gaps the platform migration found Metric filters, expression values, options sort and shared aggregate joins Oct 29, 2026
@Flo0807
Flo0807 removed this pull request from stack #2456 October 29, 2026 13:28
@Flo0807
Flo0807 deleted the feature/migration-gaps branch October 29, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change A breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant