summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 01:01:17 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 21:37:39 +0100
commitb02c0ba0a2fa565d16b8f7c0cb008f1c2b467c45 (patch)
tree64fb4d21b46aeca261e8d1cf43b5a88ba61eb5a5
parentGeneric split ebuild props (diff)
downloadgentoobrowse-api-b02c0ba0a2fa565d16b8f7c0cb008f1c2b467c45.tar.bz2
gentoobrowse-api-b02c0ba0a2fa565d16b8f7c0cb008f1c2b467c45.tar.xz
gentoobrowse-api-b02c0ba0a2fa565d16b8f7c0cb008f1c2b467c45.zip
Generic entity where filter
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
index 48bd6cc..87cfd12 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
@@ -149,28 +149,33 @@ namespace Gentoo {
}
}
- class EbuildWhereFilter : public DB::SqlWriter {
+ class EntityWhereFilter : public DB::SqlWriter {
public:
- EbuildWhereFilter(int64_t e) : ebuildId(e) { }
+ EntityWhereFilter(const std::string & en, int64_t e) :
+ entityId(e),
+ entityColName(en)
+ {
+ }
void writeSql(AdHoc::Buffer & sql) override
{
- sql.append("b.ebuildId = ?");
+ sql.appendbf("b.%s = ?", entityColName);
}
void bindParams(DB::Command * c, unsigned int & offset) override
{
- c->bindParamI(offset++, ebuildId);
+ c->bindParamI(offset++, entityId);
}
- const int64_t ebuildId;
+ const int64_t entityId;
+ const std::string entityColName;
};
void
EbuildMetaProcessor::perEbuildUpdates(DB::Connection * dbc, const EbuildCacheParser & ecp, int64_t ebuildId) const
{
- EbuildWhereFilter ewf(ebuildId);
- // USE flags
+ EntityWhereFilter ewf("ebuildId", ebuildId);
+ // IUSE
DB::TablePatch t;
SplitEbuildProps sep_use("ebuildId", ebuildId, "use", ecp.get("IUSE"));
t.dest = "gentoobrowse.ebuild_uses";