<commit_before>'use strict';

var fs = require('fs');
var os = require('os');
var path = require('path');
var winston = require('winston');
var config = require('./../lib/config');
var flickr = require('flickr-with-uploads');
var multiparty = require('multiparty');
var User = require('./../models/user');
var Photo = require('./../models/photo');

function Uploader() {}

function saveUser(email, firstName, lastName) {
  var user = new User();
  user.email = email;
  user.firstName = firstName;
  user.lastName = lastName;
  user.save();
  return user;
}

function savePhoto(photoData) {
  var photo = new Photo();
  photo.description = photoData.descr;
  photo.submitted = new Date();
  photo.latitude = photoData.lat;
  photo.longitude = photoData.lon;
  photo.user = photoData.user;
  photo.uploadStatus = 'UPLOADING';
  photo.save();
  return photo._id;
}

function streamToFlickr(photoId, payloadData, user) {
  // save the photo data
  var api = flickr(
    config.get('FLICKR_KEY'),
    config.get('FLICKR_SECRET'),
    config.get('FLICKR_OAUTH_KEY'),
    config.get('FLICKR_OAUTH_SECRET')
  );

  winston.info('Processing photo upload:' + JSON.stringify(payloadData));

  var opts = {
    method: 'upload',
    title: payloadData.descr,
    description: '',
    is_public: 0,
    is_friend: 1,
    is_family: 0,
    content_type: 1,
    hidden: 1,
    photo: fs.createReadStream(payloadData.fileName)
  };

  api(opts, function (err, data) {
    if (err) {
      winston.error('Photo metadata successfully saved');
      return;
    }

    var new_photo_id = data.photoid[0];
    winston.info('Photo ID:' + new_photo_id);
<commit_msg>Adding description to both photo title and description fields<commit_after>'use strict';

var fs = require('fs');
var os = require('os');
var path = require('path');
var winston = require('winston');
var config = require('./../lib/config');
var flickr = require('flickr-with-uploads');
var multiparty = require('multiparty');
var User = require('./../models/user');
var Photo = require('./../models/photo');

function Uploader() {}

function saveUser(email, firstName, lastName) {
  var user = new User();
  user.email = email;
  user.firstName = firstName;
  user.lastName = lastName;
  user.save();
  return user;
}

function savePhoto(photoData) {
  var photo = new Photo();
  photo.description = photoData.descr;
  photo.submitted = new Date();
  photo.latitude = photoData.lat;
  photo.longitude = photoData.lon;
  photo.user = photoData.user;
  photo.uploadStatus = 'UPLOADING';
  photo.save();
  return photo._id;
}

function streamToFlickr(photoId, payloadData, user) {
  // save the photo data
  var api = flickr(
    config.get('FLICKR_KEY'),
    config.get('FLICKR_SECRET'),
    config.get('FLICKR_OAUTH_KEY'),
    config.get('FLICKR_OAUTH_SECRET')
  );

  winston.info('Processing photo upload:' + JSON.stringify(payloadData));

  var opts = {
    method: 'upload',
    title: payloadData.descr,
    description: payloadData.descr,
    is_public: 0,
    is_friend: 1,
    is_family: 0,
    content_type: 1,
    hidden: 1,
    photo: fs.createReadStream(payloadData.fileName)
  };

  api(opts, function (err, data) {
    if (err) {
      winston.error('Photo metadata successfully saved');
      return;
    }

    var new_photo_id = data.photoid[0];
    winston.info('Photo ID:' + new_photo_id);

{'fraction_non_alphanumeric': 0.15061139278258276, 'fraction_numerical': 0.003578884580972264, 'mean_word_length': 3.7642045454545454, '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': '2172845', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1113, 'n_words': 259}