<commit_before>import Ember from 'ember';

export default Ember.Controller.extend({
  showAddUser: false,
  showAddProject: false,
  actions: {
    deleteGroup(){
      if(confirm('This will delete this entire group. Are you sure?')) {
        const groupId = this.get('model').id;
        this.store.findRecord('group', groupId).then(group => {
          group.destroyRecord();
          this.transitionToRoute('groups');
        });
      }
    },
    toggleAddUser() {
      this.toggleProperty('showAddUser');
    },
    addUser(user) {
      this.toggleProperty('showAddUser');
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        const users = group.get('users');
        group.set('users', users.concat([user]));
        group.save();
      });
    },
    removeUser(user){
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        let users = group.get('users');
        const idx = users.indexOf(user);
        users.splice(idx, 1);
        group.set('users', users);
        group.save();
      });
    },
    toggleAddProject() {
      this.toggleProperty('showAddProject');
    },
    addProject(proj) {
      this.toggleProperty('showAddProject');
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        const projects = group.get('projects');
        group.set('projects', projects.concat([proj]));
        group.save();
      });
    },
    removeProject(proj) {
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        let projects = group.get('projects');
        const idx = projects.indexOf(proj);
        projects.splice(idx, 1);
        group.set('projects', projects);
        group.save();
      });
    }<commit_msg>Fix error when adding first project<commit_after>import Ember from 'ember';

export default Ember.Controller.extend({
  showAddUser: false,
  showAddProject: false,
  actions: {
    deleteGroup(){
      if(confirm('This will delete this entire group. Are you sure?')) {
        const groupId = this.get('model').id;
        this.store.findRecord('group', groupId).then(group => {
          group.destroyRecord();
          this.transitionToRoute('groups');
        });
      }
    },
    toggleAddUser() {
      this.toggleProperty('showAddUser');
    },
    addUser(user) {
      this.toggleProperty('showAddUser');
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        const users = group.get('users');
        if (users) {
          group.set('users', users.concat([user]));
        } else {
          group.set('users', [user]);
        }
        group.save();
      });
    },
    removeUser(user){
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        let users = group.get('users');
        const idx = users.indexOf(user);
        users.splice(idx, 1);
        group.set('users', users);
        group.save();
      });
    },
    toggleAddProject() {
      this.toggleProperty('showAddProject');
    },
    addProject(proj) {
      this.toggleProperty('showAddProject');
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        const projects = group.get('projects');
        if(projects) {
          group.set('projects', projects.concat([proj]));
        } else {
          group.set('projects', [proj]);
        }
        group.save();
      });
    },
    removeProject(proj) {
      const groupId = this.get('model').id;
      this.store.findRecord('group', groupId).then(group => {
        let projects = group.get('projects');
        const idx = projects.indexOf(proj);
        projects.splice(idx, 1);
        group.set('projects', projects);
        group.save();
      });
    }
{'fraction_non_alphanumeric': 0.16518875095008867, 'fraction_numerical': 0.0010134279199391944, 'mean_word_length': 2.424111014744146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '641842', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1138, 'n_words': 200}