App.ListsIndexController = Ember.ArrayController.extend
  loading: true
  dateChanged: (->
    @set 'loading', true
    lists = if @get('date') then @store.find('list', date: @get('date')) else @store.find('list')
    lists.then => @set('loading', false)
    @set 'model', lists
  ).observes('date')
  lists: (->
    return @store.all('list') unless date = @get('date')
    @store.filter('list', (l)->
      return false unless list_date = l.get('created_at')
      list_date = list_date.toISOString().substring(0,10) if typeof(list_date) is 'object'
      list_date == date
    )
  ).property('date')

  sorted_lists: (->
    @get('lists').sortBy('created_at').reverseObjects()
  ).property('lists.@each')
