<commit_before>define(
  [
    'underscore',
    'stores/Store',
    'rsvp',
    'collections/SizeCollection',
    'dispatchers/AppDispatcher',
    'actions/SizeActions'
  ],
  function (_, Store, RSVP, SizeCollection, AppDispatcher, SizeActions) {

    var _sizes = {};

    var _getSizesUncached = function (providerId, identityId) {
      return new RSVP.Promise(function (resolve, reject) {
        var sizes = new SizeCollection([], {
          provider_id: providerId,
          identity_id: identityId
        });
        sizes.on('sync', resolve);
        sizes.fetch();
      });
    };

    var SizeStore = {

      get: function (providerId, identityId) {
        var provider = _sizes[providerId];
        if (provider)
          return provider[identityId];
      },

      fetch: function (providerId, identityId) {
        _getSizesUncached(providerId, identityId)
          .then(function (collection) {
            if (!_sizes[providerId])
              _sizes[providerId] = {};
            _sizes[providerId][identityId] = collection;
            this.emitChange();
          }.bind(this))
      }
    };

    AppDispatcher.register(function (payload) {
      var action = payload.action;

      switch (action.actionType) {
        case SizeActions.constants.fetch:
          SizeStore.fetch(action.providerId, action.identityId);
          break;
      }

      return true;
    });

    _.extend(SizeStore, Store);
<commit_msg>Lazy load SizeStore.get<commit_after>define(
  [
    'underscore',
    'stores/Store',
    'rsvp',
    'collections/SizeCollection',
    'dispatchers/AppDispatcher',
    'actions/SizeActions'
  ],
  function (_, Store, RSVP, SizeCollection, AppDispatcher, SizeActions) {

    var _sizes = {};
    var _isFetching = {};

    function fetchSizesForProviderIdentity(providerId, identityId){
      addEntriesForProviderIdentityIfNotExists(providerId, identityId);

      if(!_isFetching[providerId][identityId]) {
        _isFetching[providerId][identityId] = true;
        var sizes = new SizeCollection(null, {
          provider_id: providerId,
          identity_id: identityId
        });

        sizes.fetch().done(function () {
          _isFetching[providerId][identityId] = false;
           _sizes[providerId][identityId] = sizes;
          SizeStore.emitChange();
        });
      }
    }

    function addEntriesForProviderIdentityIfNotExists(providerId, identityId){
      // Add fetching entries, set default state to false
      _isFetching[providerId] = _isFetching[providerId] || {};
      _isFetching[providerId][identityId] = _isFetching[providerId][identityId] || false;

      // Add size entries (only needed for provider level, identity level can be undefined)
      _sizes[providerId] = _sizes[providerId] || {};
    }

    var SizeStore = {

      get: function (providerId, identityId) {
        addEntriesForProviderIdentityIfNotExists(providerId, identityId);

        if (!_sizes[providerId][identityId]) {
          fetchSizesForProviderIdentity(providerId, identityId);
        }
        return _sizes[providerId][identityId];
      }

    };

    AppDispatcher.register(function (payload) {
      var action = payload.action;

      switch (action.actionType) {
        // case SizeActions.SIZE_FETCH:
        //   fetchSizesForProviderIdentity(action.providerId, action.identityId);
        //   break;
      }

      return true;
    });

    _.extend(SizeStore, Store);

{'fraction_non_alphanumeric': 0.11359026369168357, 'fraction_numerical': 0.0, 'mean_word_length': 2.6260504201680672, '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': '2127795', 'n_tokens_mistral': 1001, 'n_tokens_neox': 983, 'n_words': 182}