<commit_before>'use strict';

/**
 * @ngdoc service
 * @name globiProtoApp.interactionHelper
 * @description
 * # interactionHelper
 * Factory in the globiProtoApp.
 */
angular.module('globiProtoApp')
  .factory('interactionHelper', function (images, taxonInteractionDetails, $q) {

    var imagePromise = function(taxonName) {
      var deferred = $q.defer();
      var result = images.get({taxon: taxonName}, function() {
        deferred.resolve(result);
      });
      return deferred.promise;
    };

    var parseImageResult = function(imageResponse) {
      return {
        scientificName: imageResponse.scientificName,
        commonName: imageResponse.commonName,
        thumbnailURL: imageResponse.thumbnailURL,
        imageURL: imageResponse.imageURL,
        infoURL: imageResponse.infoURL,
      };
    };

    var interactionDetailsPromise = function(sourceName, targetName, interactionType) {
      var deferred = $q.defer();
      var result = taxonInteractionDetails.query({
        sourceTaxon: sourceName,
        targetTaxon: targetName,
        interactionType: interactionType
      }, function() {
        deferred.resolve(result);
      });
      return deferred.promise;
    };

    // study_title is used as the unique id
    var parseStudies = function(interactionDetailsResponse) {
      var uniqueStudies = {};
      interactionDetailsResponse.forEach(function(detail) {
        // uniqueStudies[detail.study_title] = detail.study_url;
        uniqueStudies[detail.study_title] = {
          studyUrl: detail.study_url,
          studyCitation: detail.study_citation,
          studySourceCitation: detail.study_source_citation
        };
      });
      return Object.keys(uniqueStudies).map(function(studyTitle) {
        return {
          studyTitle: studyTitle,
          studyUrl: uniqueStudies[studyTitle].studyUrl,
          studyCitation: uniqueStudies[studyTitle].studyCitation,
          studySourceCitation: uniqueStudies[studyTitle].studySourceCitation
        };
      });
    };

    var parseGeo = function(interactionDetailsResponse) {
      var uniqueHolder = {};
      interactionDetailsResponse.forEach(function(interactionDetail) {
        if (interactionDetail.study_title && interactionDetail.latitude && interactionDetail.longitude) {
          var uniqueKey = interactionDetail.study_title.replace(/\s|\-/g, '') + interactionDetail.latitude.toString().replace('-','#') + '_' + interactionDetail.longitude.toString().replace('-','#');
          if (uniqueHolder[uniqueKey]) {
            uniqueHolder[uniqueKey].itemCount += 1;
            uniqueHolder[uniqueKey].message = uniqueHolder[uniqueKey].itemCount + ' Observations, ' + '<a target="_blank" href="' + interactionDetail.study_url + '">' + interactionDetail.study_title + '</a>';
          } else {
            uniqueHolder[uniqueKey] = {
              lat: interactionDetail.latitude,
              lng: interactionDetail.longitude,
              message: '1 Observation, ' + '<a target="_blank" href="' + interactionDetail.study_url + '">' + interactionDetail.study_title + '</a>',
              focus: true,
              draggable: false,
              itemCount: 1
            };
          }
        }
      });
      return uniqueHolder;
    };

    // Public API
    return {

      getSourceTargetDetails: function (sourceName, targetName, interactionType) {<commit_msg>#59 remove study title from map marker messages<commit_after>'use strict';

/**
 * @ngdoc service
 * @name globiProtoApp.interactionHelper
 * @description
 * # interactionHelper
 * Factory in the globiProtoApp.
 */
angular.module('globiProtoApp')
  .factory('interactionHelper', function (images, taxonInteractionDetails, $q) {

    var imagePromise = function(taxonName) {
      var deferred = $q.defer();
      var result = images.get({taxon: taxonName}, function() {
        deferred.resolve(result);
      });
      return deferred.promise;
    };

    var parseImageResult = function(imageResponse) {
      return {
        scientificName: imageResponse.scientificName,
        commonName: imageResponse.commonName,
        thumbnailURL: imageResponse.thumbnailURL,
        imageURL: imageResponse.imageURL,
        infoURL: imageResponse.infoURL,
      };
    };

    var interactionDetailsPromise = function(sourceName, targetName, interactionType) {
      var deferred = $q.defer();
      var result = taxonInteractionDetails.query({
        sourceTaxon: sourceName,
        targetTaxon: targetName,
        interactionType: interactionType
      }, function() {
        deferred.resolve(result);
      });
      return deferred.promise;
    };

    // study_title is used as the unique id
    var parseStudies = function(interactionDetailsResponse) {
      var uniqueStudies = {};
      interactionDetailsResponse.forEach(function(detail) {
        uniqueStudies[detail.study_title] = {
          studyUrl: detail.study_url,
          studyCitation: detail.study_citation,
          studySourceCitation: detail.study_source_citation
        };
      });
      return Object.keys(uniqueStudies).map(function(studyTitle) {
        return {
          studyTitle: studyTitle,
          studyUrl: uniqueStudies[studyTitle].studyUrl,
          studyCitation: uniqueStudies[studyTitle].studyCitation,
          studySourceCitation: uniqueStudies[studyTitle].studySourceCitation
        };
      });
    };

    var parseGeo = function(interactionDetailsResponse) {
      var uniqueHolder = {};
      interactionDetailsResponse.forEach(function(interactionDetail) {
        if (interactionDetail.study_title && interactionDetail.latitude && interactionDetail.longitude) {
          var uniqueKey = interactionDetail.study_title.replace(/\s|\-/g, '') + interactionDetail.latitude.toString().replace('-','#') + '_' + interactionDetail.longitude.toString().replace('-','#');
          if (uniqueHolder[uniqueKey]) {
            uniqueHolder[uniqueKey].itemCount += 1;
            uniqueHolder[uniqueKey].message = '<a target="_blank" href="' + interactionDetail.study_url + '">' +
              uniqueHolder[uniqueKey].itemCount + ' Observations</a>';
          } else {
            uniqueHolder[uniqueKey] = {
              lat: interactionDetail.latitude,
              lng: interactionDetail.longitude,
              message: '<a target="_blank" href="' + interactionDetail.study_url + '">' + '1 Observation</a>',
              focus: true,
              draggable: false,
              itemCount: 1
            };
          }
        }
      });
      return uniqueHolder;
    };

    // Public API
    return {

      getSourceTargetDetails: function (sourceName, targetName, interactionType) {
{'fraction_non_alphanumeric': 0.11257288084915533, 'fraction_numerical': 0.0011959934220361788, 'mean_word_length': 2.7796610169491527, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1201841', 'n_tokens_mistral': 1814, 'n_tokens_neox': 1721, 'n_words': 319}