<commit_before>module.exports = function(EventSchema) {
  const URL = 'https://www.toimintasuomi.fi/api/v1/vapaaehtoistoiminta.json';

  let request = require('request');

  request(URL, function(error, response, body) {
    let events = JSON.parse(body);

    let hasCoordinates = e => e.coordinates && e.coordinates.length === 2;
    let eventsWithCoordinates = events.filter(hasCoordinates);

    eventsWithCoordinates.forEach(function(e) {
      let event = {
        category: 'voluntaryWork',
        coordinates: {
          latitude: e.coordinates[0],
          longitude: e.coordinates[1]
        },
        name: e.title,
        originalId: e.id,
        origin: 'toimintasuomi',
        url: e.uri
      };

      EventSchema.findOneAndUpdate(
        {originalId: event.originalId},
        event,
        {upsert: true},
        function(error) {
          if (error) {
            console.log(error);
          }
        }<commit_msg>Swap lat and lon in toimintasuomi miner<commit_after>module.exports = function(EventSchema) {
  const URL = 'https://www.toimintasuomi.fi/api/v1/vapaaehtoistoiminta.json';

  let request = require('request');

  request(URL, function(error, response, body) {
    let events = JSON.parse(body);

    let hasCoordinates = e => e.coordinates && e.coordinates.length === 2;
    let eventsWithCoordinates = events.filter(hasCoordinates);

    eventsWithCoordinates.forEach(function(e) {
      let event = {
        category: 'voluntaryWork',
        coordinates: {
          longitude: e.coordinates[0],
          latitude: e.coordinates[1]
        },
        name: e.title,
        originalId: e.id,
        origin: 'toimintasuomi',
        url: e.uri
      };

      EventSchema.findOneAndUpdate(
        {originalId: event.originalId},
        event,
        {upsert: true},
        function(error) {
          if (error) {
            console.log(error);
          }
        }
{'fraction_non_alphanumeric': 0.12266112266112267, 'fraction_numerical': 0.004158004158004158, 'mean_word_length': 2.30188679245283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '800386', 'n_tokens_mistral': 605, 'n_tokens_neox': 589, 'n_words': 110}