Skip to content

Sort deals by date of last note? #16

@chhhris

Description

@chhhris

My biz team updates Deals with Notes quite frequently, but unfortunately it appears a note does not update the deal's updated_at value (e.g. a deal might be last updated May 24 even though someone added a note yesterday).

I tried sorting my array of deals based on the presence of a note, however this query is so unbelievably slow that the page times out every time:

session.deals.all(stage: :incoming).sort_by do |deal|
  (deal.notes.all.present? && deal.notes.all.last[:updated_at]) ||
  deal[:updated_at]
end

Any advice much appreciated!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions