         proposed: false
         actual_hours: 0
         estimated_hours: 0
-      
+
       @add aggregate
 
     aggregate

  comparator: (first, second) ->
    firstYear = first.get('year')
    secondYear = second.get('year')
    
    if firstYear == secondYear
      if first.get('cweek') < second.get('cweek') then -1 else 1
    else

class window.StaffPlan.Collections.WeeklyAggregates extends Backbone.Collection

  model: window.StaffPlan.Models.WeeklyAggregate

  initialize: (models, options) ->
    @parent = options.parent

  populate: () ->
    begin = new XDate().addWeeks(-150)
    end = begin.clone().addWeeks(300)
    range = _.range(begin.getTime(), end.getTime(), 7 * 86400 * 1000)

    baseAggregate = new StaffPlan.Models.WeeklyAggregate
      cweek: 0
      year: 0
      timestamp: 0
      totals:
        estimated: 0
        actual: 0
        proposedEstimated: 0
        proposedActual: 0
    date = new XDate()
    dummies = range.map (timestamp) ->
      dateClone = date.clone().setTime(timestamp)
      baseAggregate.clone().set
        cweek: dateClone.getWeek()
        year: dateClone.getFullYear()
        timestamp: timestamp
    @add dummies

    @parent.getAssignments().each (assignment) =>
      assignment.work_weeks.each (week) =>
