<commit_before>"""Trivial redis store for domains.

Will be used to store a 7-day sliding window count of domains appearing in
delta reports.
"""
import contextlib
import os

import redis


EXPIRY = 604800  # 7 days in seconds.


class RedisStatsStore(object):
    """The store for the statistics."""<commit_msg>Code example for the dataclip<commit_after>"""Trivial redis store for domains.

Will be used to store a 7-day sliding window count of domains appearing in
delta reports.

Reads from Heroku Dataclip of domains in delta reports, writes to Redis.

Dataclip is:

    select distinct delta_value->0 as domain
    from (
      select
        json_array_elements(data.value::json->'new')::jsonb as delta_value
      from data
      union all
      select
        json_array_elements(data.value::json->'updated')::jsonb as delta_value
      from data
      union all
      select
        json_array_elements(data.value::json->'deleted')::jsonb as delta_value
      from data
    ) as delta_values
"""
import contextlib
import os

import redis


EXPIRY = 604800  # 7 days in seconds.


class RedisStatsStore(object):
    """The store for the statistics."""
{'fraction_non_alphanumeric': 0.07765314926660914, 'fraction_numerical': 0.014667817083692839, 'mean_word_length': 3.427480916030534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1200792', 'n_tokens_mistral': 353, 'n_tokens_neox': 332, 'n_words': 127}