<commit_before>import DS           from 'ember-data';
import LFAdapter    from 'ember-localforage-adapter/adapters/localforage';
import LFSerializer from 'ember-localforage-adapter/serializers/localforage';
import generateUniqueId from '../utils/generate-unique-id';

/**
 * @module ember-flexberry-offline
 */

/**
 * Store that used in offline mode.
 *
 *
 * @class LocalStore
 * @extends DS.Store
 */
export default DS.Store.extend({
  init: function() {
    let owner = Ember.getOwner(this);
    let localStore = this;
    var serializer = LFSerializer.extend(DS.EmbeddedRecordsMixin, {
      /**
       `serializeBelongsTo` can be used to customize how `DS.belongsTo` properties are serialized.
       If there is set option `odata-id` at serializer and `DS.belongsTo` property is not null,
       then property will be serialized like `ids`.

       @method serializeBelongsTo
       @param {DS.Snapshot} snapshot
       @param {Object} json
       @param {Object} relationship
      */
      serializeBelongsTo(snapshot, json, relationship) {
        var option = this.attrsOption(relationship.key);
        if (!option || option.serialize !== 'odata-id') {
          this._super(snapshot, json, relationship);
          return;
        }

        var key = relationship.key;
        var belongsToId = snapshot.belongsTo(key, { id: true });
        var payloadKey = this.keyForRelationship(key, relationship.kind, 'serialize');
        if (Ember.isNone(belongsToId)) {
          json[payloadKey] = null;
        } else {
          json[payloadKey] = belongsToId;
        }
      }
    }).create(owner.ownerInjection(), {
      store: localStore
    });

    var adapter = LFAdapter
      .extend({
        init() {
          this._super(...arguments);
          window.localforage.setDriver(window.localforage.INDEXEDDB);
        },
        generateIdForRecord: generateUniqueId
      })
      .create(owner.ownerInjection(), {
        caching: 'none',
        namespace: 'ember-flexberry-offline:store',
        serializer: serializer,
        clear: clearLFAdapter
      });

    this.set('adapter', adapter);

    this._super(...arguments);
  },

  /**
   * Serializer is fetched via this method or adapter.serializer
   *
   * @method serializerFor
   * @public
   */
  serializerFor: function() {
    return this.get('adapter.serializer');
  },
<commit_msg>Add stubs of methods for prepare query parameters<commit_after>import DS           from 'ember-data';
import LFAdapter    from 'ember-localforage-adapter/adapters/localforage';
import LFSerializer from 'ember-localforage-adapter/serializers/localforage';
import generateUniqueId from '../utils/generate-unique-id';

/**
 * @module ember-flexberry-offline
 */

/**
 * Store that used in offline mode.
 *
 *
 * @class LocalStore
 * @extends DS.Store
 */
export default DS.Store.extend({
  init: function() {
    let owner = Ember.getOwner(this);
    let localStore = this;
    var serializer = LFSerializer.extend(DS.EmbeddedRecordsMixin, {
      /**
       `serializeBelongsTo` can be used to customize how `DS.belongsTo` properties are serialized.
       If there is set option `odata-id` at serializer and `DS.belongsTo` property is not null,
       then property will be serialized like `ids`.

       @method serializeBelongsTo
       @param {DS.Snapshot} snapshot
       @param {Object} json
       @param {Object} relationship
      */
      serializeBelongsTo(snapshot, json, relationship) {
        var option = this.attrsOption(relationship.key);
        if (!option || option.serialize !== 'odata-id') {
          this._super(snapshot, json, relationship);
          return;
        }

        var key = relationship.key;
        var belongsToId = snapshot.belongsTo(key, { id: true });
        var payloadKey = this.keyForRelationship(key, relationship.kind, 'serialize');
        if (Ember.isNone(belongsToId)) {
          json[payloadKey] = null;
        } else {
          json[payloadKey] = belongsToId;
        }
      }
    }).create(owner.ownerInjection(), {
      store: localStore
    });

    var adapter = LFAdapter
      .extend({
        init() {
          this._super(...arguments);
          window.localforage.setDriver(window.localforage.INDEXEDDB);
        },
        generateIdForRecord: generateUniqueId,
        getPaginationQuery: function(page, perPage) {
          let query = {};
          return query;
        },

        getSortingQuery: function(sortingInfo, serializer) {
          let query = {};

          return query;
        },

        getLimitFunctionQuery: function(limitFunction, projectionName) {
          let query = {};

          if (projectionName && typeof (projectionName) === 'string' && projectionName.length > 0) {
            Ember.merge(query, { projection: projectionName });
          }

          return query;
        },
      })
      .create(owner.ownerInjection(), {
        caching: 'none',
        namespace: 'ember-flexberry-offline:store',
        serializer: serializer,
        clear: clearLFAdapter
      });

    this.set('adapter', adapter);

    this._super(...arguments);
  },

  /**
   * Serializer is fetched via this method or adapter.serializer
   *
   * @method serializerFor
   * @public
   */
  serializerFor: function() {
    return this.get('adapter.serializer');
  },

{'fraction_non_alphanumeric': 0.1174924924924925, 'fraction_numerical': 0.00018768768768768769, 'mean_word_length': 2.4830065359477125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6689263', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1495, 'n_words': 354}