summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 01:21:51 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 21:37:39 +0100
commitf9428393fa5a64f1e330fbec43275c713da1cec2 (patch)
tree7c0506ad0d8b71fdadc8a8e27dc1724d6e8e5eab
parentGeneric entity where filter (diff)
downloadgentoobrowse-api-f9428393fa5a64f1e330fbec43275c713da1cec2.tar.bz2
gentoobrowse-api-f9428393fa5a64f1e330fbec43275c713da1cec2.tar.xz
gentoobrowse-api-f9428393fa5a64f1e330fbec43275c713da1cec2.zip
Update package urls
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp21
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h2
-rw-r--r--gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql2
-rw-r--r--gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql2
4 files changed, 19 insertions, 8 deletions
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
index 87cfd12..b63bb55 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
@@ -120,9 +120,9 @@ namespace Gentoo {
m->bindParamS(5, repoName);
m->bindParamS(6, categoryName);
m->bindParamS(7, packageName);
- m->forEachRow<int64_t, bool>([this,dbc,&ecp,&fn] (auto ebuildId, auto newest) {
+ m->forEachRow<int64_t, bool, int64_t>([this,dbc,&ecp,&fn] (auto ebuildId, auto newest, auto packageId) {
fprintf(stderr, "Created ebuild %ld for %s (%s)\n", ebuildId, fn.c_str(), newest ? "yes" : "no");
- this->perEbuildUpdates(dbc, ecp, ebuildId);
+ this->perEbuildUpdates(dbc, ecp, ebuildId, newest, packageId);
});
}
}
@@ -142,9 +142,9 @@ 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, bool>([this,dbc,&ecp,&fn] (auto ebuildId, auto newest) {
+ m->forEachRow<int64_t, bool, int64_t>([this,dbc,&ecp,&fn] (auto ebuildId, auto newest, auto packageId) {
fprintf(stderr, "Updated ebuild %ld for %s (%s)\n", ebuildId, fn.c_str(), newest ? "yes" : "no");
- this->perEbuildUpdates(dbc, ecp, ebuildId);
+ this->perEbuildUpdates(dbc, ecp, ebuildId, newest, packageId);
});
}
}
@@ -172,7 +172,7 @@ namespace Gentoo {
};
void
- EbuildMetaProcessor::perEbuildUpdates(DB::Connection * dbc, const EbuildCacheParser & ecp, int64_t ebuildId) const
+ EbuildMetaProcessor::perEbuildUpdates(DB::Connection * dbc, const EbuildCacheParser & ecp, int64_t ebuildId, bool newest, int64_t packageId) const
{
EntityWhereFilter ewf("ebuildId", ebuildId);
// IUSE
@@ -192,6 +192,17 @@ namespace Gentoo {
t.cols = { "ebuildid", "arch" };
t.where = &ewf;
dbc->patchTable(&t);
+ if (newest) {
+ // HOMEPAGE
+ EntityWhereFilter pwf("packageId", 1);
+ SplitEbuildProps sep_homepage("packageId", packageId, "url", ecp.get("HOMEPAGE"));
+ t.dest = "gentoobrowse.package_urls";
+ t.srcExpr = &sep_homepage;
+ t.pk = { "packageId", "url" };
+ t.cols = { "packageId", "url" };
+ t.where = &pwf;
+ dbc->patchTable(&t);
+ }
}
void
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
index 90c0d94..42b538d 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
@@ -19,7 +19,7 @@ namespace Gentoo {
void deleted(DB::Connection * dbc, const boost::filesystem::path & fn) const;
private:
- void perEbuildUpdates(DB::Connection * dbc, const EbuildCacheParser & ecp, int64_t ebuildId) const;
+ void perEbuildUpdates(DB::Connection * dbc, const EbuildCacheParser & ecp, int64_t ebuildId, bool newest, int64_t packageId) const;
};
}
}
diff --git a/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql b/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql
index 691efd9..2a34c36 100644
--- a/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql
+++ b/gentoobrowse-api/service/sql/maintenance/ebuildInsert.sql
@@ -10,4 +10,4 @@ RETURNING ebuildid, NOT EXISTS (
SELECT FROM gentoobrowse.ebuilds ve
WHERE ve.packageid = gentoobrowse.ebuilds.packageid
AND ve.versioninst > gentoobrowse.ebuilds.versioninst
- )
+ ), packageid
diff --git a/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql b/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql
index 891344c..f5a42c5 100644
--- a/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql
+++ b/gentoobrowse-api/service/sql/maintenance/ebuildUpdate.sql
@@ -14,4 +14,4 @@ RETURNING ebuildid, NOT EXISTS (
SELECT FROM gentoobrowse.ebuilds ve
WHERE ve.packageid = e.packageid
AND ve.versioninst > e.versioninst
- )
+ ), e.packageid