import Ember from 'ember';

export default Ember.Controller.extend({
  store: Ember.inject.service(),
  contestSortProperties: [
    'organizationKindSort',
    'awardQualifier',
    'awardPrimary:desc',
    'awardAgeSort',
    'awardName',
  ],
  sortedContests: Ember.computed.sort(
    'model.contests',
    'contestSortProperties'
  ),
  awardSortProperties: [
    'organizationKindSort',
    'isQualifier',
    'isPrimary:desc',
    'ageSort',
    'name',
  ],
  districtAwards: Ember.computed.alias('model.convention.organization.awards'),
  divisionAwards: Ember.computed(
    'model.convention.organization',
    function() {
      return this.get('store').query('award', {
        'organization__parent': this.get('model.convention.organization.id'),
      });
    }
  ),
  unionedAwards: Ember.computed.union(
    'districtAwards',
    'divisionAwards',
  ),
  filteredAwards: Ember.computed(
    'unionedAwards.@each.{kind,season}',
    'model.kind',
    'model.convention.season',
    function() {
      return this.get('unionedAwards').filterBy('kind', this.get('model.kind')).filterBy('season', this.get('model.convention.season'));
    }
  ),
  sortedAwards: Ember.computed.sort(
    'filteredAwards',
    'awardSortProperties',
  ),
  actions: {
    sortBy(contestSortProperties) {
      this.set('contestSortProperties', [contestSortProperties]);
    },
    sortByAward(awardSortProperties) {
      this.set('awardSortProperties', [awardSortProperties]);
    },
  }
});

@@ -465,96 +465,11 @@
 ,%0A  
-districtAwards: Ember.computed.alias('model.convention.organization.awards'),%0A  division
+raw
 Awar
@@ -502,32 +502,8 @@
 odel
-.convention.organization
 ',%0A 
@@ -593,14 +593,25 @@
 on__
-parent
+grantors__session
 ': t
@@ -629,32 +629,8 @@
 del.
-convention.organization.
 id')
@@ -656,96 +656,8 @@
  ),%0A
-  unionedAwards: Ember.computed.union(%0A    'districtAwards',%0A    'divisionAwards',%0A  ),%0A
   fi
@@ -691,23 +691,19 @@
 d(%0A    '
-unioned
+raw
 Awards.@
@@ -816,15 +816,11 @@
 et('
-unioned
+raw
 Awar
@@ -933,16 +933,80 @@
  %7D%0A  ),%0A
+  uniqueAwards: Ember.computed.uniq(%0A    'filteredAwards',%0A  ),%0A
   sorted
@@ -1035,32 +1035,30 @@
 .sort(%0A    '
-filtered
+unique
 Awards',%0A   

Update contest award filter