<commit_before>(* © 2013 RunOrg *)

open Std

module Owner = type module [ `ServerAdmin ]
type owner = Owner.t

(* The token store is an event-independent table, because : 

   - There will be a LOT of token activity, possibly more than any other activity 
     except page views. Storing that in a stream will hurt in terms of migration 
     time.
   - We need instant reaction times when creating a new token. *)

let dbname = Cqrs.Names.independent "tokens" 1 

let () = 
  Cqrs.Sql.on_first_connection (Cqrs.Sql.command begin 
    "CREATE TABLE IF NOT EXISTS \"" ^ dbname ^ "\" ( "
    ^ "\"token\" CHAR(40) NOT NULL, "
    ^ "\"payload\" BYTEA NOT NULL, "
    ^ "\"created\" TIMESTAMP NOT NULL DEFAULT('now'), "
    ^ "PRIMARY KEY(\"token\"))"
  end []) ;

  (* 2 days is longer than the actual session life : this is a cleanup function, 
     not an invalidation function. Invalidation happens when loading data. *)
  Cqrs.Sql.on_first_connection (Cqrs.Sql.command begin 
    "DELETE FROM \"" ^ dbname ^ "\" WHERE \"created\" < timestamp 'now' - interval '2 days'"<commit_msg>Fix default token timestamp<commit_after>(* © 2013 RunOrg *)

open Std

module Owner = type module [ `ServerAdmin ]
type owner = Owner.t

(* The token store is an event-independent table, because : 

   - There will be a LOT of token activity, possibly more than any other activity 
     except page views. Storing that in a stream will hurt in terms of migration 
     time.
   - We need instant reaction times when creating a new token. *)

let dbname = Cqrs.Names.independent "tokens" 1 

let () = 
  Cqrs.Sql.on_first_connection (Cqrs.Sql.command begin 
    "CREATE TABLE IF NOT EXISTS \"" ^ dbname ^ "\" ( "
    ^ "\"token\" CHAR(40) NOT NULL, "
    ^ "\"payload\" BYTEA NOT NULL, "
    ^ "\"created\" TIMESTAMP NOT NULL DEFAULT now(), "
    ^ "PRIMARY KEY(\"token\"))"
  end []) ;

  (* 2 days is longer than the actual session life : this is a cleanup function, 
     not an invalidation function. Invalidation happens when loading data. *)
  Cqrs.Sql.on_first_connection (Cqrs.Sql.command begin 
    "DELETE FROM \"" ^ dbname ^ "\" WHERE \"created\" < timestamp 'now' - interval '2 days'"
{'fraction_non_alphanumeric': 0.11656723267553924, 'fraction_numerical': 0.008260670032124828, 'mean_word_length': 3.0595903165735567, 'pattern_counts': {'":': 0, '<': 5, '<?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': '889066', 'n_tokens_mistral': 697, 'n_tokens_neox': 644, 'n_words': 259}