<commit_before><?php
use \Tsugi\Util\U;
use \Tsugi\Blob\Access;

if ( ! isset($_REQUEST['days']) ) die('days required');
if ( ! isset($_GET['base']) ) die('Base required');

if ( ! defined('COOKIE_SESSION') ) define('COOKIE_SESSION', true);
require_once("../../config.php");
session_start();
require_once("../gate.php");
require_once("../admin_util.php");
require_once("expire_util.php");
if ( $REDIRECTED === true || ! isset($_SESSION["admin"]) ) return;

use \Tsugi\Core\LTIX;
LTIX::getConnection();

$base = $_GET['base'];
if ( $base == 'user' ) {
    $table = 'lti_user';
    $limit = 200;
    $where = '';
    $where = " AND user_id <> ".$_SESSION['id'].' ';
} else if ( $base == 'context' ) {
    $table = 'lti_context';
    $limit = 10;
    $where = '';
} else if ( $base == 'tenant' ) {
    $table = 'lti_key';
    $limit = 1;
    $where = " AND ".get_safe_key_where().' ';
} else {
    die('Invalid base value');
}

if ( ! isset($_GET['days']) ) die('Required parameter days');
if ( ! is_numeric($_GET['days']) ) die('days must be a number');
$days = $_GET['days'] + 0;
if ($days < 1 ) die('Bad value for days');

$count = get_expirable_records($table, $days);

$sql = "DELETE FROM {$CFG->dbprefix}{$table}\n".
    get_expirable_where($days)."\n".$where.<commit_msg>Updates<commit_after><?php
use \Tsugi\Util\U;
use \Tsugi\Blob\Access;

if ( ! isset($_REQUEST['days']) ) die('days required');
if ( ! isset($_GET['base']) ) die('Base required');

if ( ! defined('COOKIE_SESSION') ) define('COOKIE_SESSION', true);
require_once("../../config.php");
session_start();
require_once("../gate.php");
require_once("../admin_util.php");
require_once("expire_util.php");
if ( $REDIRECTED === true || ! isset($_SESSION["admin"]) ) return;

use \Tsugi\Core\LTIX;
LTIX::getConnection();

$base = $_GET['base'];
if ( $base == 'user' ) {
    $table = 'lti_user';
    $limit = 100; // Takes about 10 seconds
    $where = '';
    $where = " AND user_id <> ".$_SESSION['id'].' ';
} else if ( $base == 'context' ) {
    $table = 'lti_context';
    $limit = 10;
    $where = '';
} else if ( $base == 'tenant' ) {
    $table = 'lti_key';
    $limit = 1;
    $where = " AND ".get_safe_key_where().' ';
} else {
    die('Invalid base value');
}

if ( ! isset($_GET['days']) ) die('Required parameter days');
if ( ! is_numeric($_GET['days']) ) die('days must be a number');
$days = $_GET['days'] + 0;
if ($days < 1 ) die('Bad value for days');

$count = get_expirable_records($table, $days);

$sql = "DELETE FROM {$CFG->dbprefix}{$table}\n".
    get_expirable_where($days)."\n".$where.
{'fraction_non_alphanumeric': 0.23735408560311283, 'fraction_numerical': 0.007003891050583658, 'mean_word_length': 4.0810276679841895, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5369014', 'n_tokens_mistral': 961, 'n_tokens_neox': 942, 'n_words': 199}