Fix groups show page

It can definitely be cleaned up more in the future, but this should get us around a 90% reduction in page load times.
This commit is contained in:
Matt-Yorkley
2019-05-09 10:57:39 +01:00
parent 4ec46c2db6
commit d5bd058754
3 changed files with 10 additions and 13 deletions

View File

@@ -1,12 +1,10 @@
Darkswarm.controller "GroupPageCtrl", ($scope, group_enterprises, Enterprises, MapConfiguration, OfnMap, visibleFilter, Navigation) ->
Darkswarm.controller "GroupPageCtrl", ($scope, enterprises, Enterprises, MapConfiguration, OfnMap, visibleFilter, Navigation) ->
$scope.Enterprises = Enterprises
all_enterprises_by_id = Enterprises.enterprises_by_id
enterprises_by_id = enterprises.map (enterprise) =>
Enterprises.enterprises_by_id[enterprise.id]
dereferenced_enterprises = group_enterprises.map (enterprise) =>
all_enterprises_by_id[enterprise.id]
visible_enterprises = visibleFilter dereferenced_enterprises
visible_enterprises = visibleFilter enterprises_by_id
# TODO: this is duplicate code with app/assets/javascripts/darkswarm/services/enterprises.js.coffee
# It would be better to load only the needed enterprises (group + related shops).

View File

@@ -37,7 +37,12 @@ module InjectionHelper
end
def inject_group_enterprises
inject_json_ams "group_enterprises", @group.enterprises.activated.all, Api::EnterpriseSerializer, enterprise_injection_data
inject_json_ams(
"enterprises",
@group.enterprises.activated.all,
Api::EnterpriseSerializer,
enterprise_injection_data
)
end
def inject_current_hub

View File

@@ -5,12 +5,6 @@
- content_for(:image) do
= @group.logo.url
-# inject all enterprises as "enterprises"
-# it could be more efficient to inject only the enterprises that are related to the group
= inject_enterprises
-# inject enterprises in this group
-# further hubs and producers of these enterprises can't be resolved within this small subset
= inject_group_enterprises
#group-page.row.pad-top.footer-pad{"ng-controller" => "GroupPageCtrl"}