<commit_before>/**
 * Adds commas to a number
 * @param {number} number
 * @param {string} locale
 * @return {string}
 */

const Flickr = require('flickr-sdk');
const fs = require('fs');
const request = require('request');
const config = require('./config.js');

const PLUGIN_FOLDER = 'lr-latest.widget';

const flickr = new Flickr(config.flickr);

let randomAlbum;
let responsePhoto;
let photo;
let url;
let index;

const getWallpaper = () => {
  randomAlbum = config.wallpapers[Math.floor(Math.random() * config.wallpapers.length)];

  flickr
    .request()
    .albums(randomAlbum)
    .media()
    .get({
      extras: 'original_format',
    })
    .then((response) => {
      responsePhoto = response.body.photoset.photo;
      photo = responsePhoto[Math.floor(Math.random() * responsePhoto.length)];
      url = `https://farm${photo.farm}.staticflickr.com/${photo.server}/${photo.id}_${photo.originalsecret}_o.${photo.originalformat}`;

      request
        .get(url)
        .on('error', (err) => {
          console.log(err);
        })
        .pipe(
        fs.createWriteStream(
          `${PLUGIN_FOLDER}/wallpaper.${photo.originalformat}`,
        ),
      );
    },
    (err) => {
      console.log(err);
    },
  );
};

const getPictures = () => {
  const tags = config.tags;

  randomAlbum =
    config.galleries[Math.floor(Math.random() * config.galleries.length)];

  flickr
    .request()
    .people(config.personalId)
    .media()
    .get({
      media: 'photos',
      tags: tags.join(),
      sort: 'date-taken-desc',
      extras: 'tags, date_taken, date_upload',
    })
    .then((response) => {
      responsePhoto = response.body.photos.photo;
      for (let i = 0; i < responsePhoto.length && tags.length; i += 1) {
        photo = responsePhoto[i];
        index = tags.indexOf(photo.tags);

        if (photo.tags && index > -1) {
          url = `https://farm${photo.farm}.staticflickr.com/${photo.server}/${photo.id}_${photo.secret}_z.jpg`;

          request
            .get(url)
            .on('error', (err) => {
              console.log(err);
            })
            .pipe(fs.createWriteStream(`${PLUGIN_FOLDER}/${photo.tags}.jpg`));

          tags.splice(index, 1);
        }
      }
    },
    (err) => {
      console.log(err);
    },
  );
};

const init = () => {
  getPictures();<commit_msg>Adjusted index.js for Istanbul processing<commit_after>/**
 * Adds commas to a number
 * @param {number} number
 * @param {string} locale
 * @return {string}
 */

const Flickr = require('flickr-sdk');
const fs = require('fs');
const request = require('request');
const config = require('./config.js');

const PLUGIN_FOLDER = 'lr-latest.widget';

const flickr = new Flickr(config.flickr);

let randomAlbum;
let responsePhoto;
let photo;
let url;
let index;

const getWallpaper = () => {
  randomAlbum = config.wallpapers[Math.floor(Math.random() * config.wallpapers.length)];

  flickr
    .request()
    .albums(randomAlbum)
    .media()
    .get({
      extras: 'original_format',
    })
    .then((response) => {
      responsePhoto = response.body.photoset.photo;
      photo = responsePhoto[Math.floor(Math.random() * responsePhoto.length)];
      url = `https://farm${photo.farm}.staticflickr.com/${photo.server}/${photo.id}_${photo.originalsecret}_o.${photo.originalformat}`;

      request
        .get(url)
        .on('error', (err) => {
          console.log(err);
        })
        .pipe(fs.createWriteStream(`${PLUGIN_FOLDER}/wallpaper.${photo.originalformat}`));
    },
    (err) => {
      console.log(err);
    });
};

const getPictures = () => {
  const tags = config.tags;

  randomAlbum =
    config.galleries[Math.floor(Math.random() * config.galleries.length)];

  flickr
    .request()
    .people(config.personalId)
    .media()
    .get({
      media: 'photos',
      tags: tags.join(),
      sort: 'date-taken-desc',
      extras: 'tags, date_taken, date_upload',
    })
    .then((response) => {
      responsePhoto = response.body.photos.photo;
      for (let i = 0; i < responsePhoto.length && tags.length; i += 1) {
        photo = responsePhoto[i];
        index = tags.indexOf(photo.tags);

        if (photo.tags && index > -1) {
          url = `https://farm${photo.farm}.staticflickr.com/${photo.server}/${photo.id}_${photo.secret}_z.jpg`;

          request
            .get(url)
            .on('error', (err) => {
              console.log(err);
            })
            .pipe(fs.createWriteStream(`${PLUGIN_FOLDER}/${photo.tags}.jpg`));

          tags.splice(index, 1);
        }
      }
    },
    (err) => {
      console.log(err);
    });
};

const init = () => {
  getPictures();
{'fraction_non_alphanumeric': 0.17723960565795113, 'fraction_numerical': 0.0017145306472353193, 'mean_word_length': 2.4932634730538923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 4, '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': '3029512', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1527, 'n_words': 263}