Improve egg:refresh performance a bit
This commit is contained in:
parent
1084bd36a6
commit
16051928c1
42
www/extern/egg/EGGDatabase.php
vendored
42
www/extern/egg/EGGDatabase.php
vendored
@ -104,9 +104,22 @@ class EGGDatabase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$r = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
return $r;
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sql_query_assoc_pre_prep(PDOStatement $stmt, array $params)
|
||||||
|
{
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($params as $p)
|
||||||
|
{
|
||||||
|
if (strpos($stmt->queryString, $p[0]) !== FALSE) $stmt->bindValue($p[0], $p[1], $p[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sql_exec_prep(string $query, array $params)
|
public function sql_exec_prep(string $query, array $params)
|
||||||
@ -123,6 +136,20 @@ class EGGDatabase
|
|||||||
return $stmt->rowCount();
|
return $stmt->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sql_exec_pre_prep(PDOStatement $stmt, array $params)
|
||||||
|
{
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($params as $p)
|
||||||
|
{
|
||||||
|
if (str_contains($stmt->queryString, $p[0])) $stmt->bindValue($p[0], $p[1], $p[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
return $stmt->rowCount();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param string $name
|
* @param string $name
|
||||||
@ -224,17 +251,22 @@ class EGGDatabase
|
|||||||
public function insertNewCommits(string $source, Repository $repo, Branch $branch, array $commits) {
|
public function insertNewCommits(string $source, Repository $repo, Branch $branch, array $commits) {
|
||||||
$this->logger->proclog("Inserting " . count($commits) . " (new) commits into [" . $source . "|" . $repo->Name . "|" . $branch->Name . "]");
|
$this->logger->proclog("Inserting " . count($commits) . " (new) commits into [" . $source . "|" . $repo->Name . "|" . $branch->Name . "]");
|
||||||
|
|
||||||
|
|
||||||
|
$stmtAddCommit = $this->pdo->prepare("INSERT INTO commits ([branch_id], [hash]) VALUES (:brid, :sha)");
|
||||||
|
$stmtAddMD = $this->pdo->prepare("INSERT OR IGNORE INTO metadata ([hash], [author_name], [author_email], [committer_name], [committer_email], [message], [date], [parent_commits]) VALUES (:sha, :an, :am, :cn, :cm, :msg, :dat, :prt)");
|
||||||
|
$stmtGetID = $this->pdo->prepare("SELECT id FROM commits WHERE [branch_id] = :brid AND [Hash] = :sha");
|
||||||
|
|
||||||
foreach ($commits as $commit)
|
foreach ($commits as $commit)
|
||||||
{
|
{
|
||||||
$strparents = implode(";", $commit->Parents);
|
$strparents = implode(";", $commit->Parents);
|
||||||
|
|
||||||
$this->sql_exec_prep("INSERT INTO commits ([branch_id], [hash]) VALUES (:brid, :sha)",
|
$this->sql_exec_pre_prep($stmtAddCommit,
|
||||||
[
|
[
|
||||||
[":brid", $branch->ID, PDO::PARAM_INT],
|
[":brid", $branch->ID, PDO::PARAM_INT],
|
||||||
[":sha", $commit->Hash, PDO::PARAM_STR],
|
[":sha", $commit->Hash, PDO::PARAM_STR],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->sql_exec_prep("INSERT OR IGNORE INTO metadata ([hash], [author_name], [author_email], [committer_name], [committer_email], [message], [date], [parent_commits]) VALUES (:sha, :an, :am, :cn, :cm, :msg, :dat, :prt)",
|
$this->sql_exec_pre_prep($stmtAddMD,
|
||||||
[
|
[
|
||||||
[":sha", $commit->Hash, PDO::PARAM_STR],
|
[":sha", $commit->Hash, PDO::PARAM_STR],
|
||||||
[":an", $commit->AuthorName, PDO::PARAM_STR],
|
[":an", $commit->AuthorName, PDO::PARAM_STR],
|
||||||
@ -246,7 +278,7 @@ class EGGDatabase
|
|||||||
[":prt", $strparents, PDO::PARAM_STR],
|
[":prt", $strparents, PDO::PARAM_STR],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dbid = $this->sql_query_assoc_prep("SELECT id FROM commits WHERE [branch_id] = :brid AND [Hash] = :sha",
|
$dbid = $this->sql_query_assoc_pre_prep($stmtGetID,
|
||||||
[
|
[
|
||||||
[":brid", $branch->ID, PDO::PARAM_INT],
|
[":brid", $branch->ID, PDO::PARAM_INT],
|
||||||
[":sha", $commit->Hash, PDO::PARAM_STR],
|
[":sha", $commit->Hash, PDO::PARAM_STR],
|
||||||
|
3
www/extern/egg/RemoteSource.php
vendored
3
www/extern/egg/RemoteSource.php
vendored
@ -90,7 +90,6 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
if ($repo_changed) $anyChanged = true;
|
if ($repo_changed) $anyChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->proclog("Committing SQL-transaction for [" . $this->name . "|" . $repo->Name . "]");
|
|
||||||
$db->commitTransaction();
|
$db->commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +346,7 @@ abstract class StandardGitConnection implements IRemoteSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($branch->Head === null) {
|
if ($branch->Head === null) {
|
||||||
$this->logger->proclog("HEAD pointer in new Branch: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] set to ". $branch->HeadFromAPI ." Queried " . count($newcommits) . " commits (reused $reusedFromExisting commits from DB)");
|
$this->logger->proclog("HEAD pointer in new Branch: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] set to {".substr($branch->HeadFromAPI ?? 'NULL', 0, 8)."} - Queried " . count($newcommits) . " commits (reused $reusedFromExisting commits from DB)");
|
||||||
} else {
|
} else {
|
||||||
$this->logger->proclog("HEAD pointer in Branch: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] no longer matches. Re-queried all " . count($newcommits) . " commits (old HEAD := {".substr($branch->Head ?? 'NULL', 0, 8)."}, missing: [" . join(", ", array_map(function($p){return substr($p ?? 'NULL', 0, 8);}, $next_sha)) . "] )");
|
$this->logger->proclog("HEAD pointer in Branch: [" . $this->name . "|" . $repo->Name . "|" . $branch->Name . "] no longer matches. Re-queried all " . count($newcommits) . " commits (old HEAD := {".substr($branch->Head ?? 'NULL', 0, 8)."}, missing: [" . join(", ", array_map(function($p){return substr($p ?? 'NULL', 0, 8);}, $next_sha)) . "] )");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user