Break up the one-query-of-doom

The single query was producing a tremendously large ActiveRecord allocation.

While this isn't nearly as cool as one query, it's still a significant
reduction in SQL trips, and now has the bonus of only loading what is
actually going to be displayed.
This commit is contained in:
James Mason 2017-12-21 19:06:36 -08:00
parent 754d201b01
commit fa55224163
26 changed files with 181 additions and 165 deletions

View file

@ -1,13 +1,13 @@
#map{ style: "height: 500px;" }
- content_for(:script_body) do
- marker = escape_javascript(render '/conferences/venue_map_marker',
venue: conference.venue)
venue: venue)
:javascript
// create a map in the "map" div, set the view to a given place and zoom
var map = L.map('map', { scrollWheelZoom: false }).setView(
[
#{conference.venue.latitude.to_f + 0.05},
#{h(conference.venue.longitude)}
#{venue.latitude.to_f + 0.05},
#{h(venue.longitude)}
], 11);
// add an OpenStreetMap tile layer
L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
@ -20,8 +20,8 @@
// add a marker in the given location, attach some popup content to it
// and open the popup
L.marker([
#{h conference.venue.latitude},
#{h conference.venue.longitude}
#{h venue.latitude},
#{h venue.longitude}
]).addTo(map)
.bindPopup("#{marker}")
.openPopup();