diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-06-03 01:55:05 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-06-03 01:55:05 +0100 |
commit | 2389d5ae54ee836f8663a44c6b465a568c1fba66 (patch) | |
tree | fb71ac556a44cc003e19451aea5d63dfab074aee | |
parent | Only parse and insert non-null deps (diff) | |
download | gentoobrowse-api-2389d5ae54ee836f8663a44c6b465a568c1fba66.tar.bz2 gentoobrowse-api-2389d5ae54ee836f8663a44c6b465a568c1fba66.tar.xz gentoobrowse-api-2389d5ae54ee836f8663a44c6b465a568c1fba66.zip |
Bulk merge ebuild use flags
3 files changed, 40 insertions, 19 deletions
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp index c8d52a3..65bc7bd 100644 --- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp @@ -23,6 +23,7 @@ #include <sql/maintenance/ebuildDelete.sql.h> #include <sql/maintenance/ebuildDeps.sql.h> #include <sql/maintenance/ebuildRDeps.sql.h> +#include <sql/maintenance/ebuildUsesInsert.sql.h> namespace U = Gentoo::Utils; using namespace Gentoo::Utils::File; @@ -110,27 +111,45 @@ namespace Gentoo { { "flags", "text" }, // 2 { "op", "text" } // 3 }).second; + Utils::Database::namedTemp(dbc, "tmpEbuildUses", { + { "ebuildId", "int" }, + { "use", "text" }, + }); + useInsert = dbc->modify(sql::maintenance::ebuildUsesInsert.getSql()); } void EbuildMetaProcessor::apply(DB::Connection * dbc) { if (!ebuildIds.empty()) { - DB::TablePatch t; - t.pk = { "ebuildid", "packageid", "versionspec", "flags", "slot", "op" }; - t.cols = { "ebuildid", "packageid", "versionspec", "flags", "slot", "op" }; U::EntityWhereFilter ewf("ebuildId", ebuildIds); - t.where = &ewf; + { + dbc->execute("CREATE INDEX idxTmpEbuildDeps ON tmpEbuildDeps(ebuildId, runtime)"); + DB::TablePatch t; + t.pk = { "ebuildid", "packageid", "versionspec", "flags", "slot", "op" }; + t.cols = { "ebuildid", "packageid", "versionspec", "flags", "slot", "op" }; + t.where = &ewf; - DB::StaticSqlWriter sb(sql::maintenance::ebuildDeps.getSql()); - t.srcExpr = &sb; - t.dest = "gentoobrowse.ebuild_deps"; - dbc->patchTable(&t); + DB::StaticSqlWriter sb(sql::maintenance::ebuildDeps.getSql()); + t.srcExpr = &sb; + t.dest = "gentoobrowse.ebuild_deps"; + dbc->patchTable(&t); - DB::StaticSqlWriter sr(sql::maintenance::ebuildRDeps.getSql()); - t.srcExpr = &sr; - t.dest = "gentoobrowse.ebuild_rdeps"; - dbc->patchTable(&t); + DB::StaticSqlWriter sr(sql::maintenance::ebuildRDeps.getSql()); + t.srcExpr = &sr; + t.dest = "gentoobrowse.ebuild_rdeps"; + dbc->patchTable(&t); + } + { + dbc->execute("CREATE INDEX idxTmpEbuildUses ON tmpEbuildUses(ebuildId)"); + DB::TablePatch t; + t.src = "tmpEbuildUses"; + t.dest = "gentoobrowse.ebuild_uses"; + t.pk = { "ebuildid", "use" }; + t.cols = { "ebuildid", "use" }; + t.where = &ewf; + dbc->patchTable(&t); + } } if (!catsDeleteFrom.empty()) { bool any = false; @@ -151,6 +170,7 @@ namespace Gentoo { EbuildMetaProcessor::tidy(DB::Connection * dbc) { Utils::Database::drop(dbc, "tmpEbuildDeps"); + Utils::Database::drop(dbc, "tmpEbuildUses"); } void @@ -159,13 +179,11 @@ namespace Gentoo { U::EntityWhereFilter ewf("ebuildId", ebuildId); // IUSE DB::TablePatch t; - U::SplitEbuildProps sep_use("ebuildId", ebuildId, "use", ecp.get("IUSE")); - t.dest = "gentoobrowse.ebuild_uses"; - t.srcExpr = &sep_use; - t.pk = { "ebuildid", "use" }; - t.cols = { "ebuildid", "use" }; - t.where = &ewf; - dbc->patchTable(&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"; diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h index 2e92217..7b3e088 100644 --- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h +++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h @@ -27,6 +27,7 @@ namespace Gentoo { void insertDeps(const std::vector<Gentoo::DependencyPtr> &); DB::ModifyCommandPtr depInsert; + DB::ModifyCommandPtr useInsert; std::set<int64_t> ebuildIds; std::set<std::string> catsDeleteFrom; }; diff --git a/gentoobrowse-api/service/sql/maintenance/ebuildUsesInsert.sql b/gentoobrowse-api/service/sql/maintenance/ebuildUsesInsert.sql new file mode 100644 index 0000000..9d01c96 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/ebuildUsesInsert.sql @@ -0,0 +1,2 @@ +INSERT INTO tmpEbuildUses(ebuildId, use) +SELECT DISTINCT ?::INT, TRIM(REGEXP_SPLIT_TO_TABLE(?, '\s+'), '+') |