<commit_before><?php

namespace TemperaturePi;

use PhpGpio\Sensors\DS18B20;

class Logger extends \SQlite3
{
    private $sensor;
    private $currentTemperature;
    private $dbPath;
    private $db;

    public function __construct()
    {
        $this->sensor = new DS18B20();
        $this->dbPath = __DIR__ . '/../../resources/sqlite/log.db';
        $this->db = 'temperature';
    }

    public function fetchAll()
    {
        $return = array();
        $this->open($this->dbPath);
        $result = $this->query('SELECT datetime, celsius FROM temperature');
        while ($row = $result->fetchArray()) {
            //$return[$row['datetime']] = $row['celsius'];
            $return[] = $row['celsius'];
        }
        $this->close();

        return $return;
    }

    public function writeJsDatas()
    {
        $jsFile = __DIR__ . "/../../web/js/data.js";
        $datas = $this->fetchAll();
        $jsContent = "var data = [['Date', 'Celsius']";
        foreach ($datas as $index=>$celsius) {
            $jsContent .= "\n,[$index,$celsius]";
        }<commit_msg>setting up the sensor (using the new guess method in the php-gpio API)<commit_after><?php

namespace TemperaturePi;

use PhpGpio\Sensors\DS18B20;

class Logger extends \SQlite3
{
    private $sensor;
    private $currentTemperature;
    private $dbPath;
    private $db;

    public function __construct()
    {
        $this->sensor = new DS18B20();
        $this->sensor->setup();
        $this->dbPath = __DIR__ . '/../../resources/sqlite/log.db';
        $this->db = 'temperature';
    }

    public function fetchAll()
    {
        $return = array();
        $this->open($this->dbPath);
        $result = $this->query('SELECT datetime, celsius FROM temperature');
        while ($row = $result->fetchArray()) {
            //$return[$row['datetime']] = $row['celsius'];
            $return[] = $row['celsius'];
        }
        $this->close();

        return $return;
    }

    public function writeJsDatas()
    {
        $jsFile = __DIR__ . "/../../web/js/data.js";
        $datas = $this->fetchAll();
        $jsContent = "var data = [['Date', 'Celsius']";
        foreach ($datas as $index=>$celsius) {
            $jsContent .= "\n,[$index,$celsius]";
        }
{'fraction_non_alphanumeric': 0.17558602388323752, 'fraction_numerical': 0.00796107916850951, 'mean_word_length': 2.1904090267983074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2461901', 'n_tokens_mistral': 733, 'n_tokens_neox': 695, 'n_words': 151}