<commit_before>class Lovefield {
  constructor(schemaBuilder, $q) {
    this.schemaBuilder = schemaBuilder;
    this.Types = lf.Type;
    this.$q = $q;
    this.connection = undefined;
    this.dbPromise = undefined;
  }
  getDb() {
    if (this.connection) {
      return this.$q.resolve(this.connection);
    }
    if (!this.dbPromise) {
      this.dbPromise = this.schemaBuilder.connect()
        .then(connection => {
          this.connection = connection;
          return this.connection;
        })
        .catch(error => {
          console.error(error);
        });
    }
    return this.dbPromise;
  }
}

export default function LovefieldProvider() {
  let schemaBuilder;
  return {
    create(name, version) {
      schemaBuilder = lf.schema.create(name, version);
    },
    $get: function($q) {
      'ngInject';
      return new Lovefield(schemaBuilder, $q);
    }
  };
}<commit_msg>feat(local DB): changed promise logic<commit_after>class Lovefield {
  constructor(schemaBuilder, $q) {
    this.schemaBuilder = schemaBuilder;
    this.Types = lf.Type;
    this.$q = $q;
    this.connection = undefined;
    this.dbPromise = undefined;
  }
  getDb() {
    if (this.connection) {
      return this.$q.resolve(this.connection);
    }
    if (!this.dbPromise) {
      this.dbPromise = this.$q.defer();
      this.schemaBuilder.connect()
        .then(connection => {
          this.connection = connection;
          return this.dbPromise.resolve(this.connection);
        })
        .catch(error => {
          console.error(error);
          return this.dbPromise.reject(error);
        });
    }
    return this.dbPromise.promise;
  }
}

export default function LovefieldProvider() {
  let schemaBuilder;
  return {
    create(name, version) {
      schemaBuilder = lf.schema.create(name, version);
    },
    $get: function($q) {
      'ngInject';
      return new Lovefield(schemaBuilder, $q);
    }
  };
}
{'fraction_non_alphanumeric': 0.13357588357588357, 'fraction_numerical': 0.0, 'mean_word_length': 2.4070796460176993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4613969', 'n_tokens_mistral': 586, 'n_tokens_neox': 586, 'n_words': 109}