-
Notifications
You must be signed in to change notification settings - Fork 85
Conversation index endpoint with supporting infrastructure #1296
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
Conversation
| """ | ||
| @spec status_filter(Queryable.t, map) :: Queryable.t | ||
| def status_filter(queryable, %{"status" => "active"}) do | ||
| prefiltered_ids = queryable |> select([c], c.id) |> Repo.all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to additional joins below, we cannot just pipe the existing query due to potentially applying the project filter above as well. The SQL query ecto builds get's all garbled up with multiple joins and is no longer applying conditions to correct schemas and fields. Unfortunately, this is the only way I could find to support flexibility of multiple queries.
| |> join(:left, [c, _m], cp in ConversationPart, c.id == cp.conversation_id) | ||
| |> group_by([c, m, _cp], [c.id, m.initiated_by]) | ||
| |> having([_c, m, _cp], m.initiated_by == "user") | ||
| |> or_having([c, m, cp], m.initiated_by == "admin" and count(cp.id) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a reply_count counter cache field to Conversation might speed things up a bit here and it would certainly replace the having/or_having with where/or_where, but I would do it as part of a separate issue, since updating it would involve ConversationPart changesets.
My vote is, separate issue for consideration, and mark it low priority for now. If we find we need it for performance reasons, we can do it then.
51b35b4 to
30c9b07
Compare
e5d4759 to
270f0e2
Compare
3877f5b to
e5d4759
Compare
e5d4759 to
2ca0b0a
Compare
- Policy.Conversation.scope/2 with tests - Messages.list_conversations/2 with tests - ConversationView and tests - ConversationController :index endpoint and tests
2ca0b0a to
21293b0
Compare
What's in this PR?
This PR basess off of #1295 to facilitate review. Should be rebased to
developonce #1295 is merged.This PR adds a ConversationController with an
:indexendpoint as well as all associated infrastructureMessages.list_conversations/2ConversationViewPolicy.Conversation.scope/2Tests have also been added.
References
Fixes #1288
Progress on: https://github.com/code-corps/code-corps-api/milestone/22