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

🧮 Aggregate queries #6868

Open
FelixMalfait opened this issue Sep 3, 2024 · 6 comments
Open

🧮 Aggregate queries #6868

FelixMalfait opened this issue Sep 3, 2024 · 6 comments
Assignees
Labels
prio: med scope: backend Issues that are affecting the backend side only size: long type: feature

Comments

@FelixMalfait
Copy link
Member

FelixMalfait commented Sep 3, 2024

Our GraphQL API should support aggregate queries on findMany queries.

We already have totalCount so we can take inspiration from that.
But it's significantly more challenging because the aggregated fields name are dynamic and depend on the object names themselves. Here's how it could look like:

query {
   companies {
    edges {
      node {
        id
        domainName {
          primaryLinkLabel
        }
        people {
          totalCount
          maxCreatedAt
        }
      }
    }
    totalCount
    maxCreatedAt
  }
}

We'll need to add: min, max, avg, sum, countDistinct

@FelixMalfait FelixMalfait added the scope: backend Issues that are affecting the backend side only label Sep 3, 2024
@FelixMalfait
Copy link
Member Author

Default aggregations available for all fields:
Screenshot 2024-09-03 at 13 04 26
Screenshot 2024-09-03 at 13 04 38

For date fields:
Screenshot 2024-09-03 at 13 05 31

For numeric fields:
Screenshot 2024-09-03 at 13 06 21

@Bonapara
Copy link
Member

CleanShot.2024-09-19.at.13.57.53.mp4

@FelixMalfait FelixMalfait moved this from 🆕 New to 📋 Backlog in Product development ✅ Sep 30, 2024
@FelixMalfait FelixMalfait moved this from 📋 Backlog to 🔖 Planned in Product development ✅ Sep 30, 2024
@FelixMalfait FelixMalfait assigned ijreilly and unassigned magrinj Oct 31, 2024
Weiko added a commit that referenced this issue Nov 14, 2024
First step of #6868

Adds min.., max.. queries for DATETIME fields
adds min.., max.., avg.., sum.. queries for NUMBER fields 

(count distinct operation and composite fields such as CURRENCY handling
will be dealt with in a future PR)

<img width="1422" alt="Capture d’écran 2024-11-06 à 15 48 46"
src="https://github.com/user-attachments/assets/4bcdece0-ad3e-4536-9720-fe4044a36719">

---------

Co-authored-by: Charles Bochet <[email protected]>
Co-authored-by: Weiko <[email protected]>
khuddite pushed a commit to khuddite/twenty that referenced this issue Nov 18, 2024
First step of twentyhq#6868

Adds min.., max.. queries for DATETIME fields
adds min.., max.., avg.., sum.. queries for NUMBER fields 

(count distinct operation and composite fields such as CURRENCY handling
will be dealt with in a future PR)

<img width="1422" alt="Capture d’écran 2024-11-06 à 15 48 46"
src="https://github.com/user-attachments/assets/4bcdece0-ad3e-4536-9720-fe4044a36719">

---------

Co-authored-by: Charles Bochet <[email protected]>
Co-authored-by: Weiko <[email protected]>
@ijreilly
Copy link
Collaborator

CleanShot.2024-09-19.at.13.57.53.mp4

@Bonapara do we have further designs ?

@Bonapara
Copy link
Member

Bonapara commented Nov 19, 2024

Do you still need anything, @ijreilly?

@ijreilly
Copy link
Collaborator

no all good for now after our talk ! @Bonapara

@ijreilly ijreilly moved this from 🔖 Planned to 🏗 In progress in Product development ✅ Nov 25, 2024
@ijreilly
Copy link
Collaborator

ijreilly commented Nov 25, 2024

Next steps:

  1. Expose current available aggregate operations (MAX, MIN, AVG, SUM) on table views: Use aggregate queries in table views #8734
  2. Same for kanban views Use aggregate queries in kanban views #8735
  3. Use "count" from aggregate operations instead of "totalCount"

@Bonapara Bonapara changed the title Aggregate queries 🧮 Aggregate queries Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio: med scope: backend Issues that are affecting the backend side only size: long type: feature
Projects
Status: 🏗 In Progress
Development

No branches or pull requests

5 participants