public function getAssignmentsInPeriod()

in synergy/server/db/RunDAO.php [348:402]


    public function getAssignmentsInPeriod($id, $from, $to) {
        date_default_timezone_set('UTC');
        DB_DAO::connectDatabase();
        $handler = DB_DAO::getDB()->prepare("SELECT u.id AS uid, u.username, a.last_updated, a.started, a.issues, a.time_taken, u.first_name,a.keyword_id, u.last_name, p.name, a.state, a.number_of_cases, a.number_of_completed_cases,a.failed_cases,a.passed_cases, a.skipped_cases, k.keyword, a.specification_id,a.id as aid, sp.title as sptitle, a.created_by FROM (test_assignement a, user u, platform p, specification sp) LEFT JOIN keyword k ON k.id=a.keyword_id WHERE a.test_run_id=:id AND a.specification_id=sp.id AND p.id=a.platform_id AND a.user_id=u.id AND a.last_updated<=:t AND a.last_updated>=:f GROUP BY a.id ");
        $handler->bindValue(":id", $id);
        $handler->bindValue(":t", $to);
        $handler->bindValue(":f", $from);
        if (!$handler->execute()) {
            DB_DAO::throwDbError($handler->errorInfo());
        }

        $assignments = array();
        while ($row = $handler->fetch(PDO::FETCH_ASSOC)) {
            $tr = new TestAssignment($row["username"], $row["name"], $id, $row["keyword"], $row["number_of_cases"]);
            $tr->completed = $row["number_of_completed_cases"];
            $tr->createdBy = intval($row["created_by"]);
            if (strlen($row["keyword"]) < 1) {
                $tr->labelId = -1;
            } else {
                $tr->labelId = intval($row["keyword_id"]);
            }
            $tr->setLastUpdated($row["last_updated"]);
            $tr->setStarted($row["started"]);
            $tr->userDisplayName = $row["first_name"] . " " . $row["last_name"];
            $tr->failed = intval($row["failed_cases"]);
            $tr->passed = intval($row["passed_cases"]);
            $tr->skipped = intval($row["skipped_cases"]);
            $tr->userId = intval($row["uid"]);
            $tr->state = $row["state"];
            $tr->id = intval($row["aid"]);
            $tr->specification = $row["sptitle"];
            $tr->specificationId = intval($row["specification_id"]);

            if ($tr->completed === $tr->total) {
                if ($tr->failed > 0) {
                    $tr->info = "warning";
                } else {
                    $tr->info = "finished";
                }
            } else {
                if ($tr->completed > 0) {
                    $tr->info = "unfinished";
                } else {
                    $tr->info = "pending";
                }
            }

            $tr->timeToComplete = intval($row["time_taken"]);
            $tr->issues = explode(";", $row["issues"]);

            $tr->setTribesId($row["tribes_id"]);
            array_push($assignments, $tr);
        }
        return $assignments;
    }