<commit_before>import Service, { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { isPresent } from '@ember/utils';

export default Service.extend({
  fetch: service(),
  serverVariables: service(),

  config: computed('apiHost', function () {
    return this.getConfig();
  }),
  getConfig() {
    return this.fetch.getJsonFromApiHost('/application/config');
  },

  async itemFromConfig(key) {
    const config = await this.getConfig();
    const obj = config.config;
    return key in obj?obj[key]:null;
  },

  userSearchType: computed('config.userSearchType', function(){
    return this.getUserSearchType();<commit_msg>Cache config from API server<commit_after>import Service, { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { isPresent } from '@ember/utils';

export default Service.extend({
  fetch: service(),
  serverVariables: service(),
  _config: null,

  config: computed('apiHost', function () {
    return this.getConfig();
  }),
  async getConfig() {
    if (!this._config) {
      this._config = await this.fetch.getJsonFromApiHost('/application/config');
    }
    return this._config;
  },

  async itemFromConfig(key) {
    const config = await this.getConfig();
    const obj = config.config;
    return key in obj?obj[key]:null;
  },

  userSearchType: computed('config.userSearchType', function(){
    return this.getUserSearchType();
{'fraction_non_alphanumeric': 0.1408839779005525, 'fraction_numerical': 0.0, 'mean_word_length': 4.231046931407942, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3926014', 'n_tokens_mistral': 416, 'n_tokens_neox': 409, 'n_words': 107}