Adding dereferencing to taxons and reducing our data-set

This commit is contained in:
Will Marshall
2014-07-02 12:30:28 +10:00
committed by Rohan Mitchell
parent 4a116570d1
commit 24d3abf6d5
8 changed files with 52 additions and 6 deletions

View File

@@ -1,15 +1,20 @@
Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Dereferencer)->
Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Taxons, Dereferencer)->
new class Enterprises
enterprises_by_id: {} # id/object pairs for lookup
constructor: ->
@enterprises = enterprises
for enterprise in enterprises
@enterprises_by_id[enterprise.id] = enterprise
@dereference()
@dereferenceEnterprises()
@dereferenceTaxons()
dereference: ->
dereferenceEnterprises: ->
if CurrentHub.hub?.id
CurrentHub.hub = @enterprises_by_id[CurrentHub.hub.id]
for enterprise in @enterprises
Dereferencer.dereference enterprise.hubs, @enterprises_by_id
Dereferencer.dereference enterprise.producers, @enterprises_by_id
dereferenceTaxons: ->
for enterprise in @enterprises
Dereferencer.dereference enterprise.taxons, Taxons.taxons_by_id

View File

@@ -0,0 +1,8 @@
Darkswarm.factory "Taxons", (taxons)->
new class Taxons
taxons: taxons
taxons_by_id: {}
constructor: ->
for taxon in @taxons
@taxons_by_id[taxon.id] = taxon