<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from . import Opml, Feed
from . import HackerNews, Reddit
from tornado import gen, queues
from tornado.ioloop import IOLoop
from concurrent.futures import ThreadPoolExecutor
from motor.motor_tornado import MotorClient

thread_pool = ThreadPoolExecutor(2)

feeds = queues.Queue()
entries = queues.Queue()
client = MotorClient(os.environ['MONGO_ENTRIES'])
db = client['entries-by-votes']

ENTRIES_AGE = float(os.environ.get('ENTRIES_AGE', 7))


@gen.coroutine
def do_insert_entry(entry):
    yield db.entries.update_one(
        {'link': entry['link']}, {'$set': entry}, upsert=True
    )


@gen.coroutine
def get_feeds():
    return (yield thread_pool.submit(Opml().get_feeds))


@gen.coroutine
def get_entries(url, title):
    return (yield thread_pool.submit(Feed(url, title).get_entries))
<commit_msg>entries ages to 14<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from . import Opml, Feed
from . import HackerNews, Reddit
from tornado import gen, queues
from tornado.ioloop import IOLoop
from concurrent.futures import ThreadPoolExecutor
from motor.motor_tornado import MotorClient

thread_pool = ThreadPoolExecutor(2)

feeds = queues.Queue()
entries = queues.Queue()
client = MotorClient(os.environ['MONGO_ENTRIES'])
db = client['entries-by-votes']

ENTRIES_AGE = float(os.environ.get('ENTRIES_AGE', 14))


@gen.coroutine
def do_insert_entry(entry):
    yield db.entries.update_one(
        {'link': entry['link']}, {'$set': entry}, upsert=True
    )


@gen.coroutine
def get_feeds():
    return (yield thread_pool.submit(Opml().get_feeds))


@gen.coroutine
def get_entries(url, title):
    return (yield thread_pool.submit(Feed(url, title).get_entries))

{'fraction_non_alphanumeric': 0.13287514318442153, 'fraction_numerical': 0.005154639175257732, 'mean_word_length': 5.108391608391608, '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': '1166659', 'n_tokens_mistral': 617, 'n_tokens_neox': 595, 'n_words': 137}