<commit_before><?php

    function select() {
        echo "The select function is called.";
        exit;
    }

    function insert() {
        echo "The insert function is called.";
        exit;
    }

    function getAllTasksFromProject($projectId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE project_id = ? ORDER BY deadline ASC;");
        $stmt->execute([$projectId]);
        return $stmt->fetchAll();
    }

    function getAllCompletedTasksFromProject($projectId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE project_id = ? AND completer_id IS NOT NULL ORDER BY deadline ASC;");
        $stmt->execute([$projectId]);
        return $stmt->fetchAll();
    }

    function getAllUncompletedTasksFromProject($projectId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE project_id = ? AND completer_id IS NULL ORDER BY deadline ASC;");
        $stmt->execute([$projectId]);
        return $stmt->fetchAll();
    }

    function getTagFromTaskId($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT DISTINCT * FROM tag, task_tag WHERE task_id = ? AND tag.id = task_tag.tag_id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function createTask(){

        global $conn;
        $stmt = $conn->prepare("INSERT INTO task (id, name, description, deadline, creator_id, assigned_id, completer_id, project_id) VALUES (DEFAULT, ?, NULL, NULL, ?, NULL, NULL, ?) RETURNING id;");
        $stmt->execute(["New Task", $_SESSION['user_id'], $_SESSION['project_id']]);
        return $stmt->fetchAll();

    }

    function completeTask($taskId){
        global $conn;
        $stmt = $conn->prepare("UPDATE task SET completer_id = ? WHERE id = ?;");
        $stmt->execute([$_SESSION['user_id'], $taskId]);
    }

    function deleteTask($taskId){
        global $conn;
        $stmt = $conn->prepare("DELETE FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
    }

    function getTaskDetails($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    function getTaskComments($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT comment.creation_date, comment.content, user_table.name, user_table.photo_path FROM comment, user_table WHERE comment.id_task = ? AND comment.id_user = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    function getTaskName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT name FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskDescription($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT description FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskDeadline($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT deadline FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskCreatorName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT name FROM user_table, task WHERE task.id = ? AND task.creator_id = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskAssignedName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT DISTINCT user_table.name, user_table.id FROM user_table, task WHERE task.id = ? AND task.assigned_id = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    function getTaskCompleterName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT name FROM user_table, task WHERE task.id = ? AND task.completer_id = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTagsFromProject(){
        global $conn;
        $stmt = $conn->prepare("SELECT DISTINCT tag.name, tag.id FROM tag, task_tag, task, project WHERE project.id = ? AND task.project_id = project.id AND task_tag.task_id = task.id AND task_tag.tag_id = tag.id;");
        $stmt->execute([ $_SESSION['project_id']]);
        return $stmt->fetchAll();
    }

    function getProjectMembersNames($project){
        global $conn;
        $stmt = $conn->prepare('SELECT user_table.name, user_table.id FROM user_project, user_table WHERE id_project=? AND user_table.id=user_project.id_user');
        $stmt->execute([$project]);
        return $stmt->fetchAll();
    }

    function setTaskAssigned($assignedId, $taskId){
        global $conn;
        $stmt = $conn->prepare('UPDATE task SET assigned_id = ? WHERE id=?;');
        $stmt->execute([$assignedId,$taskId]);
    }

    function setTaskName($name, $taskId){
        global $conn;
        $stmt = $conn->prepare('UPDATE task SET name = ? WHERE id=?;');
        $stmt->execute([$name,$taskId]);<commit_msg>Getting all project tags from tasks and files<commit_after><?php

    function select() {
        echo "The select function is called.";
        exit;
    }

    function insert() {
        echo "The insert function is called.";
        exit;
    }

    function getAllTasksFromProject($projectId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE project_id = ? ORDER BY deadline ASC;");
        $stmt->execute([$projectId]);
        return $stmt->fetchAll();
    }

    function getAllCompletedTasksFromProject($projectId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE project_id = ? AND completer_id IS NOT NULL ORDER BY deadline ASC;");
        $stmt->execute([$projectId]);
        return $stmt->fetchAll();
    }

    function getAllUncompletedTasksFromProject($projectId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE project_id = ? AND completer_id IS NULL ORDER BY deadline ASC;");
        $stmt->execute([$projectId]);
        return $stmt->fetchAll();
    }

    function getTagFromTaskId($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT DISTINCT * FROM tag, task_tag WHERE task_id = ? AND tag.id = task_tag.tag_id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function createTask(){

        global $conn;
        $stmt = $conn->prepare("INSERT INTO task (id, name, description, deadline, creator_id, assigned_id, completer_id, project_id) VALUES (DEFAULT, ?, NULL, NULL, ?, NULL, NULL, ?) RETURNING id;");
        $stmt->execute(["New Task", $_SESSION['user_id'], $_SESSION['project_id']]);
        return $stmt->fetchAll();

    }

    function completeTask($taskId){
        global $conn;
        $stmt = $conn->prepare("UPDATE task SET completer_id = ? WHERE id = ?;");
        $stmt->execute([$_SESSION['user_id'], $taskId]);
    }

    function deleteTask($taskId){
        global $conn;
        $stmt = $conn->prepare("DELETE FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
    }

    function getTaskDetails($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT * FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    function getTaskComments($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT comment.creation_date, comment.content, user_table.name, user_table.photo_path FROM comment, user_table WHERE comment.id_task = ? AND comment.id_user = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    function getTaskName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT name FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskDescription($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT description FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskDeadline($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT deadline FROM task WHERE id = ?;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskCreatorName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT name FROM user_table, task WHERE task.id = ? AND task.creator_id = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTaskAssignedName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT DISTINCT user_table.name, user_table.id FROM user_table, task WHERE task.id = ? AND task.assigned_id = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    function getTaskCompleterName($taskId){
        global $conn;
        $stmt = $conn->prepare("SELECT name FROM user_table, task WHERE task.id = ? AND task.completer_id = user_table.id;");
        $stmt->execute([$taskId]);
        return $stmt->fetchAll();
    }

    function getTagsFromProject(){
        global $conn;
        $stmt = $conn->prepare("SELECT DISTINCT tag.name, tag.id FROM tag, file, file_tag, task_tag, task, project WHERE (project.id = ? AND task.project_id = project.id AND task_tag.task_id = task.id AND task_tag.tag_id = tag.id) OR (project.id = ? AND file.project_id = project.id AND file.id = file_tag.file_id AND file_tag.tag_id = tag.id);");
        $stmt->execute([$_SESSION['project_id'],$_SESSION['project_id']]);
        return $stmt->fetchAll();
    }

    function getProjectMembersNames($project){
        global $conn;
        $stmt = $conn->prepare('SELECT user_table.name, user_table.id FROM user_project, user_table WHERE id_project=? AND user_table.id=user_project.id_user');
        $stmt->execute([$project]);
        return $stmt->fetchAll();
    }

    function setTaskAssigned($assignedId, $taskId){
        global $conn;
        $stmt = $conn->prepare('UPDATE task SET assigned_id = ? WHERE id=?;');
        $stmt->execute([$assignedId,$taskId]);
    }

    function setTaskName($name, $taskId){
        global $conn;
        $stmt = $conn->prepare('UPDATE task SET name = ? WHERE id=?;');
        $stmt->execute([$name,$taskId]);
{'fraction_non_alphanumeric': 0.15147478591817318, 'fraction_numerical': 0.0, 'mean_word_length': 2.9016332590942837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 109, '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': '3273632', 'n_tokens_mistral': 3187, 'n_tokens_neox': 3109, 'n_words': 730}