Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add counter cache to projects for open and closed conversations #1313

Copy link
Copy link
@joshsmith

Description

@joshsmith
Issue body actions

Problem

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:

  • on insert
    • inc: [open_conversations_count: 1]
  • on update
    • status "open" => "closed"
      • inc: [closed_conversations_count: 1, open_conversations_count: -1]
  • on 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 Ecto

A useful post on this, as well: https://medium.com/@kaisersly/prepare-changes-and-counter-cache-abd93b8a20a

Reactions are currently unavailable

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.