mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
aurjson: cache extended fields
Cache the results of the extended fields computation if the global caching mechanism is enabled. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
1283fe4918
commit
6493d00db5
1 changed files with 4 additions and 13 deletions
|
@ -292,11 +292,7 @@ class AurJSON {
|
||||||
"FROM Licenses INNER JOIN PackageLicenses " .
|
"FROM Licenses INNER JOIN PackageLicenses " .
|
||||||
"ON PackageLicenses.PackageID = " . $pkgid . " " .
|
"ON PackageLicenses.PackageID = " . $pkgid . " " .
|
||||||
"AND PackageLicenses.LicenseID = Licenses.ID";
|
"AND PackageLicenses.LicenseID = Licenses.ID";
|
||||||
$result = $this->dbh->query($query);
|
$rows = db_cache_result($query, 'extended-fields:' . $pkgid, PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$type_map = array(
|
$type_map = array(
|
||||||
'depends' => 'Depends',
|
'depends' => 'Depends',
|
||||||
|
@ -310,7 +306,7 @@ class AurJSON {
|
||||||
'license' => 'License',
|
'license' => 'License',
|
||||||
);
|
);
|
||||||
$data = array();
|
$data = array();
|
||||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
foreach ($rows as $row) {
|
||||||
$type = $type_map[$row['Type']];
|
$type = $type_map[$row['Type']];
|
||||||
$data[$type][] = $row['Name'] . $row['Cond'];
|
$data[$type][] = $row['Name'] . $row['Cond'];
|
||||||
}
|
}
|
||||||
|
@ -319,13 +315,8 @@ class AurJSON {
|
||||||
$query = "SELECT Keyword FROM PackageKeywords " .
|
$query = "SELECT Keyword FROM PackageKeywords " .
|
||||||
"WHERE PackageBaseID = " . intval($base_id) . " " .
|
"WHERE PackageBaseID = " . intval($base_id) . " " .
|
||||||
"ORDER BY Keyword ASC";
|
"ORDER BY Keyword ASC";
|
||||||
$result = $this->dbh->query($query);
|
$rows = db_cache_result($query, 'keywords:' . intval($base_id));
|
||||||
|
$data['Keywords'] = array_map(function ($x) { return $x[0]; }, $rows);
|
||||||
if (!$result) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['Keywords'] = $result->fetchAll(PDO::FETCH_COLUMN, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue