<commit_before>import json
import time
import logging
import webapp2

from google.appengine.ext import ndb
from google.appengine.api import memcache
from datetime import datetime
from server_utils import valid_secret_key, json_serial, json_deserial

DEFAULT_ARTICLE_VALUE = 'default_url'


def article_key(url=DEFAULT_ARTICLE_VALUE):
    return ndb.Key('Article', url)

def add_article_to_cache(url, article_dict):
    if not memcache.add('{}:article'.format(url), json.dumps(article_dict, default=json_serial)):
        logging.error('Memcache set failed for article ' + article_dict["heading"])


class Article(ndb.Model):
    """A published article about German weightlifting"""
    url = ndb.StringProperty(indexed=True)
    publisher = ndb.StringProperty(indexed=True)
    heading = ndb.StringProperty(indexed=False)
    content = ndb.StringProperty(indexed=False)
    date = ndb.DateTimeProperty(auto_now=False)
    image = ndb.StringProperty(indexed=False)


class GetArticles(webapp2.RequestHandler):
    def get(self):<commit_msg>keep articles cached for one week<commit_after>import json
import time
import logging
import webapp2

from google.appengine.ext import ndb
from google.appengine.api import memcache
from datetime import datetime
from server_utils import valid_secret_key, json_serial, json_deserial

DEFAULT_ARTICLE_VALUE = 'default_url'


def article_key(url=DEFAULT_ARTICLE_VALUE):
    return ndb.Key('Article', url)

def add_article_to_cache(url, article_dict):
    if not memcache.add('{}:article'.format(url), json.dumps(article_dict, default=json_serial), time=60*60*24*7):
        logging.error('Memcache set failed for article ' + article_dict["heading"])


class Article(ndb.Model):
    """A published article about German weightlifting"""
    url = ndb.StringProperty(indexed=True)
    publisher = ndb.StringProperty(indexed=True)
    heading = ndb.StringProperty(indexed=False)
    content = ndb.StringProperty(indexed=False)
    date = ndb.DateTimeProperty(auto_now=False)
    image = ndb.StringProperty(indexed=False)


class GetArticles(webapp2.RequestHandler):
    def get(self):
{'fraction_non_alphanumeric': 0.09787234042553192, 'fraction_numerical': 0.005200945626477541, 'mean_word_length': 5.76038338658147, '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': '505588', 'n_tokens_mistral': 659, 'n_tokens_neox': 649, 'n_words': 147}