<commit_before>/* globals Task */
const {Cu} = require("chrome");
const PocketFeed = require("./PocketFeed");
const {POCKET_STORIES_LENGTH} = require("common/constants");
const am = require("common/action-manager");
const {pocket_story_endpoint, pocket_consumer_key} = require("../../pocket.json");

Cu.import("resource://gre/modules/Task.jsm");

const UPDATE_TIME = 30 * 60 * 1000; // 30 minutes

module.exports = class PocketStoriesFeed extends PocketFeed {
  constructor(options) {
    super(options, UPDATE_TIME);
  }

  _fetchStories() {
    if (!pocket_story_endpoint || !pocket_consumer_key) {
      let err = "Pocket story endpoint not configured: Make sure to add endpoint URL and " +
        "API key to pocket.json (see pocket-example.json)";
      console.log(err); // eslint-disable-line no-console
      throw new Error(err);
    }

    let pocketUrl = `${pocket_story_endpoint}?consumer_key=${pocket_consumer_key}&count=${POCKET_STORIES_LENGTH}`;
    return this.fetch(pocketUrl).then(r => JSON.parse(r).list);
  }

  // XXX Need to remove parenthesis from image URLs as React will otherwise
  // fail to render them properly as part of the SpotlightItem template.
  // This is temporary until Pocket provides alternative image links (e.g. data URIs)
  _normalizeUrl(url) {
    if (url) {
      return url.replace(/\(/g, "%28").replace(/\)/g, "%29");<commit_msg>Fix(content): #2467 Dismissing a Pocket story doesn't add a new one<commit_after>/* globals Task */
const {Cu} = require("chrome");
const PocketFeed = require("./PocketFeed");
const am = require("common/action-manager");
const {pocket_story_endpoint, pocket_consumer_key} = require("../../pocket.json");

Cu.import("resource://gre/modules/Task.jsm");

const UPDATE_TIME = 30 * 60 * 1000; // 30 minutes

module.exports = class PocketStoriesFeed extends PocketFeed {
  constructor(options) {
    super(options, UPDATE_TIME);
  }

  _fetchStories() {
    if (!pocket_story_endpoint || !pocket_consumer_key) {
      let err = "Pocket story endpoint not configured: Make sure to add endpoint URL and " +
        "API key to pocket.json (see pocket-example.json)";
      console.log(err); // eslint-disable-line no-console
      throw new Error(err);
    }

    let pocketUrl = `${pocket_story_endpoint}?consumer_key=${pocket_consumer_key}`;
    return this.fetch(pocketUrl).then(r => JSON.parse(r).list);
  }

  // XXX Need to remove parenthesis from image URLs as React will otherwise
  // fail to render them properly as part of the SpotlightItem template.
  // This is temporary until Pocket provides alternative image links (e.g. data URIs)
  _normalizeUrl(url) {
    if (url) {
      return url.replace(/\(/g, "%28").replace(/\)/g, "%29");
{'fraction_non_alphanumeric': 0.13807069219440354, 'fraction_numerical': 0.011782032400589101, 'mean_word_length': 3.9221014492753623, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6322220', 'n_tokens_mistral': 883, 'n_tokens_neox': 815, 'n_words': 232}