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

Sort deals by date of last note? #16

Open
chhhris opened this issue Jul 31, 2014 · 2 comments
Open

Sort deals by date of last note? #16

chhhris opened this issue Jul 31, 2014 · 2 comments

Comments

@chhhris
Copy link
Contributor

chhhris commented Jul 31, 2014

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!

@obrok
Copy link
Contributor

obrok commented Aug 1, 2014

You can try session.deals.all(stage: incoming, sort_by: :last_activity, sort_order: :desc). It won't exactly sort by the date of last note, because other things also count as activity (adding tasks, updating, etc.) but might be enough for your purpose.

@iaintshine
Copy link
Contributor

You want to sort by last_activity_at e.g. client.deals.all(sort_by: :last_activity_at) unfortunetly it's not exposed by the api, even the attribute is. I'll prioritise it for the next milestone.

@iaintshine iaintshine self-assigned this Sep 24, 2015
@iaintshine iaintshine added this to the version 1.2 milestone Sep 24, 2015
@efedasz efedasz removed this from the version 1.2 milestone Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants