diff options
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+') |