<commit_before><?php

namespace Sessions;

class Controller_Sessions extends \Controller_Gate {
	
	public function action_index() {		
		Model_Session::scrub();
		
		$this->template->title = __('session.title');
		$data['sessions'] = Model_Session::get_by_user(\Auth::get_user()->id);			
		$this->template->content = \View::forge('index', $data);
	}
	
	/* Some shortcuts */
	public function action_yesterday() {
		\Response::redirect('sessions/'.date('Y-m-d', strtotime('-1day')));
	}
	
	public function action_today() {
		\Response::redirect('sessions/'.date('Y-m-d'));
	}
	
	public function action_tomorrow() {
		\Response::redirect('sessions/'.date('Y-m-d', strtotime('+1day')));
	}
		
	/**
	 * View a session with given date
	 * @param type $date
	 */
	public function action_view($date=null) {	
		$this->push_css('jquery.timepicker-1.3.5.min');
		$this->push_js(['jquery.timepicker-1.3.5.min', 'sessions-timepicker', 'sessions-modals']);
	
		$session = \Utils::valid_session($date, false);
		if(empty($session)) {
			// Create session if none exists
			$session = Model_Session::forge([
				'deadline' => $date. ' ' . Model_Session::DEADLINE_TIME,
				'date' => $date,
			])->save();
		} else if ($session->can_delay()) {
			// Automatically delay existing session<commit_msg>Fix bug on session creation (method call on boolean)<commit_after><?php

namespace Sessions;

class Controller_Sessions extends \Controller_Gate {
	
	public function action_index() {		
		Model_Session::scrub();
		
		$this->template->title = __('session.title');
		$data['sessions'] = Model_Session::get_by_user(\Auth::get_user()->id);			
		$this->template->content = \View::forge('index', $data);
	}
	
	/* Some shortcuts */
	public function action_yesterday() {
		\Response::redirect('sessions/'.date('Y-m-d', strtotime('-1day')));
	}
	
	public function action_today() {
		\Response::redirect('sessions/'.date('Y-m-d'));
	}
	
	public function action_tomorrow() {
		\Response::redirect('sessions/'.date('Y-m-d', strtotime('+1day')));
	}
		
	/**
	 * View a session with given date
	 * @param type $date
	 */
	public function action_view($date=null) {	
		$this->push_css('jquery.timepicker-1.3.5.min');
		$this->push_js(['jquery.timepicker-1.3.5.min', 'sessions-timepicker', 'sessions-modals']);
	
		$session = \Utils::valid_session($date, false);
		if(empty($session)) {
			// Create session if none exists
			$session = Model_Session::forge([
				'deadline' => $date. ' ' . Model_Session::DEADLINE_TIME,
				'date' => $date,
			]);
			$session->save();
		} 
		
		if ($session->can_delay()) {
			// Automatically delay existing session
{'fraction_non_alphanumeric': 0.19211634137007272, 'fraction_numerical': 0.006123230003827019, 'mean_word_length': 4.228, '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': '2765629', 'n_tokens_mistral': 983, 'n_tokens_neox': 875, 'n_words': 154}