You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a conversation record is created/updated, we need to update the open_conversations_count and closed _conversations_count counter cache columns on the projects table.
Add project_id to Conversation
change in Ember app to send the project_id up to the app
change in API
migrate data
We'll need to update the counts based on the following logic:
joshsmith
changed the title
Add counter cache to projects for open conversations
Add counter cache to projects for open and closed conversations
Dec 23, 2017
@joshsmith Do you think the Conversation needs an explicit association to a project for this to work? I think it will if we need to cast the project_id.
Problem
When a
conversation
record is created/updated, we need to update theopen_conversations_count
andclosed _conversations_count
counter cache columns on theprojects
table.project_id
toConversation
We'll need to update the counts based on the following logic:
insert
inc: [open_conversations_count: 1]
update
status
"open" => "closed"inc: [closed_conversations_count: 1, open_conversations_count: -1]
update
status
"closed" => "open"inc: [closed_conversations_count: -1, open_conversations_count: 1]
We'll add
prepare_changes
to increment one and decrement the other. See this example in EctoA useful post on this, as well: https://medium.com/@kaisersly/prepare-changes-and-counter-cache-abd93b8a20a
The text was updated successfully, but these errors were encountered: