<commit_before>var Twit = Meteor.npmRequire('twit');

Tweet = {
  postForFlight: function (flight) {
    var flightTweetFactory = new FlightTweetFactory(flight);
    var tweetMessage = flightTweetFactory.build;

    this.twitterAPI.post('statuses/update', {status: tweetMessage}, Meteor.bindEnvironment(function (err, data, response) {
      if (err)
        console.log(err);
    }));
  },

  postForItem: function (item) {
    var flightNumber = Flights.findOne(item.flightId).number;
    var itemTweetFactory = new ItemTweetFactory(item);
    var tweetMessage = itemTweetFactory.build;

    this.twitterAPI.post('statuses/update', {status: tweetMessage}, Meteor.bindEnvironment(function (err, data, response) {
      if (response.statusCode === 200) {
        Items.update(item._id, {$set: {tweeted: true}});
      }
    }));
  },

  pickItemForTweet: function (flight) {
    var items = Items.find({flightId: flight._id, tweeted: false}).fetch();
    return _.sample(items);
  },

  twitterAPI: new Twit({
    consumer_key: 'kqAQtrale59wg7ymyppxnNQYY',
    consumer_secret: Meteor.settings.twitterConsumerSecret,
    access_token: '<KEY>',
    access_token_secret: Meteor.settings.twitterAccessTokenSecret
  })
};<commit_msg>Output error if any when tweeting item<commit_after>var Twit = Meteor.npmRequire('twit');

Tweet = {
  postForFlight: function (flight) {
    var flightTweetFactory = new FlightTweetFactory(flight);
    var tweetMessage = flightTweetFactory.build;

    this.twitterAPI.post('statuses/update', {status: tweetMessage}, Meteor.bindEnvironment(function (err, data, response) {
      if (err)
        console.log(err);
    }));
  },

  postForItem: function (item) {
    var flightNumber = Flights.findOne(item.flightId).number;
    var itemTweetFactory = new ItemTweetFactory(item);
    var tweetMessage = itemTweetFactory.build;

    this.twitterAPI.post('statuses/update', {status: tweetMessage}, Meteor.bindEnvironment(function (err, data, response) {
      if (err) console.log(err);
      if (response.statusCode === 200) {
        Items.update(item._id, {$set: {tweeted: true}});
      }
    }));
  },

  pickItemForTweet: function (flight) {
    var items = Items.find({flightId: flight._id, tweeted: false}).fetch();
    return _.sample(items);
  },

  twitterAPI: new Twit({
    consumer_key: 'kqAQtrale59wg7ymyppxnNQYY',
    consumer_secret: Meteor.settings.twitterConsumerSecret,
    access_token: '<KEY>',
    access_token_secret: Meteor.settings.twitterAccessTokenSecret
  })
};
{'fraction_non_alphanumeric': 0.1327503974562798, 'fraction_numerical': 0.0047694753577106515, 'mean_word_length': 4.105476673427992, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '791038', 'n_tokens_mistral': 848, 'n_tokens_neox': 793, 'n_words': 155}