<commit_before>var self = require('sdk/self');

// a dummy function, to show how tests work.
// to see how to test this function, look at test/test-index.js
function dummy(text, callback) {
  callback(text);
}

exports.dummy = dummy;<commit_msg>getting url from calvin-backend and reloading to a pinned tab<commit_after>var self = require('sdk/self');
var { getTabForId, setTabURL } = require ("sdk/tabs/utils");
var tabID = "calvin-bot-tab";
var tabs = require("sdk/tabs");
var { setInterval } = require("sdk/timers");
var delay = 1000 * 60

tabs.open({
  url: "http://www.moldedbits.com",
  onReady: function onReady(tab) {
  },
  isPinned: true,
  onActivate: function onActivate(tab) {
    reloadURLFromBackend()
    tabID = tab.id;
  }
});

function reloadURLFromBackend() {
    var Request = require("sdk/request").Request;
    var randomURL = Request({
      url: "http://calvin-backend.herokuapp.com/data/get_random_url.json",
      onComplete: function (response) {
        var newURL = response.json.url;
        console.log("success with URL:- " + newURL);
        openRandomURL(newURL);
      }
    }).get();
}

function openRandomURL(url) {
  setTabURL(getTabForId(tabID), url)
}

setInterval(function() {
  reloadURLFromBackend()
}, delay)
{'fraction_non_alphanumeric': 0.14604948124501196, 'fraction_numerical': 0.004788507581803671, 'mean_word_length': 3.8230769230769233, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4053048', 'n_tokens_mistral': 423, 'n_tokens_neox': 411, 'n_words': 99}