<commit_before>import Ember from 'ember';
import TravisCache from 'ember-travis-status/services/travis-cache';

export default function getTravisStatus(repo, branch) {
  const cachedValue = TravisCache[repo]; // Incase repo is not passed
  let url;

  console.log();

  if (!repo) {
    return;
  } else if (cachedValue) {
    Ember.debug(`Returning cached value for ${repo}`);

    return new Ember.RSVP.Promise(function(resolve) {
      resolve(cachedValue);
    });
  }

  url = `https://api.travis-ci.org/repos/${repo}/builds`;

  if (branch) {
    url += `?${branch}`;
  }

  return new Ember.RSVP.Promise(function(resolve, reject) {
    Ember.$.get(url).done(function(builds) {
      const latestBuildResult = builds[0]['result'];

      let status = 'failing';

      Ember.debug(`Fetched new value for ${repo}`);

      if (latestBuildResult === 0) {
        status = 'passing';
      }

      TravisCache[repo] = status;

      resolve(status);
    }).fail(function(data) {
      reject(data);
    });
  });
}<commit_msg>Switch statement used to avoid jshint errors<commit_after>import Ember from 'ember';
import TravisCache from 'ember-travis-status/services/travis-cache';

export default function getTravisStatus(repo, branch) {
  const cachedValue = TravisCache[repo]; // Incase repo is not passed
  let url;

  console.log();

  if (!repo) {
    return;
  } else if (cachedValue) {
    Ember.debug(`Returning cached value for ${repo}`);

    return new Ember.RSVP.Promise(function(resolve) {
      resolve(cachedValue);
    });
  }

  url = `https://api.travis-ci.org/repos/${repo}/builds`;

  if (branch) {
    url += `?${branch}`;
  }

  return new Ember.RSVP.Promise(function(resolve, reject) {
    Ember.$.get(url).done(function(builds) {
      const latestBuildResult = builds[0]['result'];

      let status;

      Ember.debug(`Fetched new value for ${repo}`);

      switch (latestBuildResult) {
        case 0: status = 'passing'; break;
        case 1: status = 'failing'; break;
        default: status = 'Unknown';
      }

      TravisCache[repo] = status;

      resolve(status);
    }).fail(function(data) {
      reject(data);
    });
  });
}
{'fraction_non_alphanumeric': 0.15239410681399632, 'fraction_numerical': 0.0023020257826887663, 'mean_word_length': 3.0845864661654137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2208361', 'n_tokens_mistral': 719, 'n_tokens_neox': 704, 'n_words': 157}