rubyforgood / coral

An upcoming project for Ruby for Good
MIT License
13 stars 11 forks source link

Conhub/nursery table feature #78

Closed conj40 closed 4 years ago

conj40 commented 4 years ago

History of restoration table feature added for #63

Description

Useful table feature added to nursery_tables/show.html.erb . This table displays a most-recent-first history of restoration activities for the Nursery Table.

Type of change

How Has This Been Tested?

Tested on my local machine everything works fine.

Screenshots

before Screenshot 2019-08-17 at 17 04 12

after Screenshot 2019-08-17 at 16 47 21

LizPrescott commented 4 years ago

Totally. I always refer folks to this when I’m talking about n+1 queries. https://semaphoreci.com/blog/2017/08/09/faster-rails-eliminating-n-plus-one-queries.html Basically, if you watch your rails console when you visit this page, you’ll see multiple queries. If you “eager load” the association ahead of time, rails will only make one query, which is faster (especially if there are a lot of log entries per table). So you might do something like. @nursery_table = NurseryTable.includes(:restoration_activity_log_entry).where(id: params[id])

That might not be the exact syntax, but should get you started. Lmk if I can offer more hints!

On Aug 18, 2019, at 7:32 AM, chub93 notifications@github.com wrote:

@chub93 commented on this pull request.

In rails/app/views/nursery_tables/show.html.erb:

+

  • Recent restoration activities: +

  • +

  • <% @nursery_table.restoration_activity_log_entries.order('id DESC').each do |entry| %> Hi @LizPrescott would it be possible to give me an example please?
  • — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

    Date Performed Cleaned? Percent full Bleached Dead