summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-04-24 23:11:40 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 21:37:39 +0100
commita959e1c7fe6f59bffb062ea8c871cf1c582bb511 (patch)
treea27d08078565502c1966791e7acc26dd20a91adf
parentDon't bypass prepared statement logic (diff)
downloadgentoobrowse-api-a959e1c7fe6f59bffb062ea8c871cf1c582bb511.tar.bz2
gentoobrowse-api-a959e1c7fe6f59bffb062ea8c871cf1c582bb511.tar.xz
gentoobrowse-api-a959e1c7fe6f59bffb062ea8c871cf1c582bb511.zip
Include flag indicating if ebuild is highest version of package
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp8
-rw-r--r--gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql6
-rw-r--r--gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql6
3 files changed, 14 insertions, 6 deletions
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
index 52c196b..3a6e409 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
@@ -119,8 +119,8 @@ namespace Gentoo {
m->bindParamS(5, repoName);
m->bindParamS(6, categoryName);
m->bindParamS(7, packageName);
- m->forEachRow<int64_t>([this,dbc,&ecp,&fn] (auto ebuildId) {
- fprintf(stderr, "Created ebuild %ld for %s\n", ebuildId, fn.c_str());
+ m->forEachRow<int64_t, bool>([this,dbc,&ecp,&fn] (auto ebuildId, auto newest) {
+ fprintf(stderr, "Created ebuild %ld for %s (%s)\n", ebuildId, fn.c_str(), newest ? "yes" : "no");
this->perEbuildUpdates(dbc, ecp, ebuildId);
});
}
@@ -141,8 +141,8 @@ namespace Gentoo {
m->bindParamS(4, (fn / 3).string()); // category
m->bindParamS(5, matches.fetch(1)); // package
m->bindParamS(6, matches.fetch(2)); // version
- m->forEachRow<int64_t>([this,dbc,&ecp,&fn] (auto ebuildId) {
- fprintf(stderr, "Updated ebuild %ld for %s\n", ebuildId, fn.c_str());
+ m->forEachRow<int64_t, bool>([this,dbc,&ecp,&fn] (auto ebuildId, auto newest) {
+ fprintf(stderr, "Updated ebuild %ld for %s (%s)\n", ebuildId, fn.c_str(), newest ? "yes" : "no");
this->perEbuildUpdates(dbc, ecp, ebuildId);
});
}
diff --git a/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql b/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql
index 110b7c8..691efd9 100644
--- a/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql
+++ b/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql
@@ -6,4 +6,8 @@ WHERE c.categoryid = p.categoryid
AND r.name = ?
AND c.name = ?
AND p.name = ?
-RETURNING ebuildid
+RETURNING ebuildid, NOT EXISTS (
+ SELECT FROM gentoobrowse.ebuilds ve
+ WHERE ve.packageid = gentoobrowse.ebuilds.packageid
+ AND ve.versioninst > gentoobrowse.ebuilds.versioninst
+ )
diff --git a/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql b/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql
index fc83417..891344c 100644
--- a/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql
+++ b/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql
@@ -10,4 +10,8 @@ AND r.name = ?
AND c.name = ?
AND p.name = ?
AND e.version = ?
-RETURNING ebuildid
+RETURNING ebuildid, NOT EXISTS (
+ SELECT FROM gentoobrowse.ebuilds ve
+ WHERE ve.packageid = e.packageid
+ AND ve.versioninst > e.versioninst
+ )