<commit_before>import Ember from 'ember';

export default Ember.Controller.extend({
  init () {
    Ember.run.schedule('afterRender', () => {
      componentHandler.upgradeAllRegistered();
    });
  },

  settingsSnackbar (message) {
    const _this = this;
    const snackbarContainer = document.querySelector('#snackbar-container');

    const handler = function () {
      _this.transitionToRoute('home');
      Ember.run.later(() => {
        window.location.reload(true);
      }, 500);
    };

    const data = {
      message,
      timeout: 4000,
      actionHandler: handler,
      actionText: 'Reload'
    };
    snackbarContainer.MaterialSnackbar.showSnackbar(data);
  },
  currency: function () {
    let currency = this.get('model').findBy('id', 'currency');

    if (!currency) {
      return {
        isDefault: true,
        id: 'currency',
        setting: 'Currency',
        value: '$'
      };
    }
    return currency;
  }.property('model'),

  userName: function () {
    let userName = this.get('model').findBy('id', 'user-name');

    if (!userName) {
      return {
        isDefault: true,
        id: 'user-name',
        setting: 'Name',
        value: 'Guest'
      };
    }
    return userName;
  }.property('model'),

  actions: {
    closeSettings () {
      this.transitionToRoute('home');
    },

    updateSetting (obj) {
      let payload = obj;

      if (payload.isDefault) {
        payload.isDefault = false;
        let record = this.store.createRecord('setting', payload);
        record.save();
        return;
      }

      return this.store.findRecord('setting', payload.get('id'))
        .then(response => {
          response.set('value', payload.get('value'));
          response.save();
        })
        .then(this.settingsSnackbar('Settings changed.'))
        .catch(err => {
          console.log(err);
          this.settingsSnackbar('Ooops. Something went wrong.');
        });
    }
  }
});
<commit_msg>feat: Add currency symbol property to settings<commit_after>import Ember from 'ember';

export default Ember.Controller.extend({
  init () {
    Ember.run.schedule('afterRender', () => {
      componentHandler.upgradeAllRegistered();
    });
  },

  settingsSnackbar (message) {
    const _this = this;
    const snackbarContainer = document.querySelector('#snackbar-container');

    const handler = function () {
      _this.transitionToRoute('home');
      Ember.run.later(() => {
        window.location.reload(true);
      }, 500);
    };

    const data = {
      message,
      timeout: 4000,
      actionHandler: handler,
      actionText: 'Reload'
    };
    snackbarContainer.MaterialSnackbar.showSnackbar(data);
  },
  currency: function () {
    let currency = this.get('model').findBy('id', 'currency');

    if (!currency) {
      return {
        isDefault: true,
        id: 'currency',
        setting: 'Currency',
        value: 'USD'
      };
    }
    return currency;
  }.property('model'),

  currencySymbol: function () {
    let currencySymbol = this.get('model').findBy('id', 'currency-symbol');

    if (!currencySymbol) {
      return {
        isDefault: true,
        id: 'currency-symbol',
        setting: 'Currency Symbol',
        value: '$'
      };
    }
    return currencySymbol;
  }.property('model'),

  userName: function () {
    let userName = this.get('model').findBy('id', 'user-name');

    if (!userName) {
      return {
        isDefault: true,
        id: 'user-name',
        setting: 'Name',
        value: 'Guest'
      };
    }
    return userName;
  }.property('model'),

  actions: {
    closeSettings () {
      this.transitionToRoute('home');
    },

    updateSetting (obj) {
      let payload = obj;

      if (payload.isDefault) {
        payload.isDefault = false;
        let record = this.store.createRecord('setting', payload);
        record.save();
        return;
      }

      return this.store.findRecord('setting', payload.get('id'))
        .then(response => {
          response.set('value', payload.get('value'));
          response.save();
        })
        .then(this.settingsSnackbar('Settings changed.'))
        .catch(err => {
          console.log(err);
          this.settingsSnackbar('Ooops. Something went wrong.');
        });
    }
  }
});

{'fraction_non_alphanumeric': 0.15311116289909113, 'fraction_numerical': 0.0032626427406199023, 'mean_word_length': 2.2564491654021244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2468155', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1250, 'n_words': 241}