<commit_before><?php

defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
require APPPATH . '/libraries/REST_Controller.php';

/**
 * This is an example of a few basic user interaction methods you could use
 * all done with a hardcoded array
 *
 * @package         CodeIgniter
 * @subpackage      Rest Server
 * @category        Controller
 * @author          <NAME>, <NAME>
 * @license         MIT
 * @link            https://github.com/chriskacerguis/codeigniter-restserver
 */
class Api extends REST_Controller {

    function __construct()
    {
        // Construct the parent class
        parent::__construct();
		$this->load->model('daily_reports_model');	
        // Configure limits on our controller methods
        // Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
        $this->methods['users_get']['limit'] = 500; // 500 requests per hour per user/key
        $this->methods['users_post']['limit'] = 100; // 100 requests per hour per user/key
        $this->methods['users_delete']['limit'] = 50; // 50 requests per hour per user/key
    }
	
	public function dailyreport_post(){
		$emp_id = $this->post('id');
				
		$this->set_response($this->daily_reports_model->get_reports(array('users.emp_id' => $emp_id)), REST_Controller::HTTP_CREATED);
	}
	
	public function addingusers_post()
    {
        $this->load->model('users');	
        $data = array(
            'emp_id' => $this->post('emp_id'),
            'email' => $this->post('email'),
			'password' => '<PASSWORD>',
            'name' => $this->post('name'),
            'type' => $this->post('type'),
        );
		$message = ['status_msg' => 'User added'];
		if($this->users->insert_users($data)){
			$this->set_response($message, REST_Controller::HTTP_OK); // CREATED (200) being the HTTP response code			
		}else{
			$this->response(NULL, REST_Controller::HTTP_BAD_REQUEST);
		}
    }
	
	public function updateusers_post()
    {
		$message = ['status_msg' => 'User Updated'];
        $this->load->model('users');	
		if($this->users->update_users_api($this->post('emp_id'), $this->post('data'))){
			$this->set_response($message, REST_Controller::HTTP_OK); // CREATED (200) being the HTTP response code			
		}else{
			$this->response(NULL, REST_Controller::HTTP_BAD_REQUEST);
		}
    }
	
	public function qatrackerusers_get(){
		$this->load->model('users');	
		$emp_id = $this->get('emp_id');
		$users = $this->users->get_users(array('emp_id' => $emp_id));<commit_msg>Update user model API<commit_after><?php

defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
require APPPATH . '/libraries/REST_Controller.php';

/**
 * This is an example of a few basic user interaction methods you could use
 * all done with a hardcoded array
 *
 * @package         CodeIgniter
 * @subpackage      Rest Server
 * @category        Controller
 * @author          <NAME>, <NAME>
 * @license         MIT
 * @link            https://github.com/chriskacerguis/codeigniter-restserver
 */
class Api extends REST_Controller {

    function __construct()
    {
        // Construct the parent class
        parent::__construct();
		$this->load->model('daily_reports_model');	
        // Configure limits on our controller methods
        // Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
        $this->methods['users_get']['limit'] = 500; // 500 requests per hour per user/key
        $this->methods['users_post']['limit'] = 100; // 100 requests per hour per user/key
        $this->methods['users_delete']['limit'] = 50; // 50 requests per hour per user/key
    }
	
	public function dailyreport_post(){
		$emp_id = $this->post('id');
				
		$this->set_response($this->daily_reports_model->get_reports(array('users.emp_id' => $emp_id)), REST_Controller::HTTP_CREATED);
	}
	
	public function addingusers_post()
    {
        $this->load->model('users_model');	
        $data = array(
            'emp_id' => $this->post('emp_id'),
            'email' => $this->post('email'),
			'password' => '<PASSWORD>',
            'name' => $this->post('name'),
            'type' => $this->post('type'),
        );
		$message = ['status_msg' => 'User added'];
		if($this->users_model->insert_users($data)){
			$this->set_response($message, REST_Controller::HTTP_OK); // CREATED (200) being the HTTP response code			
		}else{
			$this->response(NULL, REST_Controller::HTTP_BAD_REQUEST);
		}
    }
	
	public function updateusers_post()
    {
		$message = ['status_msg' => 'User Updated'];
        $this->load->model('users_model');	
		if($this->users_model->update_users_api($this->post('emp_id'), $this->post('data'))){
			$this->set_response($message, REST_Controller::HTTP_OK); // CREATED (200) being the HTTP response code			
		}else{
			$this->response(NULL, REST_Controller::HTTP_BAD_REQUEST);
		}
    }
	
	public function qatrackerusers_post(){
		$this->load->model('users_model');	
		$emp_id = $this->post('emp_id');
		$users = $this->users_model->get_users(array('emp_id' => $emp_id));
{'fraction_non_alphanumeric': 0.15922107674684993, 'fraction_numerical': 0.008400152730049638, 'mean_word_length': 3.344112769485904, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 91, 'https://': 2, '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': '4645401', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1577, 'n_words': 372}