<commit_before>CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetGraphDataForStat`(IN `statName` VARCHAR(20))
    READS SQL DATA
BEGIN

SET @minDate = CURDATE();
SET @intercept = 0;
SET @slope = 0;
SET @agent = '';

SELECT DISTINCT agent FROM RawStatsForAgent LIMIT 1 INTO @agent;

CALL GetRawStatForAgent(@agent, statName);
CALL GetBadgePrediction(statName);

SELECT MIN(`date`) FROM RawStatForAgent INTO @minDate;
SELECT MAX(`date`) FROM RawStatForAgent INTO @maxDate;

SELECT slope FROM BadgePrediction INTO @slope;
SELECT intercept FROM BadgePrediction INTO @intercept;

CREATE TEMPORARY TABLE GraphDataForStat
    SELECT dl.date `Date`,
	       r.value `Actual`,
           CEIL(@intercept + (@slope * (DATEDIFF(dl.date, @minDate) + 1))) `Regression`
      FROM RawStatForAgent r 
RIGHT JOIN Dates dl 
           ON dl.date = r.date
WHERE dl.date >= @minDate AND
      dl.date <= @maxDate;

END<commit_msg>Limiting graph data to last 30 days<commit_after>BEGIN

SET @minDate = CURDATE();
SET @intercept = 0;
SET @slope = 0;
SET @agent = '';

SELECT DISTINCT agent FROM RawStatsForAgent LIMIT 1 INTO @agent;

CALL GetRawStatForAgent(@agent, statName);
CALL GetBadgePrediction(statName);

SELECT MIN(`date`) FROM RawStatForAgent INTO @minDate;
SELECT MAX(`date`) FROM RawStatForAgent INTO @maxDate;

SELECT slope FROM BadgePrediction INTO @slope;
SELECT intercept FROM BadgePrediction INTO @intercept;

CREATE TEMPORARY TABLE GraphDataForStat
SELECT * FROM
   (SELECT dl.date `Date`,
	       r.value `Actual`,
           CEIL(@intercept + (@slope * (DATEDIFF(dl.date, @minDate) + 1))) `Regression`
      FROM RawStatForAgent r 
RIGHT JOIN Dates dl 
           ON dl.date = r.date
WHERE dl.date >= @minDate AND
      dl.date <= @maxDate 
ORDER BY Date DESC LIMIT 30) q
ORDER BY Date ASC;

END
{'fraction_non_alphanumeric': 0.10206358059118795, 'fraction_numerical': 0.007808142777467931, 'mean_word_length': 4.245614035087719, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '402481', 'n_tokens_mistral': 621, 'n_tokens_neox': 575, 'n_words': 191}