summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-06-03 02:18:24 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-06-03 02:18:24 +0100
commit3866b89a59469b9723fed7d200dc80737a15a59b (patch)
treea1383aac3867c6cf4d0ab99256072bf221d5d8c8
parentBulk merge ebuild use flags (diff)
downloadgentoobrowse-api-3866b89a59469b9723fed7d200dc80737a15a59b.tar.bz2
gentoobrowse-api-3866b89a59469b9723fed7d200dc80737a15a59b.tar.xz
gentoobrowse-api-3866b89a59469b9723fed7d200dc80737a15a59b.zip
Bulk merge ebuild archs
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp31
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h1
-rw-r--r--gentoobrowse-api/service/sql/maintenance/ebuildArchsInsert.sql2
3 files changed, 26 insertions, 8 deletions
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
index 65bc7bd..a57c674 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
@@ -24,6 +24,7 @@
#include <sql/maintenance/ebuildDeps.sql.h>
#include <sql/maintenance/ebuildRDeps.sql.h>
#include <sql/maintenance/ebuildUsesInsert.sql.h>
+#include <sql/maintenance/ebuildArchsInsert.sql.h>
namespace U = Gentoo::Utils;
using namespace Gentoo::Utils::File;
@@ -116,6 +117,11 @@ namespace Gentoo {
{ "use", "text" },
});
useInsert = dbc->modify(sql::maintenance::ebuildUsesInsert.getSql());
+ Utils::Database::namedTemp(dbc, "tmpEbuildArchs", {
+ { "ebuildId", "int" },
+ { "arch", "text" },
+ });
+ archInsert = dbc->modify(sql::maintenance::ebuildArchsInsert.getSql());
}
void
@@ -150,6 +156,16 @@ namespace Gentoo {
t.where = &ewf;
dbc->patchTable(&t);
}
+ {
+ dbc->execute("CREATE INDEX idxTmpEbuildArchs ON tmpEbuildArchs(ebuildId)");
+ DB::TablePatch t;
+ t.src = "tmpEbuildArchs";
+ t.dest = "gentoobrowse.ebuild_archs";
+ t.pk = { "ebuildid", "arch" };
+ t.cols = { "ebuildid", "arch" };
+ t.where = &ewf;
+ dbc->patchTable(&t);
+ }
}
if (!catsDeleteFrom.empty()) {
bool any = false;
@@ -171,6 +187,7 @@ namespace Gentoo {
{
Utils::Database::drop(dbc, "tmpEbuildDeps");
Utils::Database::drop(dbc, "tmpEbuildUses");
+ Utils::Database::drop(dbc, "tmpEbuildArchs");
}
void
@@ -178,20 +195,17 @@ namespace Gentoo {
{
U::EntityWhereFilter ewf("ebuildId", ebuildId);
// IUSE
- DB::TablePatch t;
if (auto uses = ecp.get("IUSE")) {
useInsert->bindParamI(0, ebuildId);
useInsert->bindParamS(1, *uses);
useInsert->execute();
}
// KEYWORDS
- U::SplitEbuildProps sep_keywords("ebuildId", ebuildId, "arch", ecp.get("KEYWORDS"));
- t.dest = "gentoobrowse.ebuild_archs";
- t.srcExpr = &sep_keywords;
- t.pk = { "ebuildid", "arch" };
- t.cols = { "ebuildid", "arch" };
- t.where = &ewf;
- dbc->patchTable(&t);
+ if (auto keywords = ecp.get("KEYWORDS")) {
+ archInsert->bindParamI(0, ebuildId);
+ archInsert->bindParamS(1, *keywords);
+ archInsert->execute();
+ }
// Dependencies
ebuildIds.insert(ebuildId);
depInsert->bindParamI(1, ebuildId);
@@ -204,6 +218,7 @@ namespace Gentoo {
insertDeps(Portage::Utils::Depend::parse(rdepend->first, rdepend->second));
}
if (newest) {
+ DB::TablePatch t;
// HOMEPAGE
U::EntityWhereFilter pwf("packageId", packageId);
U::SplitEbuildProps sep_homepage("packageId", packageId, "url", ecp.get("HOMEPAGE"));
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
index 7b3e088..f4d4b07 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
@@ -28,6 +28,7 @@ namespace Gentoo {
DB::ModifyCommandPtr depInsert;
DB::ModifyCommandPtr useInsert;
+ DB::ModifyCommandPtr archInsert;
std::set<int64_t> ebuildIds;
std::set<std::string> catsDeleteFrom;
};
diff --git a/gentoobrowse-api/service/sql/maintenance/ebuildArchsInsert.sql b/gentoobrowse-api/service/sql/maintenance/ebuildArchsInsert.sql
new file mode 100644
index 0000000..7ea8eae
--- /dev/null
+++ b/gentoobrowse-api/service/sql/maintenance/ebuildArchsInsert.sql
@@ -0,0 +1,2 @@
+INSERT INTO tmpEbuildArchs(ebuildId, arch)
+SELECT DISTINCT ?::INT, REGEXP_SPLIT_TO_TABLE(?, '\s+')