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

Deeply Nested Aggregate query is not filtered by parent colum #6753

Open
sftgoldie opened this issue Apr 5, 2021 · 1 comment
Open

Deeply Nested Aggregate query is not filtered by parent colum #6753

sftgoldie opened this issue Apr 5, 2021 · 1 comment

Comments

@sftgoldie
Copy link

The query needs to count each occurance of a column value in a "history" table per each "definition" row. This requires looking up possible values and counting each of the possible "ExitReason Codes".

This query gets each subtask, but the count is the total count of each ExitReason, and not the ExitReason count for the give subtask:

query SubtaskExitReasonCount {
  ivr_subtasks {
    friendly_name
    subtask_histories {
      exitReasonByExitReason {
        exit_reason
        subtask_histories_aggregate {
          aggregate {  count  }
        }
      }
    }
  }
}

The following does work as expected; however, it would require filtering by each subtask_id rather depending on the implied relationships.

query SubtaskExitReasonCountWithFilter {
  ivr_subtasks {
    friendly_name
    subtask_histories {
      exitReasonByExitReason {
        exit_reason
        subtask_histories_aggregate(where: {subtask_id: {_eq: 1}}) {
          aggregate { count }
        }
      }
    }
  }
}
  • How can the subtask_histories_aggregate be filtered/grouped by the subtask_id?
  • Must this be done with a VIEW with an extra group by statement?
  • Can a where clause reference a parent relationship property?
## Pseudo Code
subtask_histories_aggregate(where: {subtask_id: {_eq: "_root.id" }}) {
          aggregate { count }
        }
@tirumaraiselvan
Copy link
Contributor

Similar: #5081

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

No branches or pull requests

2 participants