<commit_before><?php

namespace Model;

use SimpleValidator\Validator;
use SimpleValidator\Validators;

/**
 * Timetable time off
 *
 * @package  model
 * @author   <NAME>
 */
class TimetableOff extends Base
{
    /**
     * SQL table name
     *
     * @var string
     */
    const TABLE = 'timetable_off';

    /**
     * Get query to fetch everything (pagination)
     *
     * @access public
     * @param  integer  $user_id  User id
     * @return \PicoDb\Table
     */
    public function getUserQuery($user_id)
    {
        return $this->db->table(static::TABLE)->eq('user_id', $user_id);
    }

    /**
     * Get the timetable for a given user
     *
     * @access public
     * @param  integer  $user_id  User id
     * @return array
     */
    public function getByUser($user_id)
    {
        return $this->db->table(static::TABLE)->eq('user_id', $user_id)->desc('date')->asc('start')->findAll();
    }

    /**
     * Get the timetable for a given user
     *
     * @access public
     * @param  integer  $user_id  User id
     * @param  string   $start_date
     * @param  string   $end_date
     * @return array
     */
    public function getByUserAndDate($user_id, $start_date, $end_date)
    {
        return $this->db->table(static::TABLE)
                        ->eq('user_id', $user_id)
                        ->gte('date', $start_date)
                        ->lte('date', $end_date)
                        ->desc('date')
                        ->asc('start')
                        ->findAll();
    }

    /**
     * Add a new time slot in the database
     *
     * @access public
     * @param  integer   $user_id   User id
     * @param  string    $date      Day (ISO8601 format)
     * @param  boolean   $all_day   All day flag
     * @param  float     $start     Start hour (24h format)
     * @param  float     $end       End hour (24h format)
     * @param  string    $comment
     * @return boolean|integer
     */
    public function create($user_id, $date, $all_day, $start = '', $end = '', $comment = '')
    {
        $values = array(
            'user_id' => $user_id,
            'date' => $date,
            'all_day' => $all_day,
            'start' => $all_day ? '' : $start,
            'end' => $all_day ? '' : $end,<commit_msg>Fix postgres issue with time-off timetable<commit_after><?php

namespace Model;

use SimpleValidator\Validator;
use SimpleValidator\Validators;

/**
 * Timetable time off
 *
 * @package  model
 * @author   <NAME>
 */
class TimetableOff extends Base
{
    /**
     * SQL table name
     *
     * @var string
     */
    const TABLE = 'timetable_off';

    /**
     * Get query to fetch everything (pagination)
     *
     * @access public
     * @param  integer  $user_id  User id
     * @return \PicoDb\Table
     */
    public function getUserQuery($user_id)
    {
        return $this->db->table(static::TABLE)->eq('user_id', $user_id);
    }

    /**
     * Get the timetable for a given user
     *
     * @access public
     * @param  integer  $user_id  User id
     * @return array
     */
    public function getByUser($user_id)
    {
        return $this->db->table(static::TABLE)->eq('user_id', $user_id)->desc('date')->asc('start')->findAll();
    }

    /**
     * Get the timetable for a given user
     *
     * @access public
     * @param  integer  $user_id  User id
     * @param  string   $start_date
     * @param  string   $end_date
     * @return array
     */
    public function getByUserAndDate($user_id, $start_date, $end_date)
    {
        return $this->db->table(static::TABLE)
                        ->eq('user_id', $user_id)
                        ->gte('date', $start_date)
                        ->lte('date', $end_date)
                        ->desc('date')
                        ->asc('start')
                        ->findAll();
    }

    /**
     * Add a new time slot in the database
     *
     * @access public
     * @param  integer   $user_id   User id
     * @param  string    $date      Day (ISO8601 format)
     * @param  boolean   $all_day   All day flag
     * @param  float     $start     Start hour (24h format)
     * @param  float     $end       End hour (24h format)
     * @param  string    $comment
     * @return boolean|integer
     */
    public function create($user_id, $date, $all_day, $start = '', $end = '', $comment = '')
    {
        $values = array(
            'user_id' => $user_id,
            'date' => $date,
            'all_day' => (int) $all_day, // Postgres fix
            'start' => $all_day ? '' : $start,
            'end' => $all_day ? '' : $end,
{'fraction_non_alphanumeric': 0.1363537827877737, 'fraction_numerical': 0.0034684587036635595, 'mean_word_length': 1.7513416815742398, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, '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': '1521562', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1432, 'n_words': 357}