| @@ 43-58 (lines=16) @@ | ||
| 40 | * |
|
| 41 | * @return int |
|
| 42 | */ |
|
| 43 | public function previous_run() { |
|
| 44 | $b = $this->result_db->builder(); |
|
| 45 | $res = $b |
|
| 46 | ->select("id") |
|
| 47 | ->from("runs") |
|
| 48 | ->orderBy("id", "DESC") |
|
| 49 | ->setMaxResults(2) |
|
| 50 | ->execute(); |
|
| 51 | // Drop current |
|
| 52 | $res->fetch(); |
|
| 53 | $res = $res->fetch(); |
|
| 54 | if ($res) { |
|
| 55 | return (int)$res["id"]; |
|
| 56 | } |
|
| 57 | throw new \RuntimeException("Result database contains no previous run."); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Get the id of previous run with another commit id as current run. |
|
| @@ 113-126 (lines=14) @@ | ||
| 110 | * @param int $run |
|
| 111 | * @return array<string,string> with keys 'commit_hash' |
|
| 112 | */ |
|
| 113 | public function run_info($run) { |
|
| 114 | $b = $this->result_db->builder(); |
|
| 115 | $res = $b |
|
| 116 | ->select("commit_hash") |
|
| 117 | ->from("runs") |
|
| 118 | ->where("id = ?") |
|
| 119 | ->setParameter(0, $run) |
|
| 120 | ->execute() |
|
| 121 | ->fetch(); |
|
| 122 | if ($res) { |
|
| 123 | return $res; |
|
| 124 | } |
|
| 125 | throw new \RuntimeException("Result database contains no run with id '$run'."); |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * Get the amount of violations in a run. |
|
| @@ 262-275 (lines=14) @@ | ||
| 259 | * @param int $rule |
|
| 260 | * @return array<string,string> with keys 'rule', 'explanation' |
|
| 261 | */ |
|
| 262 | public function rule_info($rule) { |
|
| 263 | $b = $this->result_db->builder(); |
|
| 264 | $res = $b |
|
| 265 | ->select("rule", "explanation") |
|
| 266 | ->from("rules") |
|
| 267 | ->where("rules.id = ?") |
|
| 268 | ->setParameter(0, $rule) |
|
| 269 | ->execute() |
|
| 270 | ->fetch(); |
|
| 271 | if ($res) { |
|
| 272 | return $res; |
|
| 273 | } |
|
| 274 | throw new \RuntimeException("Result database contains no rule with id '$rule'."); |
|
| 275 | } |
|
| 276 | ||
| 277 | /** |
|
| 278 | * Get the violations of a rule. |
|