<commit_before>App.PeopleController = Ember.ArrayController.extend
  needs: ['application']
  roleFilter: null
  queryParams: null

  offices: Ember.computed.alias('controllers.application.offices')
  anyProject: (->
    @store.all('project').findBy('id', App.NO_PROJECT_ID)
  ).property()

  selectedOffice: (->
    queryId = @get('queryParams').office_id || App.NO_OFFICE_ID
    @get('offices').findProperty('id', queryId)
  ).property()

  office: ( ->
    @get('offices').findProperty('id', @get('selectedOffice.value'))
  ).property('offices', 'selectedOffice')

  selectedProject: (->
    queryId = @get('queryParams').project_id || App.NO_PROJECT_ID
    @get('projects').findProperty('id', queryId)
  ).property()

  projects: (->
    office = @get('selectedOffice')
    filteredProjects = if office.get('id') == App.NO_OFFICE_ID
                         @store.filter('project', (record) -> true)
                       else
                         op = office.get('projects')
                         op.pushObject(@get('anyProject'))
                         op
    filteredProjects.sortBy('name')
  ).property('selectedOffice')

  filteredPeople: (->
    officeId = @get('queryParams').office_id || App.NO_OFFICE_ID
    if officeId == App.NO_OFFICE_ID
      officePeople = @get('model')
    else
      officePeople = @get('model').filterBy('office.id', @get('office.id'))

    projectId = @get('queryParams').project_id || App.NO_PROJECT_ID
    if projectId == App.NO_PROJECT_ID || !projectId
      result = officePeople
    else
      result = officePeople.filterBy 'currentAllocation.project.id', projectId

    searchRegex = new RegExp(@get('searchTerm') || '', 'i')
    result.filter (item) =>
      item.matches(searchRegex)
  ).property('queryParams', 'searchTerm')

  updateSearch: (->
    Ember.run.debounce({name: 'searchDebounce'}, =>
      @set('searchTerm', @get('search'))
    , 150)
  ).observes('search')

  setQueryParams: (->
    @transitionToRoute queryParams:
      project_id: @get('selectedProject.id')
      office_id: @get('selectedOffice.id')
  ).observes('selectedProject', 'selectedOffice')





<commit_msg>Update filter to default to anythin gproject when changing offices<commit_after>App.PeopleController = Ember.ArrayController.extend
  needs: ['application']
  roleFilter: null
  queryParams: null

  offices: Ember.computed.alias('controllers.application.offices')
  anyProject: (->
    @store.all('project').findBy('id', App.NO_PROJECT_ID)
  ).property()

  selectedOffice: (->
    queryId = @get('queryParams').office_id || App.NO_OFFICE_ID
    @get('offices').findProperty('id', queryId)
  ).property()

  office: ( ->
    @get('offices').findProperty('id', @get('selectedOffice.value'))
  ).property('offices', 'selectedOffice')

  selectedProject: (->
    queryId = @get('queryParams').project_id || App.NO_PROJECT_ID
    @get('projects').findProperty('id', queryId)
  ).property()

  projects: (->
    office = @get('selectedOffice')
    filteredProjects = if office.get('id') == App.NO_OFFICE_ID
                         @store.filter('project', (record) -> true)
                       else
                         projects = Ember.ArrayProxy.create(content: [@get('anyProject')])
                         office.get('projects').forEach (proj)-> projects.pushObject(proj)
                         projects
    filteredProjects.sortBy('name')
  ).property('selectedOffice')

  filteredPeople: (->
    officeId = @get('queryParams').office_id || App.NO_OFFICE_ID
    if officeId == App.NO_OFFICE_ID
      officePeople = @get('model')
    else
      officePeople = @get('model').filterBy('office.id', @get('office.id'))

    projectId = @get('queryParams').project_id || App.NO_PROJECT_ID
    if projectId == App.NO_PROJECT_ID || !projectId
      result = officePeople
    else
      result = officePeople.filterBy 'currentAllocation.project.id', projectId

    searchRegex = new RegExp(@get('searchTerm') || '', 'i')
    result.filter (item) =>
      item.matches(searchRegex)
  ).property('queryParams', 'searchTerm')

  updateSearch: (->
    Ember.run.debounce({name: 'searchDebounce'}, =>
      @set('searchTerm', @get('search'))
    , 150)
  ).observes('search')

  updateRoute: ->
    @transitionToRoute queryParams:
      project_id: @get('selectedProject.id')
      office_id: @get('selectedOffice.id')

  selectedOfficeUpdated: (->
    if @get("selectedOffice.id") != App.NO_OFFICE_ID
      @set("selectedProject", @get('anyProject'))
    @updateRoute()
  ).observes('selectedOffice')

  selectedProjectUpdated: (->
    @updateRoute()
  ).observes('selectedProject')






{'fraction_non_alphanumeric': 0.16062176165803108, 'fraction_numerical': 0.0012953367875647669, 'mean_word_length': 3.3461538461538463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1204101', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1386, 'n_words': 225}