<commit_before>import Feature from 'ol/Feature';
import {fromExtent as polygonFromExtent} from 'ol/geom/Polygon';

export default [
  '$rootScope',
  'hs.compositions.service_parser',
  'config',
  '$q',
  '$http',
  'hs.map.service',
  'hs.utils.service',
  function ($rootScope, compositionParser, config, $q, $http, hsMap, utils) {
    const me = this;
    angular.extend(me, {
      data: {
        limit: 15,
      },
      getCompositionsQueryUrl(endpoint, params, bbox) {
        const query = params.query;
        const bboxDelimiter =
          endpoint.url.indexOf('cswClientRun.php') > 0 ? ',' : ' ';
        const serviceName = angular.isDefined(endpoint.serviceName)
          ? 'serviceName=&' + endpoint.serviceName
          : '';
        bbox = params.filterExtent
          ? encodeURIComponent(" and BBOX='" + bbox.join(bboxDelimiter) + "'")
          : '';
        const textFilter =
          query && angular.isDefined(query.title) && query.title != ''
            ? encodeURIComponent(
                " AND title like '*" +
                  query.title +
                  "*' OR abstract like '*" +
                  query.title +
                  "*'"
              )
            : '';
        const selected = [];
        let keywordFilter = '';
        let tmp = endpoint.url;
        angular.forEach(params.keywords, (value, key) => {
          if (value) {
            selected.push("subject='" + key + "'");
          }
        });
        if (selected.length > 0) {
          keywordFilter = encodeURIComponent(
            ' AND (' + selected.join(' OR ') + ')'
          );
        }

        tmp +=
          '?format=json&' +
          serviceName +
          'query=type%3Dapplication' +
          bbox +
          textFilter +
          keywordFilter +
          '&lang=eng&sortBy=' +
          params.sortBy +
          '&detail=summary&start=' +
          params.start +
          '&limit=' +
          params.limit;
        tmp = utils.proxify(tmp);
        return tmp;
      },

      loadList(endpoint, params, bbox, extentLayer) {
        endpoint.compositionsPaging.loaded = false;
        if (angular.isUndefined(params.sortBy)) {
          params.sortBy = 'bbox';
        }
        if (angular.isUndefined(params.start)) {
          params.start = endpoint.compositionsPaging.start;
        }
        if (angular.isUndefined(params.limit) || isNaN(params.limit)) {
          params.limit = endpoints.compositionsPaging.limit;
        }
        return new Promise((resolve, reject) => {
          if (angular.isDefined(me.canceler)) {
            me.canceler.resolve();
            delete me.canceler;
          }
          me.canceler = $q.defer();
          $http
            .get(me.getCompositionsQueryUrl(endpoint, params, bbox), {
              timeout: me.canceler.promise,
            })
            .then(
              (response) => {
                endpoint.compositionsPaging.loaded = true;
                response = response.data;
                endpoint.compositions = response.records;
                if (response.records && response.records.length > 0) {
                  endpoint.compositionsPaging.compositionsCount =
                    response.matched;
                } else {
                  endpoint.compositionsPaging.compositionsCount = 0;
                }
                //TODO: Needs refactoring
                endpoint.compositionsPaging.next = response.next;
                const mapExtent = hsMap.getMapExtent();
                angular.forEach(endpoint.compositions, (record) => {
                  const attributes = {
                    record: record,
                    hs_notqueryable: true,
                    highlighted: false,
                    title: record.title || record.name,
                  };
                  record.editable = false;
                  record.endpoint = endpoint;
                  if (angular.isUndefined(record.thumbnail)) {
                    record.thumbnail =
                      endpoint.url + '?request=loadthumb&id=' + record.id;
                  }
                  const extent = compositionParser.parseExtent(record.bbox);
                  //Check if height or Width covers the whole screen
                  if (
                    !(
                      (extent[0] < mapExtent[0] && extent[2] > mapExtent[2]) ||
                      (extent[1] < mapExtent[1] && extent[3] > mapExtent[3])
                    )
                  ) {
                    attributes.geometry = polygonFromExtent(extent);
                    attributes.is_hs_composition_extent = true;
                    const newFeature = new Feature(attributes);
                    record.feature = newFeature;
                    extentLayer.getSource().addFeatures([newFeature]);
                  } else {
                    //Composition not in extent
                  }
                });
                $rootScope.$broadcast('CompositionsLoaded');
                resolve();
              },
              (err) => {}
            );
        });
      },

      resetCompositionCounter(endpoint) {
        endpoint.compositionsPaging.start = 0;
        endpoint.compositionsPaging.next = me.data.limit;
      },
    });
    return me;
  },
];<commit_msg>Remove hardcoded composition query limit<commit_after>import Feature from 'ol/Feature';
import {fromExtent as polygonFromExtent} from 'ol/geom/Polygon';

export default [
  '$rootScope',
  'hs.compositions.service_parser',
  'config',
  '$q',
  '$http',
  'hs.map.service',
  'hs.utils.service',
  function ($rootScope, compositionParser, config, $q, $http, hsMap, utils) {
    const me = this;
    angular.extend(me, {
      getCompositionsQueryUrl(endpoint, params, bbox) {
        const query = params.query;
        const bboxDelimiter =
          endpoint.url.indexOf('cswClientRun.php') > 0 ? ',' : ' ';
        const serviceName = angular.isDefined(endpoint.serviceName)
          ? 'serviceName=&' + endpoint.serviceName
          : '';
        bbox = params.filterExtent
          ? encodeURIComponent(" and BBOX='" + bbox.join(bboxDelimiter) + "'")
          : '';
        const textFilter =
          query && angular.isDefined(query.title) && query.title != ''
            ? encodeURIComponent(
                " AND title like '*" +
                  query.title +
                  "*' OR abstract like '*" +
                  query.title +
                  "*'"
              )
            : '';
        const selected = [];
        let keywordFilter = '';
        let tmp = endpoint.url;
        angular.forEach(params.keywords, (value, key) => {
          if (value) {
            selected.push("subject='" + key + "'");
          }
        });
        if (selected.length > 0) {
          keywordFilter = encodeURIComponent(
            ' AND (' + selected.join(' OR ') + ')'
          );
        }

        tmp +=
          '?format=json&' +
          serviceName +
          'query=type%3Dapplication' +
          bbox +
          textFilter +
          keywordFilter +
          '&lang=eng&sortBy=' +
          params.sortBy +
          '&detail=summary&start=' +
          params.start +
          '&limit=' +
          params.limit;
        tmp = utils.proxify(tmp);
        return tmp;
      },

      loadList(endpoint, params, bbox, extentLayer) {
        endpoint.compositionsPaging.loaded = false;
        if (angular.isUndefined(params.sortBy)) {
          params.sortBy = 'bbox';
        }
        if (angular.isUndefined(params.start)) {
          params.start = endpoint.compositionsPaging.start;
        }
        if (angular.isUndefined(params.limit) || isNaN(params.limit)) {
          params.limit = endpoints.compositionsPaging.limit;
        }
        return new Promise((resolve, reject) => {
          if (angular.isDefined(me.canceler)) {
            me.canceler.resolve();
            delete me.canceler;
          }
          me.canceler = $q.defer();
          $http
            .get(me.getCompositionsQueryUrl(endpoint, params, bbox), {
              timeout: me.canceler.promise,
            })
            .then(
              (response) => {
                endpoint.compositionsPaging.loaded = true;
                response = response.data;
                endpoint.compositions = response.records;
                if (response.records && response.records.length > 0) {
                  endpoint.compositionsPaging.compositionsCount =
                    response.matched;
                } else {
                  endpoint.compositionsPaging.compositionsCount = 0;
                }
                //TODO: Needs refactoring
                endpoint.compositionsPaging.next = response.next;
                const mapExtent = hsMap.getMapExtent();
                angular.forEach(endpoint.compositions, (record) => {
                  const attributes = {
                    record: record,
                    hs_notqueryable: true,
                    highlighted: false,
                    title: record.title || record.name,
                  };
                  record.editable = false;
                  record.endpoint = endpoint;
                  if (angular.isUndefined(record.thumbnail)) {
                    record.thumbnail =
                      endpoint.url + '?request=loadthumb&id=' + record.id;
                  }
                  const extent = compositionParser.parseExtent(record.bbox);
                  //Check if height or Width covers the whole screen
                  if (
                    !(
                      (extent[0] < mapExtent[0] && extent[2] > mapExtent[2]) ||
                      (extent[1] < mapExtent[1] && extent[3] > mapExtent[3])
                    )
                  ) {
                    attributes.geometry = polygonFromExtent(extent);
                    attributes.is_hs_composition_extent = true;
                    const newFeature = new Feature(attributes);
                    record.feature = newFeature;
                    extentLayer.getSource().addFeatures([newFeature]);
                  } else {
                    //Composition not in extent
                  }
                });
                $rootScope.$broadcast('CompositionsLoaded');
                resolve();
              },
              (err) => {}
            );
        });
      },

      resetCompositionCounter(endpoint) {
        endpoint.compositionsPaging.start = 0;
        endpoint.compositionsPaging.next = endpoint.compositionsPaging.limit;
      },
    });
    return me;
  },
];
{'fraction_non_alphanumeric': 0.11555555555555555, 'fraction_numerical': 0.0028368794326241137, 'mean_word_length': 1.4279155188246098, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '6888303', 'n_tokens_mistral': 2871, 'n_tokens_neox': 2724, 'n_words': 479}