summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-02-20 02:47:47 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-02-20 02:47:47 +0000
commit3a16f77fd1f962f3e69687a19b36039fcf7147b3 (patch)
tree87d86e8a0c845df81abd4073fa0350930db39530
parentFix first round of tools warnings (diff)
downloadgentoobrowse-api-3a16f77fd1f962f3e69687a19b36039fcf7147b3.tar.bz2
gentoobrowse-api-3a16f77fd1f962f3e69687a19b36039fcf7147b3.tar.xz
gentoobrowse-api-3a16f77fd1f962f3e69687a19b36039fcf7147b3.zip
Fix second round of tools warnings, all but iwyu
-rw-r--r--Jamroot.jam35
-rw-r--r--gentoobrowse-api/client/helpers.h5
-rw-r--r--gentoobrowse-api/client/main.cpp2
-rw-r--r--gentoobrowse-api/client/main.h5
-rw-r--r--gentoobrowse-api/domain/converters.h5
-rw-r--r--gentoobrowse-api/domain/converters.impl.h5
-rw-r--r--gentoobrowse-api/domain/unpackPqTextArray.h5
-rw-r--r--gentoobrowse-api/service/changeSet.h14
-rw-r--r--gentoobrowse-api/service/depend.cpp168
-rw-r--r--gentoobrowse-api/service/depend.h25
-rw-r--r--gentoobrowse-api/service/main.cpp66
-rw-r--r--gentoobrowse-api/service/maintenance/abstractFileProcessor.cpp36
-rw-r--r--gentoobrowse-api/service/maintenance/abstractFileProcessor.h54
-rw-r--r--gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp84
-rw-r--r--gentoobrowse-api/service/maintenance/categoryMetaProcessor.h31
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp480
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h71
-rw-r--r--gentoobrowse-api/service/maintenance/masksProcessor.cpp167
-rw-r--r--gentoobrowse-api/service/maintenance/masksProcessor.h33
-rw-r--r--gentoobrowse-api/service/maintenance/newsProcessor.cpp86
-rw-r--r--gentoobrowse-api/service/maintenance/newsProcessor.h36
-rw-r--r--gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp92
-rw-r--r--gentoobrowse-api/service/maintenance/packageMetaProcessor.h31
-rw-r--r--gentoobrowse-api/service/maintenance/updatesProcessor.cpp263
-rw-r--r--gentoobrowse-api/service/maintenance/updatesProcessor.h43
-rw-r--r--gentoobrowse-api/service/maintenance/useGlobalProcessor.cpp99
-rw-r--r--gentoobrowse-api/service/maintenance/useGlobalProcessor.h31
-rw-r--r--gentoobrowse-api/service/maintenance/useGroupProcessor.cpp144
-rw-r--r--gentoobrowse-api/service/maintenance/useGroupProcessor.h35
-rw-r--r--gentoobrowse-api/service/maintenance/useLocalProcessor.cpp109
-rw-r--r--gentoobrowse-api/service/maintenance/useLocalProcessor.h31
-rw-r--r--gentoobrowse-api/service/maintenanceBugs.cpp169
-rw-r--r--gentoobrowse-api/service/maintenanceCommon.cpp191
-rw-r--r--gentoobrowse-api/service/maintenanceGitOperations.cpp421
-rw-r--r--gentoobrowse-api/service/maintenanceimpl.h55
-rw-r--r--gentoobrowse-api/service/mask.cpp73
-rw-r--r--gentoobrowse-api/service/mask.h33
-rw-r--r--gentoobrowse-api/service/news.cpp202
-rw-r--r--gentoobrowse-api/service/news.h23
-rw-r--r--gentoobrowse-api/service/notificationsimpl.cpp84
-rw-r--r--gentoobrowse-api/service/notificationsimpl.h26
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp436
-rw-r--r--gentoobrowse-api/service/portageimpl.h111
-rw-r--r--gentoobrowse-api/service/usersimpl.cpp200
-rw-r--r--gentoobrowse-api/service/usersimpl.h44
-rw-r--r--gentoobrowse-api/service/utils/dbUtils.cpp85
-rw-r--r--gentoobrowse-api/service/utils/dbUtils.h24
-rw-r--r--gentoobrowse-api/service/utils/ebuildCacheParser.cpp50
-rw-r--r--gentoobrowse-api/service/utils/ebuildCacheParser.h27
-rw-r--r--gentoobrowse-api/service/utils/entityWhereFilter.cpp84
-rw-r--r--gentoobrowse-api/service/utils/entityWhereFilter.h31
-rw-r--r--gentoobrowse-api/service/utils/git.cpp167
-rw-r--r--gentoobrowse-api/service/utils/git.h85
-rw-r--r--gentoobrowse-api/service/utils/splitEbuildProps.cpp36
-rw-r--r--gentoobrowse-api/service/utils/splitEbuildProps.h28
-rw-r--r--gentoobrowse-api/service/utils/xmlUtils.cpp28
-rw-r--r--gentoobrowse-api/service/utils/xmlUtils.h19
-rw-r--r--gentoobrowse-api/service/xsltStreamSerializer.cpp24
-rw-r--r--gentoobrowse-api/service/xsltStreamSerializer.h6
-rw-r--r--gentoobrowse-api/unittests/mockDefs.cpp6
-rw-r--r--gentoobrowse-api/unittests/mockDefs.h4
-rw-r--r--gentoobrowse-api/unittests/testMaintenance.cpp26
-rw-r--r--gentoobrowse-api/unittests/testNotifications.cpp12
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp9
-rw-r--r--gentoobrowse-api/util/update.cpp41
65 files changed, 2501 insertions, 2650 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 6fb1bd3..1bd4766 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -35,8 +35,41 @@ project
<variant>coverage:<coverage>on
<toolset>tidy:<define>ICE_IGNORE_VERSION
<toolset>tidy:<define>ICE_MEMBER_IMPORT_EXPORT
- <toolset>tidy:<exclude>cxxstd-20-iso/maintenance.h
+ <toolset>tidy:<exclude>users.cpp
+ <toolset>tidy:<exclude>user-models.cpp
+ <toolset>tidy:<exclude>news-models.cpp
+ <toolset>tidy:<exclude>extended-models.cpp
+ <toolset>tidy:<exclude>portage-models.cpp
+ <toolset>tidy:<exclude>portage.cpp
+ <toolset>tidy:<exclude>maintenance.h
+ <toolset>tidy:<exclude>maintenance.cpp
+ <toolset>tidy:<exclude>notifications.h
+ <toolset>tidy:<exclude>notifications.cpp
+ <toolset>tidy:<exclude>notifications/xslt/base.h
+ <toolset>tidy:<exclude>notifications/xslt/base.cpp
+ <toolset>tidy:<exclude>notifications/xslt/news.h
+ <toolset>tidy:<exclude>notifications/xslt/news.cpp
+ <toolset>tidy:<exclude>notifications/xslt/signup.h
+ <toolset>tidy:<exclude>notifications/xslt/signup.cpp
+ <toolset>tidy:<exclude>notifications/css/style.h
+ <toolset>tidy:<exclude>notifications/css/style.cpp
<toolset>tidy:<exclude>unpackPqTextArray.cpp
+ <toolset>tidy:<checkxx>boost-*
+ <toolset>tidy:<checkxx>bugprone-*
+ <toolset>tidy:<xcheckxx>bugprone-implicit-widening-of-multiplication-result
+ <toolset>tidy:<xcheckxx>bugprone-easily-swappable-parameters
+ <toolset>tidy:<xcheckxx>bugprone-macro-parentheses
+ <toolset>tidy:<checkxx>clang-*
+ <toolset>tidy:<checkxx>misc-*
+ <toolset>tidy:<xcheckxx>misc-non-private-member-variables-in-classes
+ <toolset>tidy:<checkxx>modernize-*
+ <toolset>tidy:<xcheckxx>modernize-use-trailing-return-type
+ <toolset>tidy:<checkxx>hicpp-*
+ <toolset>tidy:<xcheckxx>hicpp-vararg
+ <toolset>tidy:<xcheckxx>hicpp-signed-bitwise
+ <toolset>tidy:<xcheckxx>hicpp-named-parameter
+ <toolset>tidy:<xcheckxx>hicpp-no-array-decay
+ <toolset>tidy:<checkxx>performance-*
<toolset>tidy:<librarydef>boost
<toolset>tidy:<librarydef>std
;
diff --git a/gentoobrowse-api/client/helpers.h b/gentoobrowse-api/client/helpers.h
index 4caf7f9..2691498 100644
--- a/gentoobrowse-api/client/helpers.h
+++ b/gentoobrowse-api/client/helpers.h
@@ -1,5 +1,4 @@
-#ifndef GENTOOBROWSE_CLIENT_HELPERS_H
-#define GENTOOBROWSE_CLIENT_HELPERS_H
+#pragma once
#include <Ice/AsyncResult.h>
#include <Ice/ObjectAdapter.h>
@@ -24,5 +23,3 @@ asyncMapRelated(const Collection & collection, const Proxy & p, Key CollectionMe
}
return rtn;
}
-
-#endif
diff --git a/gentoobrowse-api/client/main.cpp b/gentoobrowse-api/client/main.cpp
index 56f0a4b..e82f5a3 100644
--- a/gentoobrowse-api/client/main.cpp
+++ b/gentoobrowse-api/client/main.cpp
@@ -1,7 +1,7 @@
#include "main.h"
-#include "stdio.h"
#include <Ice/Ice.h>
#include <boost/program_options.hpp>
+#include <cstdio>
#include <plugins.impl.h>
#include <portage.h>
diff --git a/gentoobrowse-api/client/main.h b/gentoobrowse-api/client/main.h
index 9c7ccef..8aeada6 100644
--- a/gentoobrowse-api/client/main.h
+++ b/gentoobrowse-api/client/main.h
@@ -1,5 +1,4 @@
-#ifndef GENTOO_MAIN_H
-#define GENTOO_MAIN_H
+#pragma once
#include <plugins.h>
#include <portage.h>
@@ -10,5 +9,3 @@ class Module : public AdHoc::AbstractPluginImplementation {
public:
virtual void run(const Gentoo::PortagePrxPtr &, const std::vector<std::string> &) const = 0;
};
-
-#endif
diff --git a/gentoobrowse-api/domain/converters.h b/gentoobrowse-api/domain/converters.h
index 07188fa..db72c0f 100644
--- a/gentoobrowse-api/domain/converters.h
+++ b/gentoobrowse-api/domain/converters.h
@@ -1,5 +1,4 @@
-#ifndef something
-#define something
+#pragma once
#include <boost/date_time/posix_time/posix_time.hpp>
#include <portage-models.h>
@@ -21,5 +20,3 @@ namespace Slicer {
DLL_PUBLIC
std::string posixTimeToShortDate(const boost::posix_time::ptime & s);
}
-
-#endif
diff --git a/gentoobrowse-api/domain/converters.impl.h b/gentoobrowse-api/domain/converters.impl.h
index 6ba15fa..38a674e 100644
--- a/gentoobrowse-api/domain/converters.impl.h
+++ b/gentoobrowse-api/domain/converters.impl.h
@@ -1,5 +1,4 @@
-#ifndef GENTOOBROWSE_API_DOMAIN_CONVERTERS_IMPL_H
-#define GENTOOBROWSE_API_DOMAIN_CONVERTERS_IMPL_H
+#pragma once
#include "unpackPqTextArray.h"
#include <boost/lexical_cast.hpp>
@@ -72,5 +71,3 @@ namespace Slicer {
return ss.str();
}
}
-
-#endif
diff --git a/gentoobrowse-api/domain/unpackPqTextArray.h b/gentoobrowse-api/domain/unpackPqTextArray.h
index b1b2857..6e39f52 100644
--- a/gentoobrowse-api/domain/unpackPqTextArray.h
+++ b/gentoobrowse-api/domain/unpackPqTextArray.h
@@ -1,5 +1,4 @@
-#ifndef JSONFLEXLEXER_H
-#define JSONFLEXLEXER_H
+#pragma once
#include <portage-models.h>
#ifndef yyFlexLexer
@@ -21,5 +20,3 @@ namespace Slicer {
std::string buffer;
};
}
-
-#endif
diff --git a/gentoobrowse-api/service/changeSet.h b/gentoobrowse-api/service/changeSet.h
index ab83656..c8508dd 100644
--- a/gentoobrowse-api/service/changeSet.h
+++ b/gentoobrowse-api/service/changeSet.h
@@ -6,14 +6,12 @@
#include <map>
#include <portage-models.h>
-namespace Gentoo {
- namespace Service {
- struct ChangeDetails {
- StringList pathParts;
- git_delta_t changeType;
- };
- typedef std::map<std::filesystem::path, ChangeDetails> ChangeSet;
- }
+namespace Gentoo::Service {
+ struct ChangeDetails {
+ StringList pathParts;
+ git_delta_t changeType {};
+ };
+ using ChangeSet = std::map<std::filesystem::path, ChangeDetails, std::less<>>;
}
#endif
diff --git a/gentoobrowse-api/service/depend.cpp b/gentoobrowse-api/service/depend.cpp
index 8b2e29b..c707e82 100644
--- a/gentoobrowse-api/service/depend.cpp
+++ b/gentoobrowse-api/service/depend.cpp
@@ -2,97 +2,95 @@
#include "wrap/regex.h"
#include <lexer-regex.h>
-AdHoc::Lexer::PatternPtr WhenUse_Begin(
- AdHoc::LexerMatchers::regex("\\s*(!?[[:alnum:]-_@]+)\\?\\s*\\(\\s*", G_REGEX_OPTIMIZE));
-AdHoc::Lexer::PatternPtr WhenUse_End(AdHoc::LexerMatchers::regex("\\s*\\)\\s*", G_REGEX_OPTIMIZE));
-AdHoc::Lexer::PatternPtr Or_Begin(AdHoc::LexerMatchers::regex("\\s*\\|\\|\\s*\\(\\s*", G_REGEX_OPTIMIZE));
-AdHoc::Lexer::PatternPtr Or_Group(AdHoc::LexerMatchers::regex("\\s*\\(\\s*", G_REGEX_OPTIMIZE));
-AdHoc::Lexer::PatternPtr Or_End(AdHoc::LexerMatchers::regex("\\s*\\)\\s*", G_REGEX_OPTIMIZE));
-AdHoc::Lexer::PatternPtr AtomSpec(AdHoc::LexerMatchers::regex(
- "\\s*"
- "([[:punct:]]+)?" // op
- "([[:alnum:]-]+)\\/" // cat
- "([^ ]+)" // package
- "(-([0-9][.0-9]*[[:alpha:]]?\\*?((_(alpha|beta|pre|rc|p))?[[:digit:]]*)*(-r[[:digit:]]+)?))?" // version
- "(:([^/ []+(\\/[^ []+)?))?" // slot
- "(\\[([^]]+)\\])?(\\s+|$)",
- static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_UNGREEDY))); // use
+namespace Portage::Utils {
+ AdHoc::Lexer::PatternPtr WhenUse_Begin(
+ AdHoc::LexerMatchers::regex(R"(\s*(!?[[:alnum:]-_@]+)\?\s*\(\s*)", G_REGEX_OPTIMIZE));
+ AdHoc::Lexer::PatternPtr WhenUse_End(AdHoc::LexerMatchers::regex(R"(\s*\)\s*)", G_REGEX_OPTIMIZE));
+ AdHoc::Lexer::PatternPtr Or_Begin(AdHoc::LexerMatchers::regex(R"(\s*\|\|\s*\(\s*)", G_REGEX_OPTIMIZE));
+ AdHoc::Lexer::PatternPtr Or_Group(AdHoc::LexerMatchers::regex(R"(\s*\(\s*)", G_REGEX_OPTIMIZE));
+ AdHoc::Lexer::PatternPtr Or_End(AdHoc::LexerMatchers::regex(R"(\s*\)\s*)", G_REGEX_OPTIMIZE));
+ AdHoc::Lexer::PatternPtr AtomSpec(AdHoc::LexerMatchers::regex(
+ "\\s*"
+ "([[:punct:]]+)?" // op
+ "([[:alnum:]-]+)\\/" // cat
+ "([^ ]+)" // package
+ "(-([0-9][.0-9]*[[:alpha:]]?\\*?((_(alpha|beta|pre|rc|p))?[[:digit:]]*)*(-r[[:digit:]]+)?))?" // version
+ "(:([^/ []+(\\/[^ []+)?))?" // slot
+ "(\\[([^]]+)\\])?(\\s+|$)",
+ static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_UNGREEDY))); // use
-const std::string InWhen("InWhen");
-const std::string InOr("InOr");
+ const std::string InWhen("InWhen");
+ const std::string InOr("InOr");
-namespace Portage {
- namespace Utils {
- template<typename T, typename Y>
- Ice::optional<T>
- iuo(const std::optional<Y> & x)
- {
- if (x) {
- return Ice::optional<T>(*x);
- }
- return Ice::optional<T>();
+ template<typename T, typename Y>
+ Ice::optional<T>
+ iuo(const std::optional<Y> & x)
+ {
+ if (x) {
+ return Ice::optional<T>(*x);
}
+ return Ice::optional<T>();
+ }
- template<typename T, typename Y>
- std::vector<T>
- split(const std::optional<Y> & x)
- {
- std::vector<T> rtn;
- if (x) {
- Glib::Regex::split_simple(",", *x).assign_to(rtn);
- std::sort(rtn.begin(), rtn.end());
- }
- return rtn;
+ template<typename T, typename Y>
+ std::vector<T>
+ split(const std::optional<Y> & x)
+ {
+ std::vector<T> rtn;
+ if (x) {
+ Glib::Regex::split_simple(",", *x).assign_to(rtn);
+ std::sort(rtn.begin(), rtn.end());
}
+ return rtn;
+ }
- Depend::Depend() :
- AdHoc::Lexer({// use? (
- {{InitialState, InWhen, InOr}, WhenUse_Begin,
- [this](auto es) {
- es->pushState(InWhen);
- when.push_back(*es->pattern()->match(1));
- }},
- // )
- {{InWhen}, WhenUse_End,
- [this](auto es) {
- es->popState();
- when.pop_back();
- }},
- // || (
- {{InitialState, InWhen, InOr}, Or_Begin,
- [](auto es) {
- es->pushState(InOr);
- }},
- // (
- {{InitialState, InWhen, InOr}, Or_Group,
- [](auto es) {
- es->pushState(InOr);
- }},
- // )
- {{InOr}, Or_End,
- [](auto es) {
- es->popState();
- }},
- // [op]some-cat/package[-version][:slot][uses]
- {{InitialState, InWhen, InOr}, AtomSpec, [this](auto es) {
- ds.push_back(std::make_shared<Gentoo::Dependency>(when,
- iuo<std::string>(es->pattern()->match(1)), // op
- *es->pattern()->match(2), // category
- *es->pattern()->match(3), // package
- iuo<std::string>(es->pattern()->match(5)), // version
- iuo<std::string>(es->pattern()->match(11)), // slot
- split<std::string>(es->pattern()->match(14)) // use
- ));
- }}})
- {
- }
+ Depend::Depend() :
+ AdHoc::Lexer({// use? (
+ {{InitialState, InWhen, InOr}, WhenUse_Begin,
+ [this](auto es) {
+ es->pushState(InWhen);
+ when.push_back(*es->pattern()->match(1));
+ }},
+ // )
+ {{InWhen}, WhenUse_End,
+ [this](auto es) {
+ es->popState();
+ when.pop_back();
+ }},
+ // || (
+ {{InitialState, InWhen, InOr}, Or_Begin,
+ [](auto es) {
+ es->pushState(InOr);
+ }},
+ // (
+ {{InitialState, InWhen, InOr}, Or_Group,
+ [](auto es) {
+ es->pushState(InOr);
+ }},
+ // )
+ {{InOr}, Or_End,
+ [](auto es) {
+ es->popState();
+ }},
+ // [op]some-cat/package[-version][:slot][uses]
+ {{InitialState, InWhen, InOr}, AtomSpec, [this](auto es) {
+ ds.push_back(std::make_shared<Gentoo::Dependency>(when,
+ iuo<std::string>(es->pattern()->match(1)), // op
+ *es->pattern()->match(2), // category
+ *es->pattern()->match(3), // package
+ iuo<std::string>(es->pattern()->match(5)), // version
+ iuo<std::string>(es->pattern()->match(11)), // slot
+ split<std::string>(es->pattern()->match(14)) // use
+ ));
+ }}})
+ {
+ }
- std::vector<Gentoo::DependencyPtr>
- Depend::parse(const std::string_view & s)
- {
- Depend d;
- d.extract(s.data(), s.length());
- return d.ds;
- }
+ std::vector<Gentoo::DependencyPtr>
+ Depend::parse(const std::string_view & s)
+ {
+ Depend d;
+ d.extract(s.data(), s.length());
+ return d.ds;
}
}
diff --git a/gentoobrowse-api/service/depend.h b/gentoobrowse-api/service/depend.h
index 7a6af44..7cba039 100644
--- a/gentoobrowse-api/service/depend.h
+++ b/gentoobrowse-api/service/depend.h
@@ -1,23 +1,18 @@
-#ifndef GENTOOBROWSE_SERVICE_DEPEND_H
-#define GENTOOBROWSE_SERVICE_DEPEND_H
+#pragma once
#include <istream>
#include <lexer.h>
#include <portage-models.h>
#include <vector>
-namespace Portage {
- namespace Utils {
- class Depend : AdHoc::Lexer {
- private:
- Depend();
- Gentoo::StringList when;
+namespace Portage::Utils {
+ class Depend : AdHoc::Lexer {
+ private:
+ Depend();
+ Gentoo::StringList when;
- public:
- static std::vector<Gentoo::DependencyPtr> parse(const std::string_view &);
- std::vector<Gentoo::DependencyPtr> ds;
- };
- }
+ public:
+ static std::vector<Gentoo::DependencyPtr> parse(const std::string_view &);
+ std::vector<Gentoo::DependencyPtr> ds;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/main.cpp b/gentoobrowse-api/service/main.cpp
index 7fd74ca..233aa91 100644
--- a/gentoobrowse-api/service/main.cpp
+++ b/gentoobrowse-api/service/main.cpp
@@ -12,42 +12,40 @@
#include <libexslt/exslt.h>
#include <libxslt/transform.h>
-namespace Gentoo {
- namespace Service {
- class Api : public IceTray::Service {
- public:
- Api()
- {
- xmlInitParser();
- exsltRegisterAll();
- git_libgit2_init();
- }
+namespace Gentoo::Service {
+ class Api : public IceTray::Service {
+ public:
+ Api()
+ {
+ xmlInitParser();
+ exsltRegisterAll();
+ git_libgit2_init();
+ }
- ~Api()
- {
- xsltCleanupGlobals();
- xmlCleanupParser();
- git_libgit2_shutdown();
- }
+ ~Api() override
+ {
+ xsltCleanupGlobals();
+ xmlCleanupParser();
+ git_libgit2_shutdown();
+ }
- SPECIAL_MEMBERS_DELETE(Api);
+ SPECIAL_MEMBERS_DELETE(Api);
- void
- addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &,
- const Ice::ObjectAdapterPtr & adp) override
- {
- auto db = getConnectionPool(ic, "postgresql", "GentooBrowseAPI");
- auto dbp = getConnectionPool(ic, "postgresql", "GentooBrowseAPIprimary");
- auto props = ic->getProperties();
- IceTray::Cube::addObject<Gentoo::Portage, Portage>(adp, "portage", db);
- IceTray::Cube::addObject<Gentoo::Maintenance, Maintenance>(adp, "maintenance", dbp, ic, props);
- IceTray::Cube::addObject<Gentoo::Users, Users>(adp, "users", dbp);
- IceTray::Cube::add<Gentoo::Notifications, Notifications>();
- IceTray::Cube::add<IceTray::Mail::MailServer, IceTray::Mail::LibesmtpMailServer>(
- props->getPropertyWithDefault("GentooBrowseAPI.MailServer", "localhost:25"));
- }
- };
+ void
+ addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &,
+ const Ice::ObjectAdapterPtr & adp) override
+ {
+ auto db = getConnectionPool(ic, "postgresql", "GentooBrowseAPI");
+ auto dbp = getConnectionPool(ic, "postgresql", "GentooBrowseAPIprimary");
+ auto props = ic->getProperties();
+ IceTray::Cube::addObject<Gentoo::Portage, Portage>(adp, "portage", db);
+ IceTray::Cube::addObject<Gentoo::Maintenance, Maintenance>(adp, "maintenance", dbp, ic, props);
+ IceTray::Cube::addObject<Gentoo::Users, Users>(adp, "users", dbp);
+ IceTray::Cube::add<Gentoo::Notifications, Notifications>();
+ IceTray::Cube::add<IceTray::Mail::MailServer, IceTray::Mail::LibesmtpMailServer>(
+ props->getPropertyWithDefault("GentooBrowseAPI.MailServer", "localhost:25"));
+ }
+ };
- NAMEDFACTORY("default", Api, IceTray::ServiceFactory);
- }
+ NAMEDFACTORY("default", Api, IceTray::ServiceFactory);
}
diff --git a/gentoobrowse-api/service/maintenance/abstractFileProcessor.cpp b/gentoobrowse-api/service/maintenance/abstractFileProcessor.cpp
index 6c74ecb..fa0f457 100644
--- a/gentoobrowse-api/service/maintenance/abstractFileProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/abstractFileProcessor.cpp
@@ -3,28 +3,24 @@
INSTANTIATEVOIDFACTORY(Gentoo::Service::AbstractFileProcessor);
-namespace Gentoo {
- namespace Service {
- AbstractFileProcessor::~AbstractFileProcessor() { }
-
- void
- AbstractFileProcessor::prepare(DB::Connection *)
- {
- }
+namespace Gentoo::Service {
+ void
+ AbstractFileProcessor::prepare(DB::Connection *)
+ {
+ }
- void
- AbstractFileProcessor::apply(DB::Connection *, ChangeSet &)
- {
- }
+ void
+ AbstractFileProcessor::apply(DB::Connection *, ChangeSet &)
+ {
+ }
- void
- AbstractFileProcessor::phaseEnd(DB::Connection *, ChangeSet &)
- {
- }
+ void
+ AbstractFileProcessor::phaseEnd(DB::Connection *, ChangeSet &)
+ {
+ }
- void
- AbstractFileProcessor::tidy(DB::Connection *)
- {
- }
+ void
+ AbstractFileProcessor::tidy(DB::Connection *)
+ {
}
}
diff --git a/gentoobrowse-api/service/maintenance/abstractFileProcessor.h b/gentoobrowse-api/service/maintenance/abstractFileProcessor.h
index 0ffdcce..8cf1fb0 100644
--- a/gentoobrowse-api/service/maintenance/abstractFileProcessor.h
+++ b/gentoobrowse-api/service/maintenance/abstractFileProcessor.h
@@ -1,40 +1,38 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_ABSTRACTPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_ABSTRACTPROC_H
+#pragma once
#include "changeSet.h"
+#include <c++11Helpers.h>
#include <connection.h>
#include <factory.h>
#include <filesystem>
#include <maintenance.h>
-namespace Gentoo {
- namespace Service {
- typedef std::vector<std::string> PathParts;
+namespace Gentoo::Service {
+ using PathParts = std::vector<std::string>;
- class AbstractFileProcessor {
- public:
- virtual ~AbstractFileProcessor() = 0;
+ class AbstractFileProcessor {
+ public:
+ AbstractFileProcessor() = default;
+ virtual ~AbstractFileProcessor() = default;
+ SPECIAL_MEMBERS_DEFAULT(AbstractFileProcessor);
- virtual unsigned char phase() const = 0;
- virtual unsigned char order() const = 0;
- virtual bool match(const PathParts & pp) const = 0;
+ [[nodiscard]] virtual unsigned char phase() const = 0;
+ [[nodiscard]] virtual unsigned char order() const = 0;
+ [[nodiscard]] virtual bool match(const PathParts & pp) const = 0;
- virtual void prepare(DB::Connection *);
- virtual void apply(DB::Connection *, ChangeSet &);
- virtual void phaseEnd(DB::Connection *, ChangeSet &);
- virtual void tidy(DB::Connection *);
+ virtual void prepare(DB::Connection *);
+ virtual void apply(DB::Connection *, ChangeSet &);
+ virtual void phaseEnd(DB::Connection *, ChangeSet &);
+ virtual void tidy(DB::Connection *);
- virtual void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path)
- = 0;
- virtual void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path)
- = 0;
- virtual void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) = 0;
- };
- typedef std::shared_ptr<AbstractFileProcessor> FileProcessorPtr;
- typedef AdHoc::Factory<AbstractFileProcessor> FileProcessorFactory;
- }
+ virtual void created(
+ DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn, const std::filesystem::path & path)
+ = 0;
+ virtual void modified(
+ DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn, const std::filesystem::path & path)
+ = 0;
+ virtual void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) = 0;
+ };
+ using FileProcessorPtr = std::shared_ptr<AbstractFileProcessor>;
+ using FileProcessorFactory = AdHoc::Factory<AbstractFileProcessor>;
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp
index f452390..26874ea 100644
--- a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp
@@ -10,52 +10,50 @@ namespace U = Gentoo::Utils;
using namespace AdHoc;
using namespace AdHoc::FileUtils;
-namespace Gentoo {
- namespace Service {
- unsigned char
- CategoryMetaProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- CategoryMetaProcessor::order() const
- {
- return 2;
- }
- bool
- CategoryMetaProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 2 && pp[1] == "metadata.xml");
- }
+namespace Gentoo::Service {
+ unsigned char
+ CategoryMetaProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ CategoryMetaProcessor::order() const
+ {
+ return 2;
+ }
+ bool
+ CategoryMetaProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 2 && pp[1] == "metadata.xml");
+ }
- void
- CategoryMetaProcessor::created(
- DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
- {
- modified(dbc, r, fn, path);
- }
+ void
+ CategoryMetaProcessor::created(
+ DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
+ {
+ modified(dbc, r, fn, path);
+ }
- void
- CategoryMetaProcessor::modified(
- DB::Connection * dbc, int64_t, const StringList & fn, const std::filesystem::path & path)
- {
- auto m = sql::maintenance::categoryMetaUpdate.modify(dbc);
- U::XmlDoc md(path);
- m->bindParamS(0,
- md.getXPathValue("/catmetadata/longdescription[@lang='en']/text()")
- / md.getXPathValue("/catmetadata/longdescription[1]/text()"));
- m->bindParamS(1, fn.front());
- m->execute();
- }
+ void
+ CategoryMetaProcessor::modified(
+ DB::Connection * dbc, int64_t, const StringList & fn, const std::filesystem::path & path)
+ {
+ auto m = sql::maintenance::categoryMetaUpdate.modify(dbc);
+ U::XmlDoc md(path);
+ m->bindParamS(0,
+ md.getXPathValue("/catmetadata/longdescription[@lang='en']/text()")
+ / md.getXPathValue("/catmetadata/longdescription[1]/text()"));
+ m->bindParamS(1, fn.front());
+ m->execute();
+ }
- void
- CategoryMetaProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
- {
- auto m = sql::maintenance::categoryMetaUpdate.modify(dbc);
- m->bindNull(0);
- m->bindParamS(1, fn.front());
- m->execute();
- }
+ void
+ CategoryMetaProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
+ {
+ auto m = sql::maintenance::categoryMetaUpdate.modify(dbc);
+ m->bindNull(0);
+ m->bindParamS(1, fn.front());
+ m->execute();
}
}
FACTORY(Gentoo::Service::CategoryMetaProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.h b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.h
index 8915611..2dac272 100644
--- a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.h
+++ b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.h
@@ -1,24 +1,19 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_CATEGORYMETAPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_CATEGORYMETAPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
-namespace Gentoo {
- namespace Service {
- class CategoryMetaProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class CategoryMetaProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- };
- }
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
index ae241b1..ea37ea5 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
@@ -28,272 +28,270 @@ namespace U = Gentoo::Utils;
using namespace AdHoc;
using namespace AdHoc::FileUtils;
-static Glib::RefPtr<Glib::Regex> packageVersion = Glib::Regex::create("^(.+)-([0-9].*)$");
+namespace Gentoo::Service {
+ static Glib::RefPtr<Glib::Regex> packageVersion = Glib::Regex::create("^(.+)-([0-9].*)$");
-namespace Gentoo {
- namespace Service {
- EbuildMetaProcessor::EbuildMetaProcessor() : ebuildIds("ebuildId") { }
+ EbuildMetaProcessor::EbuildMetaProcessor() : ebuildIds("ebuildId") { }
- unsigned char
- EbuildMetaProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- EbuildMetaProcessor::order() const
- {
- return 1;
- }
- bool
- EbuildMetaProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 4 && pp[0] == "metadata" && pp[1] == "md5-cache");
- }
-
- void
- EbuildMetaProcessor::created(
- DB::Connection * dbc, int64_t repoId, const StringList & fn, const std::filesystem::path & path)
- {
- Glib::MatchInfo matches;
- const Glib::ustring pv = fn[3];
- if (packageVersion->match(pv, matches)) {
- U::EbuildCacheParser ecp(path);
- const std::string categoryName = fn[2];
- const std::string packageName = matches.fetch(1);
- const std::string ebuildVersion = matches.fetch(2);
+ unsigned char
+ EbuildMetaProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ EbuildMetaProcessor::order() const
+ {
+ return 1;
+ }
+ bool
+ EbuildMetaProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 4 && pp[0] == "metadata" && pp[1] == "md5-cache");
+ }
- // Maybe create a category
- auto ci = sql::maintenance::categoryInsert.modify(dbc);
- ci->bindParamS(0, categoryName);
- ci->bindParamS(1, categoryName);
- ci->execute();
- // Maybe create a package
- auto pi = sql::maintenance::packageInsert.modify(dbc);
- pi->bindParamS(0, packageName);
- pi->bindParamS(1, ecp.get("DESCRIPTION"));
- pi->bindParamS(2, packageName);
- pi->bindParamS(3, categoryName);
- pi->execute();
- // Create an ebuild
- auto m = sql::maintenance::ebuildInsert.select(dbc);
- m->bindParamS(0, ebuildVersion);
- m->bindParamS(1, ebuildVersion);
- m->bindParamS(2, ecp.get("SLOT"));
- m->bindParamS(3, ecp.get("LICENSE"));
- m->bindParamT(4, boost::posix_time::from_time_t(ecp.getStat().st_mtim.tv_sec));
- m->bindParamI(5, repoId);
- m->bindParamS(6, categoryName);
- m->bindParamS(7, packageName);
- m->forEachRow<int64_t, bool, int64_t>([this, dbc, &ecp](auto ebuildId, auto newest, auto packageId) {
- this->perEbuildUpdates(dbc, ecp, ebuildId, newest, packageId);
- });
- }
- }
+ void
+ EbuildMetaProcessor::created(
+ DB::Connection * dbc, int64_t repoId, const StringList & fn, const std::filesystem::path & path)
+ {
+ Glib::MatchInfo matches;
+ const Glib::ustring pv = fn[3];
+ if (packageVersion->match(pv, matches)) {
+ U::EbuildCacheParser ecp(path);
+ const std::string categoryName = fn[2];
+ const std::string packageName = matches.fetch(1);
+ const std::string ebuildVersion = matches.fetch(2);
- void
- EbuildMetaProcessor::modified(
- DB::Connection * dbc, int64_t repoId, const StringList & fn, const std::filesystem::path & path)
- {
- Glib::MatchInfo matches;
- const Glib::ustring pv = fn[3];
- if (packageVersion->match(pv, matches)) {
- auto m = sql::maintenance::ebuildUpdate.select(dbc);
- U::EbuildCacheParser ecp(path);
- m->bindParamS(0, ecp.get("SLOT"));
- m->bindParamS(1, ecp.get("LICENSE"));
- m->bindParamT(2, boost::posix_time::from_time_t(ecp.getStat().st_mtim.tv_sec));
- m->bindParamI(3, repoId);
- m->bindParamS(4, fn[2]); // category
- m->bindParamS(5, matches.fetch(1)); // package
- m->bindParamS(6, matches.fetch(2)); // version
- m->forEachRow<int64_t, bool, int64_t>([this, dbc, &ecp](auto ebuildId, auto newest, auto packageId) {
- this->perEbuildUpdates(dbc, ecp, ebuildId, newest, packageId);
- });
- }
+ // Maybe create a category
+ auto ci = sql::maintenance::categoryInsert.modify(dbc);
+ ci->bindParamS(0, categoryName);
+ ci->bindParamS(1, categoryName);
+ ci->execute();
+ // Maybe create a package
+ auto pi = sql::maintenance::packageInsert.modify(dbc);
+ pi->bindParamS(0, packageName);
+ pi->bindParamS(1, ecp.get("DESCRIPTION"));
+ pi->bindParamS(2, packageName);
+ pi->bindParamS(3, categoryName);
+ pi->execute();
+ // Create an ebuild
+ auto m = sql::maintenance::ebuildInsert.select(dbc);
+ m->bindParamS(0, ebuildVersion);
+ m->bindParamS(1, ebuildVersion);
+ m->bindParamS(2, ecp.get("SLOT"));
+ m->bindParamS(3, ecp.get("LICENSE"));
+ m->bindParamT(4, boost::posix_time::from_time_t(ecp.getStat().st_mtim.tv_sec));
+ m->bindParamI(5, repoId);
+ m->bindParamS(6, categoryName);
+ m->bindParamS(7, packageName);
+ m->forEachRow<int64_t, bool, int64_t>([this, dbc, &ecp](auto ebuildId, auto newest, auto packageId) {
+ this->perEbuildUpdates(dbc, ecp, ebuildId, newest, packageId);
+ });
}
+ }
- void
- EbuildMetaProcessor::prepare(DB::Connection * dbc)
- {
- depInsert = Utils::Database::namedTemp(dbc, "tmpEbuildDeps",
- {
- {"ebuildId", "int"}, // 1
- {"runtime", "boolean"}, // 5
- {"category", "text"}, // 0
- {"package", "text"}, // 4
- {"version", "text"}, // 7
- {"slot", "text"}, // 6
- {"flags", "text"}, // 2
- {"op", "text"} // 3
- })
- .second;
- Utils::Database::namedTemp(dbc, "tmpEbuildUses",
- {
- {"ebuildId", "int"},
- {"use", "text"},
- {"defaultflag", "boolean"},
- });
- useInsert = sql::maintenance::ebuildUsesInsert.modify(dbc);
- Utils::Database::namedTemp(dbc, "tmpEbuildArchs",
- {
- {"ebuildId", "int"},
- {"arch", "text"},
- });
- archInsert = sql::maintenance::ebuildArchsInsert.modify(dbc);
+ void
+ EbuildMetaProcessor::modified(
+ DB::Connection * dbc, int64_t repoId, const StringList & fn, const std::filesystem::path & path)
+ {
+ Glib::MatchInfo matches;
+ const Glib::ustring pv = fn[3];
+ if (packageVersion->match(pv, matches)) {
+ auto m = sql::maintenance::ebuildUpdate.select(dbc);
+ U::EbuildCacheParser ecp(path);
+ m->bindParamS(0, ecp.get("SLOT"));
+ m->bindParamS(1, ecp.get("LICENSE"));
+ m->bindParamT(2, boost::posix_time::from_time_t(ecp.getStat().st_mtim.tv_sec));
+ m->bindParamI(3, repoId);
+ m->bindParamS(4, fn[2]); // category
+ m->bindParamS(5, matches.fetch(1)); // package
+ m->bindParamS(6, matches.fetch(2)); // version
+ m->forEachRow<int64_t, bool, int64_t>([this, dbc, &ecp](auto ebuildId, auto newest, auto packageId) {
+ this->perEbuildUpdates(dbc, ecp, ebuildId, newest, packageId);
+ });
}
+ }
- void
- EbuildMetaProcessor::apply(DB::Connection * dbc, ChangeSet &)
- {
- if (!ebuildIds.entityIds.empty()) {
+ void
+ EbuildMetaProcessor::prepare(DB::Connection * dbc)
+ {
+ depInsert = Utils::Database::namedTemp(dbc, "tmpEbuildDeps",
{
- 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 = &ebuildIds;
-
- 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);
- }
+ {"ebuildId", "int"}, // 1
+ {"runtime", "boolean"}, // 5
+ {"category", "text"}, // 0
+ {"package", "text"}, // 4
+ {"version", "text"}, // 7
+ {"slot", "text"}, // 6
+ {"flags", "text"}, // 2
+ {"op", "text"} // 3
+ })
+ .second;
+ Utils::Database::namedTemp(dbc, "tmpEbuildUses",
{
- dbc->execute("CREATE UNIQUE INDEX idxTmpEbuildUses ON tmpEbuildUses(ebuildId, use)");
- DB::TablePatch t;
- t.src = "tmpEbuildUses";
- t.dest = "gentoobrowse.ebuild_uses";
- t.pk = {"ebuildid", "use"};
- t.cols = {"ebuildid", "use", "defaultflag"};
- t.where = &ebuildIds;
- dbc->patchTable(&t);
- }
+ {"ebuildId", "int"},
+ {"use", "text"},
+ {"defaultflag", "boolean"},
+ });
+ useInsert = sql::maintenance::ebuildUsesInsert.modify(dbc);
+ Utils::Database::namedTemp(dbc, "tmpEbuildArchs",
{
- dbc->execute("CREATE UNIQUE INDEX idxTmpEbuildArchs ON tmpEbuildArchs(ebuildId, arch)");
- DB::TablePatch t;
- t.src = "tmpEbuildArchs";
- t.dest = "gentoobrowse.ebuild_archs";
- t.pk = {"ebuildid", "arch"};
- t.cols = {"ebuildid", "arch"};
- t.where = &ebuildIds;
- dbc->patchTable(&t);
- }
- }
- if (!packagesToPrune.empty()) {
- bool any = false;
- for (const auto & catPkg : packagesToPrune) {
- // Prune packages
- auto pp = sql::maintenance::packagePrune.modify(dbc);
- pp->bindParamS(0, catPkg.first);
- pp->bindParamS(1, catPkg.second);
- any |= pp->execute();
- }
- if (any) {
- // Prune categories
- sql::maintenance::categoryPrune.modify(dbc)->execute();
- }
- }
- }
+ {"ebuildId", "int"},
+ {"arch", "text"},
+ });
+ archInsert = sql::maintenance::ebuildArchsInsert.modify(dbc);
+ }
- void
- EbuildMetaProcessor::tidy(DB::Connection * dbc)
- {
- Utils::Database::drop(dbc, "tmpEbuildDeps");
- Utils::Database::drop(dbc, "tmpEbuildUses");
- Utils::Database::drop(dbc, "tmpEbuildArchs");
- }
+ void
+ EbuildMetaProcessor::apply(DB::Connection * dbc, ChangeSet &)
+ {
+ if (!ebuildIds.entityIds.empty()) {
+ {
+ 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 = &ebuildIds;
- void
- EbuildMetaProcessor::perEbuildUpdates(DB::Connection * dbc, const U::EbuildCacheParser & ecp, int64_t ebuildId,
- bool newest, int64_t packageId)
- {
- ebuildIds.entityIds.insert(ebuildId);
- // IUSE
- if (auto uses = ecp.get("IUSE")) {
- useInsert->bindParamI(0, ebuildId);
- useInsert->bindParamS(1, *uses);
- useInsert->execute();
- }
- // KEYWORDS
- if (auto keywords = ecp.get("KEYWORDS")) {
- archInsert->bindParamI(0, ebuildId);
- archInsert->bindParamS(1, *keywords);
- archInsert->execute();
- }
- // Dependencies
- depInsert->bindParamI(1, ebuildId);
- if (auto depend = ecp.getRange("DEPEND")) {
- depInsert->bindParamB(5, false);
- insertDeps(Portage::Utils::Depend::parse(*depend));
+ 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);
}
- if (auto rdepend = ecp.getRange("RDEPEND")) {
- depInsert->bindParamB(5, true);
- insertDeps(Portage::Utils::Depend::parse(*rdepend));
+ {
+ dbc->execute("CREATE UNIQUE INDEX idxTmpEbuildUses ON tmpEbuildUses(ebuildId, use)");
+ DB::TablePatch t;
+ t.src = "tmpEbuildUses";
+ t.dest = "gentoobrowse.ebuild_uses";
+ t.pk = {"ebuildid", "use"};
+ t.cols = {"ebuildid", "use", "defaultflag"};
+ t.where = &ebuildIds;
+ dbc->patchTable(&t);
}
- if (newest) {
+ {
+ dbc->execute("CREATE UNIQUE INDEX idxTmpEbuildArchs ON tmpEbuildArchs(ebuildId, arch)");
DB::TablePatch t;
- // HOMEPAGE
- U::EntityWhereFilter<int64_t> pwf("packageId", packageId);
- U::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;
+ t.src = "tmpEbuildArchs";
+ t.dest = "gentoobrowse.ebuild_archs";
+ t.pk = {"ebuildid", "arch"};
+ t.cols = {"ebuildid", "arch"};
+ t.where = &ebuildIds;
dbc->patchTable(&t);
- // Description
- auto u = sql::maintenance::packageDescUpdate.modify(dbc);
- u->bindParamS(0, ecp.get("DESCRIPTION"));
- u->bindParamI(1, packageId);
- u->execute();
}
}
+ if (!packagesToPrune.empty()) {
+ bool any = false;
+ for (const auto & catPkg : packagesToPrune) {
+ // Prune packages
+ auto pp = sql::maintenance::packagePrune.modify(dbc);
+ pp->bindParamS(0, catPkg.first);
+ pp->bindParamS(1, catPkg.second);
+ any |= pp->execute();
+ }
+ if (any) {
+ // Prune categories
+ sql::maintenance::categoryPrune.modify(dbc)->execute();
+ }
+ }
+ }
- template<typename T>
- const T &
- operator|=(const IceUtil::Optional<T> & a, const T & b)
- {
- return a ? *a : b;
+ void
+ EbuildMetaProcessor::tidy(DB::Connection * dbc)
+ {
+ Utils::Database::drop(dbc, "tmpEbuildDeps");
+ Utils::Database::drop(dbc, "tmpEbuildUses");
+ Utils::Database::drop(dbc, "tmpEbuildArchs");
+ }
+
+ void
+ EbuildMetaProcessor::perEbuildUpdates(
+ DB::Connection * dbc, const U::EbuildCacheParser & ecp, int64_t ebuildId, bool newest, int64_t packageId)
+ {
+ ebuildIds.entityIds.insert(ebuildId);
+ // IUSE
+ if (auto uses = ecp.get("IUSE")) {
+ useInsert->bindParamI(0, ebuildId);
+ useInsert->bindParamS(1, *uses);
+ useInsert->execute();
+ }
+ // KEYWORDS
+ if (auto keywords = ecp.get("KEYWORDS")) {
+ archInsert->bindParamI(0, ebuildId);
+ archInsert->bindParamS(1, *keywords);
+ archInsert->execute();
+ }
+ // Dependencies
+ depInsert->bindParamI(1, ebuildId);
+ if (auto depend = ecp.getRange("DEPEND")) {
+ depInsert->bindParamB(5, false);
+ insertDeps(Portage::Utils::Depend::parse(*depend));
}
+ if (auto rdepend = ecp.getRange("RDEPEND")) {
+ depInsert->bindParamB(5, true);
+ insertDeps(Portage::Utils::Depend::parse(*rdepend));
+ }
+ if (newest) {
+ DB::TablePatch t;
+ // HOMEPAGE
+ U::EntityWhereFilter<int64_t> pwf("packageId", packageId);
+ U::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);
+ // Description
+ auto u = sql::maintenance::packageDescUpdate.modify(dbc);
+ u->bindParamS(0, ecp.get("DESCRIPTION"));
+ u->bindParamI(1, packageId);
+ u->execute();
+ }
+ }
- void
- EbuildMetaProcessor::insertDeps(const std::vector<Gentoo::DependencyPtr> & deps)
- {
- for (const auto & d : deps) {
- depInsert->bindParamS(0, d->category);
- depInsert->bindParamS(2, boost::algorithm::join(d->use, ","));
- depInsert->bindParamS(3, d->op |= std::string());
- depInsert->bindParamS(4, d->package);
- depInsert->bindParamS(6, d->slot |= std::string());
- depInsert->bindParamS(7, d->version |= std::string());
- depInsert->execute();
- }
+ template<typename T>
+ const T &
+ operator|=(const IceUtil::Optional<T> & a, const T & b)
+ {
+ return a ? *a : b;
+ }
+
+ void
+ EbuildMetaProcessor::insertDeps(const std::vector<Gentoo::DependencyPtr> & deps)
+ {
+ for (const auto & d : deps) {
+ depInsert->bindParamS(0, d->category);
+ depInsert->bindParamS(2, boost::algorithm::join(d->use, ","));
+ depInsert->bindParamS(3, d->op |= std::string());
+ depInsert->bindParamS(4, d->package);
+ depInsert->bindParamS(6, d->slot |= std::string());
+ depInsert->bindParamS(7, d->version |= std::string());
+ depInsert->execute();
}
+ }
- void
- EbuildMetaProcessor::deleted(DB::Connection * dbc, int64_t repoId, const StringList & fn)
- {
- Glib::MatchInfo matches;
- const Glib::ustring pv = fn[3];
- if (packageVersion->match(pv, matches)) {
- const std::string categoryName = fn[2];
- const std::string packageName = matches.fetch(1);
- const std::string ebuildVersion = matches.fetch(2);
+ void
+ EbuildMetaProcessor::deleted(DB::Connection * dbc, int64_t repoId, const StringList & fn)
+ {
+ Glib::MatchInfo matches;
+ const Glib::ustring pv = fn[3];
+ if (packageVersion->match(pv, matches)) {
+ const std::string categoryName = fn[2];
+ const std::string packageName = matches.fetch(1);
+ const std::string ebuildVersion = matches.fetch(2);
- // Delete ebuild
- auto m = sql::maintenance::ebuildDelete.modify(dbc);
- m->bindParamI(0, repoId);
- m->bindParamS(1, categoryName);
- m->bindParamS(2, packageName);
- m->bindParamS(3, ebuildVersion);
- m->execute(false);
- packagesToPrune.insert({categoryName, packageName});
- }
+ // Delete ebuild
+ auto m = sql::maintenance::ebuildDelete.modify(dbc);
+ m->bindParamI(0, repoId);
+ m->bindParamS(1, categoryName);
+ m->bindParamS(2, packageName);
+ m->bindParamS(3, ebuildVersion);
+ m->execute(false);
+ packagesToPrune.insert({categoryName, packageName});
}
}
}
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
index c198262..5d143b3 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
@@ -1,5 +1,4 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_EBUILDMETAPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_EBUILDMETAPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include "utils/ebuildCacheParser.h"
@@ -9,40 +8,36 @@
#include <modifycommand.h>
#include <portage-models.h>
-namespace Gentoo {
- namespace Service {
- class EbuildMetaProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
-
- EbuildMetaProcessor();
-
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
-
- private:
- void prepare(DB::Connection * dbc) override;
- void apply(DB::Connection * dbc, ChangeSet &) override;
- void tidy(DB::Connection * dbc) override;
-
- void perEbuildUpdates(DB::Connection * dbc, const Utils::EbuildCacheParser & ecp, int64_t ebuildId,
- bool newest, int64_t packageId);
- void insertDeps(const std::vector<Gentoo::DependencyPtr> &);
-
- DB::ModifyCommandPtr depInsert;
- DB::ModifyCommandPtr useInsert;
- DB::ModifyCommandPtr archInsert;
- Utils::EntityWhereFilter<int64_t> ebuildIds;
- typedef std::pair<std::string, std::string> CategoryPackage;
- typedef std::set<CategoryPackage> PackagesToPrune;
- PackagesToPrune packagesToPrune;
- };
- }
+namespace Gentoo::Service {
+ class EbuildMetaProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
+
+ EbuildMetaProcessor();
+
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+
+ private:
+ void prepare(DB::Connection * dbc) override;
+ void apply(DB::Connection * dbc, ChangeSet &) override;
+ void tidy(DB::Connection * dbc) override;
+
+ void perEbuildUpdates(DB::Connection * dbc, const Utils::EbuildCacheParser & ecp, int64_t ebuildId, bool newest,
+ int64_t packageId);
+ void insertDeps(const std::vector<Gentoo::DependencyPtr> &);
+
+ DB::ModifyCommandPtr depInsert;
+ DB::ModifyCommandPtr useInsert;
+ DB::ModifyCommandPtr archInsert;
+ Utils::EntityWhereFilter<int64_t> ebuildIds;
+ typedef std::pair<std::string, std::string> CategoryPackage;
+ typedef std::set<CategoryPackage> PackagesToPrune;
+ PackagesToPrune packagesToPrune;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/masksProcessor.cpp b/gentoobrowse-api/service/maintenance/masksProcessor.cpp
index 242f3ac..573345b 100644
--- a/gentoobrowse-api/service/maintenance/masksProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/masksProcessor.cpp
@@ -12,98 +12,99 @@
#include <sqlWriter.h>
#include <tablepatch.h>
-namespace Gentoo {
- namespace Service {
- unsigned char
- MasksProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- MasksProcessor::order() const
- {
- return 10;
- }
- bool
- MasksProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 2 && pp[0] == "profiles" && pp[1] == "package.mask");
- }
+namespace Gentoo::Service {
+ unsigned char
+ MasksProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ MasksProcessor::order() const
+ {
+ return 10;
+ }
+ bool
+ MasksProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 2 && pp[0] == "profiles" && pp[1] == "package.mask");
+ }
+
+ void
+ MasksProcessor::created(DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
+ {
+ modified(dbc, r, fn, path);
+ }
- void
- MasksProcessor::created(
- DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
- {
- modified(dbc, r, fn, path);
- }
+ void
+ MasksProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
+ {
+ auto tempTable = Utils::Database::namedTemp(dbc, "tmp_masks",
+ {{"n", "int"}, {"dateAdded", "date"}, {"person", "text"}, {"email", "text"}, {"message", "text"},
+ {"atomSpec", "text[]"}});
- void
- MasksProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
- {
- auto tempTable = Utils::Database::namedTemp(dbc, "tmp_masks",
- {{"n", "int"}, {"dateAdded", "date"}, {"person", "text"}, {"email", "text"}, {"message", "text"},
- {"atomSpec", "text[]"}});
+ auto i = tempTable.second;
+ AdHoc::FileUtils::MemMap f(path);
- auto i = tempTable.second;
- AdHoc::FileUtils::MemMap f(path);
- class MaskInserter : public Portage::Utils::Masks {
- public:
- MaskInserter(DB::ModifyCommand * i) : i(i) { }
+ class MaskInserter : public Portage::Utils::Masks {
+ public:
+ explicit MaskInserter(DB::ModifyCommand * i) : i(i) { }
- protected:
- void
- consume() const override
- {
- i->bindParamS(0, "{" + boost::algorithm::join(atoms, ",") + "}");
- i->bindParamS(1, date);
- if (email)
- i->bindParamS(2, *email);
- else
- i->bindNull(2);
- i->bindParamS(3, boost::algorithm::join(message, " "));
- i->bindParamI(4, n);
- if (person)
- i->bindParamS(5, *person);
- else
- i->bindNull(5);
- i->execute();
+ protected:
+ void
+ consume() const override
+ {
+ i->bindParamS(0, "{" + boost::algorithm::join(atoms, ",") + "}");
+ i->bindParamS(1, date);
+ if (email) {
+ i->bindParamS(2, *email);
}
- DB::ModifyCommand * i;
- };
- MaskInserter(tempTable.second.get()).extract(f.sv<gchar>().data(), f.sv<gchar>().length());
- // Dates are hand-typed and sometimes typos occur... ensure they're at
- // least within the range of Boost ptimes.
- while (sql::maintenance::masksFixDates.modify(dbc)->execute())
- ;
+ else {
+ i->bindNull(2);
+ }
+ i->bindParamS(3, boost::algorithm::join(message, " "));
+ i->bindParamI(4, n);
+ if (person) {
+ i->bindParamS(5, *person);
+ }
+ else {
+ i->bindNull(5);
+ }
+ i->execute();
+ }
+ DB::ModifyCommand * i;
+ };
+ MaskInserter(tempTable.second.get()).extract(f.sv<gchar>().data(), f.sv<gchar>().length());
+ // Dates are hand-typed and sometimes typos occur... ensure they're at
+ // least within the range of Boost ptimes.
+ while (sql::maintenance::masksFixDates.modify(dbc)->execute()) { }
- DB::TablePatch p;
- p.dest = "gentoobrowse.masksets";
- DB::StaticSqlWriter srcExpr(sql::maintenance::masksSets.getSql());
- p.srcExpr = &srcExpr;
- p.pk = {"dateAdded", "n"};
- p.cols = {"dateAdded", "n", "person", "email", "message", "atomSpec"};
- dbc->patchTable(&p);
+ DB::TablePatch p;
+ p.dest = "gentoobrowse.masksets";
+ DB::StaticSqlWriter srcExpr(sql::maintenance::masksSets.getSql());
+ p.srcExpr = &srcExpr;
+ p.pk = {"dateAdded", "n"};
+ p.cols = {"dateAdded", "n", "person", "email", "message", "atomSpec"};
+ dbc->patchTable(&p);
- Utils::Database::drop(dbc, tempTable.first);
- }
+ Utils::Database::drop(dbc, tempTable.first);
+ }
- void
- MasksProcessor::phaseEnd(DB::Connection * dbc, ChangeSet &)
- {
- DB::TablePatch e;
- e.dest = "gentoobrowse.ebuild_masks";
- DB::StaticSqlWriter srcExprE(sql::maintenance::masksEbuilds.getSql());
- e.srcExpr = &srcExprE;
- e.pk = {"ebuildId", "setNo"};
- e.cols = e.pk;
- dbc->patchTable(&e);
- }
+ void
+ MasksProcessor::phaseEnd(DB::Connection * dbc, ChangeSet &)
+ {
+ DB::TablePatch e;
+ e.dest = "gentoobrowse.ebuild_masks";
+ DB::StaticSqlWriter srcExprE(sql::maintenance::masksEbuilds.getSql());
+ e.srcExpr = &srcExprE;
+ e.pk = {"ebuildId", "setNo"};
+ e.cols = e.pk;
+ dbc->patchTable(&e);
+ }
- void
- MasksProcessor::deleted(DB::Connection * dbc, int64_t, const StringList &)
- {
- dbc->modify("DELETE FROM gentoobrowse.masksets")->execute();
- }
+ void
+ MasksProcessor::deleted(DB::Connection * dbc, int64_t, const StringList &)
+ {
+ dbc->modify("DELETE FROM gentoobrowse.masksets")->execute();
}
}
FACTORY(Gentoo::Service::MasksProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/masksProcessor.h b/gentoobrowse-api/service/maintenance/masksProcessor.h
index fca6ec8..ca3c828 100644
--- a/gentoobrowse-api/service/maintenance/masksProcessor.h
+++ b/gentoobrowse-api/service/maintenance/masksProcessor.h
@@ -1,28 +1,23 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_MASKSPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_MASKSPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
#include <filesystem>
#include <modifycommand.h>
-namespace Gentoo {
- namespace Service {
- class MasksProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class MasksProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- void phaseEnd(DB::Connection *, ChangeSet &) override;
- };
- }
+ void phaseEnd(DB::Connection *, ChangeSet &) override;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/newsProcessor.cpp b/gentoobrowse-api/service/maintenance/newsProcessor.cpp
index 8a67c3e..b175ba2 100644
--- a/gentoobrowse-api/service/maintenance/newsProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/newsProcessor.cpp
@@ -8,54 +8,52 @@
#include <slicer/slicer.h>
#include <sql/maintenance/newsDelete.sql.h>
-namespace Gentoo {
- namespace Service {
- unsigned char
- NewsProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- NewsProcessor::order() const
- {
- return 10;
- }
- bool
- NewsProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 4 && pp[0] == "metadata" && pp[1] == "news"
- && boost::algorithm::ends_with(pp[3], ".en.txt"));
- }
+namespace Gentoo::Service {
+ unsigned char
+ NewsProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ NewsProcessor::order() const
+ {
+ return 10;
+ }
+ bool
+ NewsProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 4 && pp[0] == "metadata" && pp[1] == "news"
+ && boost::algorithm::ends_with(pp[3], ".en.txt"));
+ }
- void
- NewsProcessor::created(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
- {
- importNews<Slicer::SqlInsertSerializer>(dbc, path);
- }
+ void
+ NewsProcessor::created(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
+ {
+ importNews<Slicer::SqlInsertSerializer>(dbc, path);
+ }
- void
- NewsProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
- {
- importNews<Slicer::SqlUpdateSerializer>(dbc, path);
- }
+ void
+ NewsProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
+ {
+ importNews<Slicer::SqlUpdateSerializer>(dbc, path);
+ }
- template<typename Serializer>
- void
- NewsProcessor::importNews(DB::Connection * dbc, const std::filesystem::path & path)
- {
- AdHoc::FileUtils::MemMap m(path);
- auto news = Portage::Utils::News::parse(m.sv<gchar>());
- news->newsid = path.parent_path().filename();
- Slicer::SerializeAny<Serializer>(news, dbc, "gentoobrowse.news");
- }
+ template<typename Serializer>
+ void
+ NewsProcessor::importNews(DB::Connection * dbc, const std::filesystem::path & path)
+ {
+ AdHoc::FileUtils::MemMap m(path);
+ auto news = Portage::Utils::News::parse(m.sv<gchar>());
+ news->newsid = path.parent_path().filename();
+ Slicer::SerializeAny<Serializer>(news, dbc, "gentoobrowse.news");
+ }
- void
- NewsProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
- {
- auto del = sql::maintenance::newsDelete.modify(dbc);
- del->bindParamS(0, *++fn.rbegin());
- del->execute();
- }
+ void
+ NewsProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
+ {
+ auto del = sql::maintenance::newsDelete.modify(dbc);
+ del->bindParamS(0, *++fn.rbegin());
+ del->execute();
}
}
FACTORY(Gentoo::Service::NewsProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/newsProcessor.h b/gentoobrowse-api/service/maintenance/newsProcessor.h
index c51e1f8..b067613 100644
--- a/gentoobrowse-api/service/maintenance/newsProcessor.h
+++ b/gentoobrowse-api/service/maintenance/newsProcessor.h
@@ -1,30 +1,24 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_NEWSPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_NEWSPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
#include <filesystem>
#include <portage-models.h>
-namespace Gentoo {
- namespace Service {
- class NewsProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class NewsProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- private:
- template<typename Serializer>
- static void importNews(DB::Connection * dbc, const std::filesystem::path & path);
- };
- }
+ private:
+ template<typename Serializer> static void importNews(DB::Connection * dbc, const std::filesystem::path & path);
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp
index df3e2da..e27c2d7 100644
--- a/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp
@@ -10,56 +10,54 @@ namespace U = Gentoo::Utils;
using namespace AdHoc;
using namespace AdHoc::FileUtils;
-namespace Gentoo {
- namespace Service {
- unsigned char
- PackageMetaProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- PackageMetaProcessor::order() const
- {
- return 3;
- }
- bool
- PackageMetaProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 3 && pp[2] == "metadata.xml");
- }
+namespace Gentoo::Service {
+ unsigned char
+ PackageMetaProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ PackageMetaProcessor::order() const
+ {
+ return 3;
+ }
+ bool
+ PackageMetaProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 3 && pp[2] == "metadata.xml");
+ }
- void
- PackageMetaProcessor::created(
- DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
- {
- modified(dbc, r, fn, path);
- }
+ void
+ PackageMetaProcessor::created(
+ DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
+ {
+ modified(dbc, r, fn, path);
+ }
- void
- PackageMetaProcessor::modified(
- DB::Connection * dbc, int64_t, const StringList & fn, const std::filesystem::path & path)
- {
- auto m = sql::maintenance::packageMetaUpdate.modify(dbc);
- U::XmlDoc md(path);
- m->bindParamS(0,
- md.getXPathValue("/pkgmetadata/longdescription[@lang='en']/text()")
- / md.getXPathValue("/pkgmetadata/longdescription[1]/text()"));
- m->bindParamS(1, md.getXPathValue("/pkgmetadata/herd/text()"));
- m->bindParamS(2, fn[0]);
- m->bindParamS(3, fn[1]);
- m->execute();
- }
+ void
+ PackageMetaProcessor::modified(
+ DB::Connection * dbc, int64_t, const StringList & fn, const std::filesystem::path & path)
+ {
+ auto m = sql::maintenance::packageMetaUpdate.modify(dbc);
+ U::XmlDoc md(path);
+ m->bindParamS(0,
+ md.getXPathValue("/pkgmetadata/longdescription[@lang='en']/text()")
+ / md.getXPathValue("/pkgmetadata/longdescription[1]/text()"));
+ m->bindParamS(1, md.getXPathValue("/pkgmetadata/herd/text()"));
+ m->bindParamS(2, fn[0]);
+ m->bindParamS(3, fn[1]);
+ m->execute();
+ }
- void
- PackageMetaProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
- {
- auto m = sql::maintenance::packageMetaUpdate.modify(dbc);
- m->bindNull(0);
- m->bindNull(1);
- m->bindParamS(2, fn[0]);
- m->bindParamS(3, fn[1]);
- m->execute();
- }
+ void
+ PackageMetaProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
+ {
+ auto m = sql::maintenance::packageMetaUpdate.modify(dbc);
+ m->bindNull(0);
+ m->bindNull(1);
+ m->bindParamS(2, fn[0]);
+ m->bindParamS(3, fn[1]);
+ m->execute();
}
}
FACTORY(Gentoo::Service::PackageMetaProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/packageMetaProcessor.h b/gentoobrowse-api/service/maintenance/packageMetaProcessor.h
index 2dfda96..e5fdfdc 100644
--- a/gentoobrowse-api/service/maintenance/packageMetaProcessor.h
+++ b/gentoobrowse-api/service/maintenance/packageMetaProcessor.h
@@ -1,25 +1,20 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_PACKAGEMETAPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_PACKAGEMETAPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
#include <filesystem>
-namespace Gentoo {
- namespace Service {
- class PackageMetaProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class PackageMetaProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- };
- }
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp
index c56bc55..a12e5f9 100644
--- a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp
@@ -5,6 +5,7 @@
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <buffer.h>
+#include <c++11Helpers.h>
#include <fileUtils.h>
#include <fstream>
#include <modifycommand.h>
@@ -17,159 +18,159 @@
using namespace AdHoc::FileUtils;
-static Glib::RefPtr<Glib::Regex> move
- = Glib::Regex::create(R"R(^move ([^/]+)/([^ ]+) ([^/]+)/(.+)$)R", Glib::RegexCompileFlags::REGEX_MULTILINE);
+namespace Gentoo::Service {
+ static Glib::RefPtr<Glib::Regex> move
+ = Glib::Regex::create(R"R(^move ([^/]+)/([^ ]+) ([^/]+)/(.+)$)R", Glib::RegexCompileFlags::REGEX_MULTILINE);
-namespace Gentoo {
- namespace Service {
- unsigned char
- UpdatesProcessor::phase() const
- {
- return 1;
- }
- unsigned char
- UpdatesProcessor::order() const
- {
- return 1;
- }
- bool
- UpdatesProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 3 && pp[0] == "profiles" && pp[1] == "updates" && pp[2].substr(1, 4) == "Q-20");
- }
-
- class UpdatesPatch : public DB::TablePatch, public DB::SqlWriter {
- public:
- UpdatesPatch(DB::Connection * db) :
- categoryInsert(sql::maintenance::categoryInsert.modify(db)),
- packageInsert(sql::maintenance::packageInsert.modify(db)),
- findPackage(sql::portage::findPackage.select(db)),
- updatesMoveUserPackages(sql::maintenance::updatesMoveUserPackages.modify(db)), changes(nullptr),
- updatePacks("updatePack")
- {
- this->src = Utils::Database::emptyClone(db, "gentoobrowse.updates");
- this->dest = "gentoobrowse.updates";
- this->pk = {"updatePack", "catfrom", "namefrom"};
- this->cols = {"updatePack", "catfrom", "namefrom", "catto", "nameto"};
- this->where = &updatePacks;
- this->order = this;
- this->beforeInsert = std::bind(&UpdatesPatch::move, this, std::placeholders::_1);
- drop = db->modify("DROP TABLE " + this->src);
- }
-
- ~UpdatesPatch()
- {
- if (!std::uncaught_exceptions()) {
- drop->execute();
- }
- }
-
- void
- writeSql(AdHoc::Buffer & sql) override
- {
- sql.append("SPLIT_PART(b.updatePack, '-', 2)::INT, SUBSTR(b.updatePack, 1, 1)::INT");
- }
-
- DB::ModifyCommandPtr drop;
- DB::ModifyCommandPtr categoryInsert;
- DB::ModifyCommandPtr packageInsert;
- DB::SelectCommandPtr findPackage;
- DB::ModifyCommandPtr updatesMoveUserPackages;
- ChangeSet * changes;
- Utils::EntityWhereFilter<std::string> updatePacks;
-
- void
- move(DB::SelectCommandPtr s)
- {
- s->forEachRow<std::string, std::string, std::string, std::string, std::string>(
- [this](auto catfrom, auto catto, auto namefrom, auto nameto, auto) {
- if (this->exists(catfrom, namefrom)
- && !this->exists(catto, nameto)) { // Does target already exist?
- // Create category
- categoryInsert->bindParamS(0, catto);
- categoryInsert->bindParamS(1, catto);
- categoryInsert->execute();
- // Create package
- packageInsert->bindParamS(0, nameto);
- packageInsert->bindParamS(1, "Created by package move");
- packageInsert->bindParamS(2, nameto);
- packageInsert->bindParamS(3, catto);
- packageInsert->execute();
- }
- updatesMoveUserPackages->bindParamS(0, catfrom);
- updatesMoveUserPackages->bindParamS(1, namefrom);
- updatesMoveUserPackages->bindParamS(2, catto);
- updatesMoveUserPackages->bindParamS(3, nameto);
- updatesMoveUserPackages->execute();
- });
- }
-
- bool
- exists(const std::string & cat, const std::string & pkg)
- {
- bool found = false;
- findPackage->bindParamS(0, cat);
- findPackage->bindParamS(1, pkg);
- while (findPackage->fetch()) {
- found = true;
- }
- return found;
- }
- };
+ unsigned char
+ UpdatesProcessor::phase() const
+ {
+ return 1;
+ }
+ unsigned char
+ UpdatesProcessor::order() const
+ {
+ return 1;
+ }
+ bool
+ UpdatesProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 3 && pp[0] == "profiles" && pp[1] == "updates" && pp[2].substr(1, 4) == "Q-20");
+ }
- void
- UpdatesProcessor::prepare(DB::Connection * dbc)
+ class UpdatesPatch : public DB::TablePatch, public DB::SqlWriter {
+ public:
+ explicit UpdatesPatch(DB::Connection * db) :
+ categoryInsert(sql::maintenance::categoryInsert.modify(db)),
+ packageInsert(sql::maintenance::packageInsert.modify(db)),
+ findPackage(sql::portage::findPackage.select(db)),
+ updatesMoveUserPackages(sql::maintenance::updatesMoveUserPackages.modify(db)), changes(nullptr),
+ updatePacks("updatePack")
{
- up = new UpdatesPatch(dbc);
+ this->src = Utils::Database::emptyClone(db, "gentoobrowse.updates");
+ this->dest = "gentoobrowse.updates";
+ this->pk = {"updatePack", "catfrom", "namefrom"};
+ this->cols = {"updatePack", "catfrom", "namefrom", "catto", "nameto"};
+ this->where = &updatePacks;
+ this->order = this;
+ this->beforeInsert = [this](auto && PH1) {
+ move(std::forward<decltype(PH1)>(PH1));
+ };
+ drop = db->modify("DROP TABLE " + this->src);
}
- void
- UpdatesProcessor::apply(DB::Connection * dbc, ChangeSet & changes)
+ ~UpdatesPatch() override
{
- if (!up->updatePacks.entityIds.empty()) {
- up->changes = &changes;
- dbc->patchTable(up);
+ if (!std::uncaught_exceptions()) {
+ drop->execute();
}
}
+ SPECIAL_MEMBERS_DELETE(UpdatesPatch);
void
- UpdatesProcessor::tidy(DB::Connection *)
+ writeSql(AdHoc::Buffer & sql) override
{
- delete up;
+ sql.append("SPLIT_PART(b.updatePack, '-', 2)::INT, SUBSTR(b.updatePack, 1, 1)::INT");
}
+ DB::ModifyCommandPtr drop;
+ DB::ModifyCommandPtr categoryInsert;
+ DB::ModifyCommandPtr packageInsert;
+ DB::SelectCommandPtr findPackage;
+ DB::ModifyCommandPtr updatesMoveUserPackages;
+ ChangeSet * changes;
+ Utils::EntityWhereFilter<std::string> updatePacks;
+
void
- UpdatesProcessor::created(
- DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
+ move(const DB::SelectCommandPtr & s)
{
- modified(dbc, r, fn, path);
+ s->forEachRow<std::string, std::string, std::string, std::string, std::string>(
+ [this](auto catfrom, auto catto, auto namefrom, auto nameto, auto) {
+ if (this->exists(catfrom, namefrom)
+ && !this->exists(catto, nameto)) { // Does target already exist?
+ // Create category
+ categoryInsert->bindParamS(0, catto);
+ categoryInsert->bindParamS(1, catto);
+ categoryInsert->execute();
+ // Create package
+ packageInsert->bindParamS(0, nameto);
+ packageInsert->bindParamS(1, "Created by package move");
+ packageInsert->bindParamS(2, nameto);
+ packageInsert->bindParamS(3, catto);
+ packageInsert->execute();
+ }
+ updatesMoveUserPackages->bindParamS(0, catfrom);
+ updatesMoveUserPackages->bindParamS(1, namefrom);
+ updatesMoveUserPackages->bindParamS(2, catto);
+ updatesMoveUserPackages->bindParamS(3, nameto);
+ updatesMoveUserPackages->execute();
+ });
}
- void
- UpdatesProcessor::modified(
- DB::Connection * dbc, int64_t, const StringList & fn, const std::filesystem::path & path)
+ bool
+ exists(const std::string & cat, const std::string & pkg)
{
- AdHoc::FileUtils::MemMap u(path);
- Glib::ustring d(std::string(u.sv()));
- Glib::MatchInfo matches;
- auto i = Utils::Database::tablePatchInserter(dbc, *up);
- i->bindParamS(4, fn.back().c_str());
- up->updatePacks.entityIds.insert(fn.back());
- for (move->match(d, matches); matches.get_match_count() == 5; matches.next()) {
- i->bindParamS(0, matches.fetch(1));
- i->bindParamS(1, matches.fetch(3));
- i->bindParamS(2, matches.fetch(2));
- i->bindParamS(3, matches.fetch(4));
- i->execute();
+ bool found = false;
+ findPackage->bindParamS(0, cat);
+ findPackage->bindParamS(1, pkg);
+ while (findPackage->fetch()) {
+ found = true;
}
+ return found;
}
+ };
- void
- UpdatesProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & p)
- {
- auto del = dbc->modify("DELETE FROM gentoobrowse.updates WHERE updatePack = ?");
- del->bindParamS(0, p.back());
+ void
+ UpdatesProcessor::prepare(DB::Connection * dbc)
+ {
+ up = new UpdatesPatch(dbc);
+ }
+
+ void
+ UpdatesProcessor::apply(DB::Connection * dbc, ChangeSet & changes)
+ {
+ if (!up->updatePacks.entityIds.empty()) {
+ up->changes = &changes;
+ dbc->patchTable(up);
}
}
+
+ void
+ UpdatesProcessor::tidy(DB::Connection *)
+ {
+ delete up;
+ }
+
+ void
+ UpdatesProcessor::created(
+ DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
+ {
+ modified(dbc, r, fn, path);
+ }
+
+ void
+ UpdatesProcessor::modified(DB::Connection * dbc, int64_t, const StringList & fn, const std::filesystem::path & path)
+ {
+ AdHoc::FileUtils::MemMap u(path);
+ Glib::ustring d(std::string(u.sv()));
+ Glib::MatchInfo matches;
+ auto i = Utils::Database::tablePatchInserter(dbc, *up);
+ i->bindParamS(4, fn.back().c_str());
+ up->updatePacks.entityIds.insert(fn.back());
+ for (move->match(d, matches); matches.get_match_count() == 5; matches.next()) {
+ i->bindParamS(0, matches.fetch(1));
+ i->bindParamS(1, matches.fetch(3));
+ i->bindParamS(2, matches.fetch(2));
+ i->bindParamS(3, matches.fetch(4));
+ i->execute();
+ }
+ }
+
+ void
+ UpdatesProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & p)
+ {
+ auto del = dbc->modify("DELETE FROM gentoobrowse.updates WHERE updatePack = ?");
+ del->bindParamS(0, p.back());
+ }
}
FACTORY(Gentoo::Service::UpdatesProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/updatesProcessor.h b/gentoobrowse-api/service/maintenance/updatesProcessor.h
index fa7a390..0063db7 100644
--- a/gentoobrowse-api/service/maintenance/updatesProcessor.h
+++ b/gentoobrowse-api/service/maintenance/updatesProcessor.h
@@ -1,34 +1,29 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_UPDATESPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_UPDATESPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
#include <filesystem>
#include <modifycommand.h>
-namespace Gentoo {
- namespace Service {
- class UpdatesPatch;
- class UpdatesProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class UpdatesPatch;
+ class UpdatesProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- void prepare(DB::Connection * dbc) override;
- void apply(DB::Connection * dbc, ChangeSet &) override;
- void tidy(DB::Connection * dbc) override;
+ void prepare(DB::Connection * dbc) override;
+ void apply(DB::Connection * dbc, ChangeSet &) override;
+ void tidy(DB::Connection * dbc) override;
- private:
- UpdatesPatch * up;
- };
- }
+ private:
+ UpdatesPatch * up;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/useGlobalProcessor.cpp b/gentoobrowse-api/service/maintenance/useGlobalProcessor.cpp
index 6f0775b..04408ab 100644
--- a/gentoobrowse-api/service/maintenance/useGlobalProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/useGlobalProcessor.cpp
@@ -7,63 +7,60 @@
using namespace AdHoc::FileUtils;
-static Glib::RefPtr<Glib::Regex> useDesc
- = Glib::Regex::create("^([^#\\s][^ ]*)\\s+-\\s+(.*)$", Glib::RegexCompileFlags::REGEX_MULTILINE);
+namespace Gentoo::Service {
+ static Glib::RefPtr<Glib::Regex> useDesc
+ = Glib::Regex::create(R"(^([^#\s][^ ]*)\s+-\s+(.*)$)", Glib::RegexCompileFlags::REGEX_MULTILINE);
-namespace Gentoo {
- namespace Service {
- unsigned char
- UseGlobalProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- UseGlobalProcessor::order() const
- {
- return 10;
- }
- bool
- UseGlobalProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 2 && pp[0] == "profiles" && pp[1] == "use.desc");
- }
-
- void
- UseGlobalProcessor::created(
- DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
- {
- modified(dbc, r, fn, path);
- }
+ unsigned char
+ UseGlobalProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ UseGlobalProcessor::order() const
+ {
+ return 10;
+ }
+ bool
+ UseGlobalProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 2 && pp[0] == "profiles" && pp[1] == "use.desc");
+ }
- void
- UseGlobalProcessor::modified(
- DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
- {
- DB::TablePatch p;
- p.dest = "gentoobrowse.use_global";
- p.src = Utils::Database::emptyClone(dbc, p.dest);
- p.pk = {"use"};
- p.cols = {"use", "description"};
+ void
+ UseGlobalProcessor::created(
+ DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
+ {
+ modified(dbc, r, fn, path);
+ }
- AdHoc::FileUtils::MemMap u(path);
- Glib::ustring d(std::string(u.sv()));
- Glib::MatchInfo matches;
- auto i = Utils::Database::tablePatchInserter(dbc, p);
- for (useDesc->match(d, matches); matches.get_match_count() == 3; matches.next()) {
- i->bindParamS(0, matches.fetch(2));
- i->bindParamS(1, matches.fetch(1));
- i->execute();
- }
- dbc->patchTable(&p);
+ void
+ UseGlobalProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
+ {
+ DB::TablePatch p;
+ p.dest = "gentoobrowse.use_global";
+ p.src = Utils::Database::emptyClone(dbc, p.dest);
+ p.pk = {"use"};
+ p.cols = {"use", "description"};
- Utils::Database::drop(dbc, p.src);
+ AdHoc::FileUtils::MemMap u(path);
+ Glib::ustring d(std::string(u.sv()));
+ Glib::MatchInfo matches;
+ auto i = Utils::Database::tablePatchInserter(dbc, p);
+ for (useDesc->match(d, matches); matches.get_match_count() == 3; matches.next()) {
+ i->bindParamS(0, matches.fetch(2));
+ i->bindParamS(1, matches.fetch(1));
+ i->execute();
}
+ dbc->patchTable(&p);
- void
- UseGlobalProcessor::deleted(DB::Connection * dbc, int64_t, const StringList &)
- {
- dbc->modify("DELETE FROM gentoobrowse.use_global")->execute();
- }
+ Utils::Database::drop(dbc, p.src);
+ }
+
+ void
+ UseGlobalProcessor::deleted(DB::Connection * dbc, int64_t, const StringList &)
+ {
+ dbc->modify("DELETE FROM gentoobrowse.use_global")->execute();
}
}
FACTORY(Gentoo::Service::UseGlobalProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/useGlobalProcessor.h b/gentoobrowse-api/service/maintenance/useGlobalProcessor.h
index a7fdc78..4577ac2 100644
--- a/gentoobrowse-api/service/maintenance/useGlobalProcessor.h
+++ b/gentoobrowse-api/service/maintenance/useGlobalProcessor.h
@@ -1,26 +1,21 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_USEGLOBALPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_USEGLOBALPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
#include <filesystem>
#include <modifycommand.h>
-namespace Gentoo {
- namespace Service {
- class UseGlobalProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class UseGlobalProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- };
- }
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp b/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp
index d42f740..205788a 100644
--- a/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp
@@ -13,88 +13,84 @@
namespace U = Gentoo::Utils;
-static Glib::RefPtr<Glib::Regex> useDesc
- = Glib::Regex::create("^([^#\\s][^ ]*)\\s+-\\s+(.*)$", Glib::RegexCompileFlags::REGEX_MULTILINE);
+namespace Gentoo::Service {
+ static Glib::RefPtr<Glib::Regex> useDesc
+ = Glib::Regex::create(R"(^([^#\s][^ ]*)\s+-\s+(.*)$)", Glib::RegexCompileFlags::REGEX_MULTILINE);
-namespace Gentoo {
- namespace Service {
- unsigned char
- UseGroupProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- UseGroupProcessor::order() const
- {
- return 10;
- }
- bool
- UseGroupProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 3 && pp[0] == "profiles" && pp[1] == "desc"
- && boost::algorithm::ends_with(pp[2], ".desc"));
- }
+ unsigned char
+ UseGroupProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ UseGroupProcessor::order() const
+ {
+ return 10;
+ }
+ bool
+ UseGroupProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 3 && pp[0] == "profiles" && pp[1] == "desc"
+ && boost::algorithm::ends_with(pp[2], ".desc"));
+ }
- void
- UseGroupProcessor::created(
- DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
- {
- auto m = sql::maintenance::useGroupsInsert.select(dbc);
- m->bindParamS(0, path.stem().string());
- m->forEachRow<int64_t>([this, dbc, &path](auto useGroupId) {
- this->mergeContent(dbc, path, useGroupId);
- });
- }
+ void
+ UseGroupProcessor::created(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
+ {
+ auto m = sql::maintenance::useGroupsInsert.select(dbc);
+ m->bindParamS(0, path.stem().string());
+ m->forEachRow<int64_t>([this, dbc, &path](auto useGroupId) {
+ this->mergeContent(dbc, path, useGroupId);
+ });
+ }
- void
- UseGroupProcessor::modified(
- DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
- {
- auto m = sql::maintenance::useGroupsGetId.select(dbc);
- m->bindParamS(0, path.stem().string());
- m->forEachRow<int64_t>([this, dbc, &path](auto useGroupId) {
- this->mergeContent(dbc, path, useGroupId);
- });
- }
+ void
+ UseGroupProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
+ {
+ auto m = sql::maintenance::useGroupsGetId.select(dbc);
+ m->bindParamS(0, path.stem().string());
+ m->forEachRow<int64_t>([this, dbc, &path](auto useGroupId) {
+ this->mergeContent(dbc, path, useGroupId);
+ });
+ }
- void
- UseGroupProcessor::mergeContent(DB::Connection * dbc, const std::filesystem::path & path, int64_t useGroupId)
- {
- DB::TablePatch p;
- p.dest = "gentoobrowse.use_group";
- U::EntityWhereFilter<int64_t> gwf("useGroupId", useGroupId);
- p.src = Utils::Database::emptyClone(dbc, "gentoobrowse.use_group");
- p.pk = {"useGroupId", "use"};
- p.cols = {"useGroupId", "use", "description"};
- p.where = &gwf;
+ void
+ UseGroupProcessor::mergeContent(DB::Connection * dbc, const std::filesystem::path & path, int64_t useGroupId)
+ {
+ DB::TablePatch p;
+ p.dest = "gentoobrowse.use_group";
+ U::EntityWhereFilter<int64_t> gwf("useGroupId", useGroupId);
+ p.src = Utils::Database::emptyClone(dbc, "gentoobrowse.use_group");
+ p.pk = {"useGroupId", "use"};
+ p.cols = {"useGroupId", "use", "description"};
+ p.where = &gwf;
- AdHoc::FileUtils::MemMap u(path);
- Glib::ustring d(std::string(u.sv()));
- Glib::MatchInfo matches;
- auto i = Utils::Database::tablePatchInserter(dbc, p);
- i->bindParamI(2, useGroupId);
- // Dirty, but dupes exist
- std::set<std::string> uses;
- for (useDesc->match(d, matches); matches.get_match_count() == 3; matches.next()) {
- if (uses.find(matches.fetch(1)) == uses.end()) {
- i->bindParamS(1, matches.fetch(1));
- i->bindParamS(0, matches.fetch(2));
- i->execute();
- uses.insert(matches.fetch(1));
- }
+ AdHoc::FileUtils::MemMap u(path);
+ Glib::ustring d(std::string(u.sv()));
+ Glib::MatchInfo matches;
+ auto i = Utils::Database::tablePatchInserter(dbc, p);
+ i->bindParamI(2, useGroupId);
+ // Dirty, but dupes exist
+ std::set<std::string> uses;
+ for (useDesc->match(d, matches); matches.get_match_count() == 3; matches.next()) {
+ if (uses.find(matches.fetch(1)) == uses.end()) {
+ i->bindParamS(1, matches.fetch(1));
+ i->bindParamS(0, matches.fetch(2));
+ i->execute();
+ uses.insert(matches.fetch(1));
}
- dbc->patchTable(&p);
-
- Utils::Database::drop(dbc, p.src);
}
+ dbc->patchTable(&p);
- void
- UseGroupProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
- {
- auto m = sql::maintenance::useGroupsDelete.modify(dbc);
- m->bindParamS(0, fn.back().substr(0, fn.back().find('.')));
- m->execute();
- }
+ Utils::Database::drop(dbc, p.src);
+ }
+
+ void
+ UseGroupProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn)
+ {
+ auto m = sql::maintenance::useGroupsDelete.modify(dbc);
+ m->bindParamS(0, fn.back().substr(0, fn.back().find('.')));
+ m->execute();
}
}
FACTORY(Gentoo::Service::UseGroupProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/useGroupProcessor.h b/gentoobrowse-api/service/maintenance/useGroupProcessor.h
index 29b1bb1..71ec083 100644
--- a/gentoobrowse-api/service/maintenance/useGroupProcessor.h
+++ b/gentoobrowse-api/service/maintenance/useGroupProcessor.h
@@ -1,29 +1,24 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_USEGROUPPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_USEGROUPPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
#include <filesystem>
#include <modifycommand.h>
-namespace Gentoo {
- namespace Service {
- class UseGroupProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class UseGroupProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- private:
- void mergeContent(DB::Connection *, const std::filesystem::path &, int64_t id);
- };
- }
+ private:
+ void mergeContent(DB::Connection *, const std::filesystem::path &, int64_t id);
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenance/useLocalProcessor.cpp b/gentoobrowse-api/service/maintenance/useLocalProcessor.cpp
index 2379410..8ea53c5 100644
--- a/gentoobrowse-api/service/maintenance/useLocalProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/useLocalProcessor.cpp
@@ -9,68 +9,65 @@
using namespace AdHoc::FileUtils;
-static Glib::RefPtr<Glib::Regex> useDesc = Glib::Regex::create(
- "^([^#\\s][^/]*)/([^:]+):([^ ]+)\\s+-\\s+(.*)$", Glib::RegexCompileFlags::REGEX_MULTILINE);
+namespace Gentoo::Service {
+ static Glib::RefPtr<Glib::Regex> useDesc = Glib::Regex::create(
+ R"(^([^#\s][^/]*)/([^:]+):([^ ]+)\s+-\s+(.*)$)", Glib::RegexCompileFlags::REGEX_MULTILINE);
-namespace Gentoo {
- namespace Service {
- unsigned char
- UseLocalProcessor::phase() const
- {
- return 2;
- }
- unsigned char
- UseLocalProcessor::order() const
- {
- return 10;
- }
- bool
- UseLocalProcessor::match(const PathParts & pp) const
- {
- return (pp.size() == 2 && pp[0] == "profiles" && pp[1] == "use.local.desc");
- }
-
- void
- UseLocalProcessor::created(
- DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
- {
- modified(dbc, r, fn, path);
- }
+ unsigned char
+ UseLocalProcessor::phase() const
+ {
+ return 2;
+ }
+ unsigned char
+ UseLocalProcessor::order() const
+ {
+ return 10;
+ }
+ bool
+ UseLocalProcessor::match(const PathParts & pp) const
+ {
+ return (pp.size() == 2 && pp[0] == "profiles" && pp[1] == "use.local.desc");
+ }
- void
- UseLocalProcessor::modified(
- DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
- {
- DB::TablePatch p;
- auto tempTable = Utils::Database::namedTemp(dbc, "tmp_uselocalraw",
- {{"category", "text"}, {"package", "text"}, {"use", "text"}, {"description", "text"}});
- p.dest = "gentoobrowse.use_local";
- DB::StaticSqlWriter srcExpr(sql::maintenance::useLocalMap.getSql());
- p.srcExpr = &srcExpr;
- p.pk = {"packageId", "use"};
- p.cols = {"packageId", "use", "description"};
+ void
+ UseLocalProcessor::created(
+ DB::Connection * dbc, int64_t r, const StringList & fn, const std::filesystem::path & path)
+ {
+ modified(dbc, r, fn, path);
+ }
- AdHoc::FileUtils::MemMap u(path);
- Glib::ustring d(std::string(u.sv()));
- Glib::MatchInfo matches;
- auto i = tempTable.second;
- for (useDesc->match(d, matches); matches.get_match_count() == 5; matches.next()) {
- i->bindParamS(0, matches.fetch(1));
- i->bindParamS(1, matches.fetch(4));
- i->bindParamS(2, matches.fetch(2));
- i->bindParamS(3, matches.fetch(3));
- i->execute();
- }
- dbc->patchTable(&p);
+ void
+ UseLocalProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const std::filesystem::path & path)
+ {
+ DB::TablePatch p;
+ auto tempTable = Utils::Database::namedTemp(dbc, "tmp_uselocalraw",
+ {{"category", "text"}, {"package", "text"}, {"use", "text"}, {"description", "text"}});
+ p.dest = "gentoobrowse.use_local";
+ DB::StaticSqlWriter srcExpr(sql::maintenance::useLocalMap.getSql());
+ p.srcExpr = &srcExpr;
+ p.pk = {"packageId", "use"};
+ p.cols = {"packageId", "use", "description"};
- Utils::Database::drop(dbc, tempTable.first);
+ AdHoc::FileUtils::MemMap u(path);
+ Glib::ustring d(std::string(u.sv()));
+ Glib::MatchInfo matches;
+ auto i = tempTable.second;
+ for (useDesc->match(d, matches); matches.get_match_count() == 5; matches.next()) {
+ i->bindParamS(0, matches.fetch(1));
+ i->bindParamS(1, matches.fetch(4));
+ i->bindParamS(2, matches.fetch(2));
+ i->bindParamS(3, matches.fetch(3));
+ i->execute();
}
+ dbc->patchTable(&p);
- void
- UseLocalProcessor::deleted(DB::Connection * dbc, int64_t, const StringList &)
- {
- dbc->modify("DELETE FROM gentoobrowse.use_local")->execute();
- }
+ Utils::Database::drop(dbc, tempTable.first);
+ }
+
+ void
+ UseLocalProcessor::deleted(DB::Connection * dbc, int64_t, const StringList &)
+ {
+ dbc->modify("DELETE FROM gentoobrowse.use_local")->execute();
}
}
FACTORY(Gentoo::Service::UseLocalProcessor, Gentoo::Service::FileProcessorFactory);
diff --git a/gentoobrowse-api/service/maintenance/useLocalProcessor.h b/gentoobrowse-api/service/maintenance/useLocalProcessor.h
index b2077bc..9f808da 100644
--- a/gentoobrowse-api/service/maintenance/useLocalProcessor.h
+++ b/gentoobrowse-api/service/maintenance/useLocalProcessor.h
@@ -1,26 +1,21 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_USELOCALPROC_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_USELOCALPROC_H
+#pragma once
#include "abstractFileProcessor.h"
#include <connection.h>
#include <filesystem>
#include <modifycommand.h>
-namespace Gentoo {
- namespace Service {
- class UseLocalProcessor : public AbstractFileProcessor {
- public:
- unsigned char phase() const override;
- unsigned char order() const override;
- bool match(const PathParts & pp) const override;
+namespace Gentoo::Service {
+ class UseLocalProcessor : public AbstractFileProcessor {
+ public:
+ unsigned char phase() const override;
+ unsigned char order() const override;
+ bool match(const PathParts & pp) const override;
- void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
- const std::filesystem::path & path) override;
- void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
- };
- }
+ void created(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn,
+ const std::filesystem::path & path) override;
+ void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) override;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/maintenanceBugs.cpp b/gentoobrowse-api/service/maintenanceBugs.cpp
index ededc29..5023578 100644
--- a/gentoobrowse-api/service/maintenanceBugs.cpp
+++ b/gentoobrowse-api/service/maintenanceBugs.cpp
@@ -12,103 +12,100 @@
#include <tablepatch.h>
#include <utils/dbUtils.h>
-namespace Gentoo {
- namespace Service {
- AdHoc::Lexer::PatternPtr bugLink = AdHoc::LexerMatchers::regex(
- R"R(Bug:(\d+) - "" status:(\w*) resolution:(\w*) severity:(\w*).*)R", G_REGEX_OPTIMIZE);
+namespace Gentoo::Service {
+ AdHoc::Lexer::PatternPtr bugLink = AdHoc::LexerMatchers::regex(
+ R"R(Bug:(\d+) - "" status:(\w*) resolution:(\w*) severity:(\w*).*)R", G_REGEX_OPTIMIZE);
- class BugListParser : public xmlpp::SaxParser, AdHoc::Lexer {
- public:
- BugListParser(DB::ModifyCommandPtr i) : ins(i)
- {
- rules.push_back({{InitialState}, bugLink, [this](auto es) {
- ins->bindParamI(0, boost::lexical_cast<int64_t>(*es->pattern()->match(1)));
- ins->bindParamS(2, *es->pattern()->match(2));
- ins->bindParamS(1, *es->pattern()->match(4));
- }});
- }
+ class BugListParser : public xmlpp::SaxParser, AdHoc::Lexer {
+ public:
+ explicit BugListParser(DB::ModifyCommandPtr i) : ins(std::move(i))
+ {
+ rules.push_back({{InitialState}, bugLink, [this](auto es) {
+ ins->bindParamI(0, boost::lexical_cast<int64_t>(*es->pattern()->match(1)));
+ ins->bindParamS(2, *es->pattern()->match(2));
+ ins->bindParamS(1, *es->pattern()->match(4));
+ }});
+ }
- protected:
- void
- on_start_element(const Glib::ustring & e, const xmlpp::SaxParser::AttributeList &) override
- {
- stk.push(e);
- }
+ protected:
+ void
+ on_start_element(const Glib::ustring & e, const xmlpp::SaxParser::AttributeList &) override
+ {
+ stk.push(e);
+ }
- void
- on_characters(const Glib::ustring & t) override
- {
- if (stk.top() == "a") {
- attributes += t;
- }
- else if (stk.top() == "em") {
- summary += t;
- }
+ void
+ on_characters(const Glib::ustring & t) override
+ {
+ if (stk.top() == "a") {
+ attributes += t;
}
+ else if (stk.top() == "em") {
+ summary += t;
+ }
+ }
- void
- on_end_element(const Glib::ustring & e) override
- {
- stk.pop();
- if (e == "li") {
- extract(attributes.c_str(), attributes.length());
- ins->bindParamS(3, summary);
- ins->execute();
- attributes.clear();
- summary.clear();
- }
+ void
+ on_end_element(const Glib::ustring & e) override
+ {
+ stk.pop();
+ if (e == "li") {
+ extract(attributes.c_str(), attributes.length());
+ ins->bindParamS(3, summary);
+ ins->execute();
+ attributes.clear();
+ summary.clear();
}
+ }
- private:
- DB::ModifyCommandPtr ins;
- std::stack<Glib::ustring> stk;
+ private:
+ DB::ModifyCommandPtr ins;
+ std::stack<Glib::ustring> stk;
- Glib::ustring attributes;
- Glib::ustring summary;
- };
+ Glib::ustring attributes;
+ Glib::ustring summary;
+ };
- AdHocFormatter(UpdatingBugs, "Refreshing bug list from %?");
- AdHocFormatter(UpdatingBugUrl, " ... %?");
- AdHocFormatter(UpdatingBugsResult, "Refreshed bug list: %? added, %? updated, %? removed");
- constexpr const std::string_view NagiosServiceName("GB API Bug Updates");
- void
- Maintenance::refreshBugs(const Ice::Current & c)
- {
- try {
- auto log = LOGMANAGER()->getLogger(__FUNCTION__);
- std::filesystem::path root = properties(c)->getPropertyWithDefault(
- "GentooBrowseAPI.BugRoot", "https://bugs.gentoo.org/data/cached");
+ AdHocFormatter(UpdatingBugs, "Refreshing bug list from %?");
+ AdHocFormatter(UpdatingBugUrl, " ... %?");
+ AdHocFormatter(UpdatingBugsResult, "Refreshed bug list: %? added, %? updated, %? removed");
+ constexpr const std::string_view NagiosServiceName("GB API Bug Updates");
+ void
+ Maintenance::refreshBugs(const Ice::Current & c)
+ {
+ try {
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ std::filesystem::path root = properties(c)->getPropertyWithDefault(
+ "GentooBrowseAPI.BugRoot", "https://bugs.gentoo.org/data/cached");
- log->messagectf<UpdatingBugs>(IceTray::Logging::LogLevel::INFO, root);
- auto dbc = db->get();
- DB::TransactionScope tx(*dbc.get());
- DB::TablePatch tp;
- tp.pk = {"bugId"};
- tp.cols = {"bugId", "severity", "status", "summary"};
- tp.dest = "gentoobrowse.bugs";
- tp.src = Utils::Database::emptyClone(dbc.get(), "gentoobrowse.bugs");
- auto ins = Utils::Database::tablePatchInserter(dbc.get(), tp);
- BugListParser blp(ins);
- for (const auto & bl :
- {"buglist-CONFIRMED.html", "buglist-UNCONFIRMED.html", "buglist-IN_PROGRESS.html"}) {
- log->messagectf<UpdatingBugUrl>(IceTray::Logging::LogLevel::DEBUG, bl);
- AdHoc::Net::CurlStreamSource css(root / bl);
- css.setopt(CURLOPT_ENCODING, "deflate, gzip");
- css.setopt(CURLOPT_TIMEOUT, 20L);
- AdHoc::Net::CurlStream cs(css);
- blp.parse_stream(cs);
- }
- auto result = dbc->patchTable(&tp);
- Utils::Database::drop(dbc.get(), tp.src);
- log->messagectf<UpdatingBugsResult>(
- IceTray::Logging::LogLevel::INFO, result.inserts, result.updates, result.deletes);
- AdHoc::submitNagiosPassiveServiceCheck(NagiosServiceName, AdHoc::NagiosStatusCode::OK,
- UpdatingBugsResult::get(result.inserts, result.updates, result.deletes));
- }
- catch (const std::exception & ex) {
- AdHoc::submitNagiosPassiveServiceCheck(NagiosServiceName, AdHoc::NagiosStatusCode::Warning, ex.what());
- throw;
+ log->messagectf<UpdatingBugs>(IceTray::Logging::LogLevel::INFO, root);
+ auto dbc = db->get();
+ DB::TransactionScope tx(*dbc.get());
+ DB::TablePatch tp;
+ tp.pk = {"bugId"};
+ tp.cols = {"bugId", "severity", "status", "summary"};
+ tp.dest = "gentoobrowse.bugs";
+ tp.src = Utils::Database::emptyClone(dbc.get(), "gentoobrowse.bugs");
+ auto ins = Utils::Database::tablePatchInserter(dbc.get(), tp);
+ BugListParser blp(ins);
+ for (const auto & bl : {"buglist-CONFIRMED.html", "buglist-UNCONFIRMED.html", "buglist-IN_PROGRESS.html"}) {
+ log->messagectf<UpdatingBugUrl>(IceTray::Logging::LogLevel::DEBUG, bl);
+ AdHoc::Net::CurlStreamSource css(root / bl);
+ css.setopt(CURLOPT_ENCODING, "deflate, gzip");
+ css.setopt(CURLOPT_TIMEOUT, 20L);
+ AdHoc::Net::CurlStream cs(css);
+ blp.parse_stream(cs);
}
+ auto result = dbc->patchTable(&tp);
+ Utils::Database::drop(dbc.get(), tp.src);
+ log->messagectf<UpdatingBugsResult>(
+ IceTray::Logging::LogLevel::INFO, result.inserts, result.updates, result.deletes);
+ AdHoc::submitNagiosPassiveServiceCheck(NagiosServiceName, AdHoc::NagiosStatusCode::OK,
+ UpdatingBugsResult::get(result.inserts, result.updates, result.deletes));
+ }
+ catch (const std::exception & ex) {
+ AdHoc::submitNagiosPassiveServiceCheck(NagiosServiceName, AdHoc::NagiosStatusCode::Warning, ex.what());
+ throw;
}
}
}
diff --git a/gentoobrowse-api/service/maintenanceCommon.cpp b/gentoobrowse-api/service/maintenanceCommon.cpp
index 77f77ae..e225848 100644
--- a/gentoobrowse-api/service/maintenanceCommon.cpp
+++ b/gentoobrowse-api/service/maintenanceCommon.cpp
@@ -8,122 +8,119 @@
#include <safeMapFind.h>
#include <users.h>
-namespace Gentoo {
- namespace Service {
- class BaseScheduledTask : public IceUtil::TimerTask {
- public:
- BaseScheduledTask(Ice::CommunicatorPtr i) : ic(i) { }
+namespace Gentoo::Service {
+ class BaseScheduledTask : public IceUtil::TimerTask {
+ public:
+ explicit BaseScheduledTask(Ice::CommunicatorPtr i) : ic(std::move(i)) { }
- private:
- Ice::CommunicatorPtr ic;
- };
+ private:
+ Ice::CommunicatorPtr ic;
+ };
- class AutoUpdatePackages : public BaseScheduledTask {
- public:
- AutoUpdatePackages(Ice::CommunicatorPtr i) : BaseScheduledTask(i) { }
+ class AutoUpdatePackages : public BaseScheduledTask {
+ public:
+ explicit AutoUpdatePackages(Ice::CommunicatorPtr i) : BaseScheduledTask(std::move(i)) { }
- void
- runTimerTask() override
- {
- auto m = IceTray::Cube::get<Maintenance>();
- auto rb = m->refreshBugsAsync();
- m->updateRepositories();
- m->refreshPackageTree();
- m->sendNotifications();
- rb.get();
- }
- };
-
- class UserMaintenance : public BaseScheduledTask {
- public:
- UserMaintenance(Ice::CommunicatorPtr i) : BaseScheduledTask(i) { }
+ void
+ runTimerTask() override
+ {
+ auto m = IceTray::Cube::get<Maintenance>();
+ auto rb = m->refreshBugsAsync();
+ m->updateRepositories();
+ m->refreshPackageTree();
+ m->sendNotifications();
+ rb.get();
+ }
+ };
- void
- runTimerTask() override
- {
- auto u = IceTray::Cube::get<Users>();
- u->prune();
- }
- };
+ class UserMaintenance : public BaseScheduledTask {
+ public:
+ explicit UserMaintenance(Ice::CommunicatorPtr i) : BaseScheduledTask(std::move(i)) { }
- Maintenance::Maintenance(
- const DB::ConnectionPoolPtr & d, const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p) :
- Maintenance::Maintenance(d)
+ void
+ runTimerTask() override
{
- addTask<AutoUpdatePackages>(ic, p, "SyncTime");
- addTask<UserMaintenance>(ic, p, "UserMaintenanceTime");
+ auto u = IceTray::Cube::get<Users>();
+ u->prune();
}
+ };
- Maintenance::Maintenance(const DB::ConnectionPoolPtr & d) : IceTray::AbstractDatabaseClient(d) { }
+ Maintenance::Maintenance(DB::ConnectionPoolPtr d, const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p) :
+ Maintenance::Maintenance(std::move(d))
+ {
+ addTask<AutoUpdatePackages>(ic, p, "SyncTime");
+ addTask<UserMaintenance>(ic, p, "UserMaintenanceTime");
+ }
- Maintenance::~Maintenance()
- {
- if (taskRunner) {
- taskRunner->destroy();
- }
+ Maintenance::Maintenance(DB::ConnectionPoolPtr d) : IceTray::AbstractDatabaseClient(std::move(d)) { }
+
+ Maintenance::~Maintenance()
+ {
+ if (taskRunner) {
+ taskRunner->destroy();
}
+ }
- template<typename Task>
- void
- Maintenance::addTask(Ice::CommunicatorPtr ic, Ice::PropertiesPtr p, const std::string & whenCfg)
- {
- if (auto sync = p->getPropertyAsIntWithDefault("GentooBrowseAPI." + whenCfg, 0) * 60) {
- if (!taskRunner) {
- taskRunner = new IceUtil::Timer();
- }
- taskRunner->scheduleRepeated(std::make_shared<Task>(ic), IceUtil::Time::seconds(sync));
+ template<typename Task>
+ void
+ Maintenance::addTask(const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p, const std::string & whenCfg)
+ {
+ if (auto sync = p->getPropertyAsIntWithDefault("GentooBrowseAPI." + whenCfg, 0) * 60) {
+ if (!taskRunner) {
+ taskRunner = new IceUtil::Timer();
}
+ taskRunner->scheduleRepeated(std::make_shared<Task>(ic), IceUtil::Time::seconds(sync));
}
+ }
- Ice::PropertiesPtr
- Maintenance::properties(const Ice::Current & c)
- {
- return c.adapter->getCommunicator()->getProperties();
- }
+ Ice::PropertiesPtr
+ Maintenance::properties(const Ice::Current & c)
+ {
+ return c.adapter->getCommunicator()->getProperties();
+ }
- Gentoo::UserNews
- Maintenance::getUserNews(const Ice::Current &)
- {
- auto portage = IceTray::Cube::get<Portage>();
- portage->ice_ping();
- auto categories = portage->getAllCategories();
+ Gentoo::UserNews
+ Maintenance::getUserNews(const Ice::Current &)
+ {
+ auto portage = IceTray::Cube::get<Portage>();
+ portage->ice_ping();
+ auto categories = portage->getAllCategories();
- UserNews un;
- auto t = fetch<NewsContentTriggers>(sql::maintenance::getNotificationEbuildLists);
- std::transform(t.begin(), t.end(), std::inserter(un, un.end()),
- [&categories, &portage](const NewsContentTriggers::value_type & t) {
- NewsContent nc;
- std::copy_if(categories.begin(), categories.end(), std::back_inserter(nc.categories),
- [&t](const Gentoo::CategoryPtr & c) {
- return AdHoc::containerContains(t.categoryids, c->categoryid);
+ UserNews un;
+ auto t = fetch<NewsContentTriggers>(sql::maintenance::getNotificationEbuildLists);
+ std::transform(t.begin(), t.end(), std::inserter(un, un.end()),
+ [&categories, &portage](const NewsContentTriggers::value_type & t) {
+ NewsContent nc;
+ std::copy_if(categories.begin(), categories.end(), std::back_inserter(nc.categories),
+ [&t](const Gentoo::CategoryPtr & c) {
+ return AdHoc::containerContains(t.categoryids, c->categoryid);
+ });
+ for (auto pid : t.packageids) {
+ nc.packages.emplace_back(portage->getPackage(pid));
+ auto vs = portage->getPackageVersions(pid);
+ std::copy_if(vs.begin(), vs.end(), std::back_inserter(nc.ebuilds),
+ [&t](const Gentoo::EbuildPtr & v) {
+ return AdHoc::containerContains(t.ebuildids, v->ebuildid);
});
- for (auto pid : t.packageids) {
- nc.packages.emplace_back(portage->getPackage(pid));
- auto vs = portage->getPackageVersions(pid);
- std::copy_if(vs.begin(), vs.end(), std::back_inserter(nc.ebuilds),
- [&t](const Gentoo::EbuildPtr & v) {
- return AdHoc::containerContains(t.ebuildids, v->ebuildid);
- });
- }
- return UserNews::value_type(t.userid, nc);
- });
- return un;
- }
+ }
+ return UserNews::value_type(t.userid, nc);
+ });
+ return un;
+ }
- void
- Maintenance::sendNotifications(const Ice::Current & current)
- {
- auto notifications = IceTray::Cube::get<Notifications>();
- auto mailServer = IceTray::Cube::get<IceTray::Mail::MailServer>();
- auto users = IceTray::Cube::get<Users>();
- users->ice_ping();
+ void
+ Maintenance::sendNotifications(const Ice::Current & current)
+ {
+ auto notifications = IceTray::Cube::get<Notifications>();
+ auto mailServer = IceTray::Cube::get<IceTray::Mail::MailServer>();
+ auto users = IceTray::Cube::get<Users>();
+ users->ice_ping();
- for (const auto & trigger : getUserNews(current)) {
- auto user = users->get(trigger.first);
- auto email = notifications->getNews(user, trigger.second);
- mailServer->sendEmail(email);
- users->mailshotsent(user->userid);
- }
+ for (const auto & trigger : getUserNews(current)) {
+ auto user = users->get(trigger.first);
+ auto email = notifications->getNews(user, trigger.second);
+ mailServer->sendEmail(email);
+ users->mailshotsent(user->userid);
}
}
}
diff --git a/gentoobrowse-api/service/maintenanceGitOperations.cpp b/gentoobrowse-api/service/maintenanceGitOperations.cpp
index 28940da..ade5c9a 100644
--- a/gentoobrowse-api/service/maintenanceGitOperations.cpp
+++ b/gentoobrowse-api/service/maintenanceGitOperations.cpp
@@ -17,235 +17,236 @@
#include <systemd/sd-daemon.h>
#include <utils/dbUtils.h>
-namespace Gentoo {
- namespace Service {
- using namespace Utils::Git;
- namespace pl = std::placeholders;
-
- typedef std::set<std::string> StringSet;
-
- static int
- onFile(const git_diff_delta * delta, void * fileset)
- {
- static_cast<StringSet *>(fileset)->insert(delta->old_file.path);
- static_cast<StringSet *>(fileset)->insert(delta->new_file.path);
- return 0;
- }
+namespace Gentoo::Service {
+ using namespace Utils::Git;
+ using StringSet = std::set<std::string>;
+
+ static int
+ onFile(const git_diff_delta * delta, void * fileset)
+ {
+ static_cast<StringSet *>(fileset)->insert(delta->old_file.path);
+ static_cast<StringSet *>(fileset)->insert(delta->new_file.path);
+ return 0;
+ }
- template<typename T>
- static int
- onFile(const git_diff_delta * delta, T, void * fileset)
- {
- return onFile(delta, fileset);
- }
+ template<typename T>
+ static int
+ onFile(const git_diff_delta * delta, T, void * fileset)
+ {
+ return onFile(delta, fileset);
+ }
- AdHocFormatter(UpdatingChangeLog, "Updating change log for repository %? with range %?...%?");
- AdHocFormatter(UpdatedChangeLog, "Updated change log for repository %?, added %? new entries");
- static void
- writeChangeLog(DB::Connection * db, int64_t repoId, git_repository * repo, const git_oid & lastCommitOid,
- const git_oid & headCommitOid)
- {
- auto log = LOGMANAGER()->getLogger(__FUNCTION__);
- log->messagectf<UpdatingChangeLog>(IceTray::Logging::LogLevel::INFO, repoId, lastCommitOid, headCommitOid);
- auto cli = sql::maintenance::changeLogInsert.modify(db);
- cli->bindParamI(0, repoId);
- // Set up walker
- auto walker = gitSafeGet(git_revwalk_new, git_revwalk_free, repo);
- gitSafe(git_revwalk_push, walker.get(), &headCommitOid);
- gitSafe(git_revwalk_hide, walker.get(), &lastCommitOid);
-
- git_oid oid;
- unsigned int count = 0;
- // Walk through revisions
- while (!git_revwalk_next(&oid, walker.get())) {
- // Get commit
- auto commit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &oid);
-
- // Get commit's tree
- auto currentTree = gitSafeGet(git_commit_tree, git_tree_free, commit.get());
-
- // Collect all files change in commit from all parents
- std::unique_ptr<git_tree, void (*)(git_tree *)> parentTree(nullptr, git_tree_free);
- if (git_commit_parentcount(commit.get()) > 0) {
- auto parentCommit = gitSafeGet(git_commit_parent, git_commit_free, commit.get(), 0U);
- // Get parent tree
- parentTree = gitSafeGet(git_commit_tree, git_tree_free, parentCommit.get());
- }
- // Get tree to tree diff
- auto diff = gitSafeGet(
- git_diff_tree_to_tree, git_diff_free, repo, currentTree.get(), parentTree.get(), nullptr);
- // Compare trees
- StringSet fs;
- gitSafe(git_diff_foreach, diff.get(), onFile<float>, onFile<const git_diff_binary *>, nullptr, nullptr,
- &fs);
-
- // Insert commit into DB
- auto sig = git_commit_author(commit.get());
- cli->bindParamS(1, *oid);
- cli->bindParamT(2, boost::posix_time::from_time_t(sig->when.time));
- cli->bindParamS(3, git_commit_summary(commit.get()));
- cli->bindParamS(4, git_commit_body(commit.get()));
- cli->bindParamS(5, sig->name);
- cli->bindParamS(6, sig->email);
- cli->bindParamS(7, Slicer::packPqArray(fs));
- count += cli->execute();
+ AdHocFormatter(UpdatingChangeLog, "Updating change log for repository %? with range %?...%?");
+ AdHocFormatter(UpdatedChangeLog, "Updated change log for repository %?, added %? new entries");
+ static void
+ writeChangeLog(DB::Connection * db, int64_t repoId, git_repository * repo, const git_oid & lastCommitOid,
+ const git_oid & headCommitOid)
+ {
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<UpdatingChangeLog>(IceTray::Logging::LogLevel::INFO, repoId, lastCommitOid, headCommitOid);
+ auto cli = sql::maintenance::changeLogInsert.modify(db);
+ cli->bindParamI(0, repoId);
+ // Set up walker
+ auto walker = gitSafeGet(git_revwalk_new, git_revwalk_free, repo);
+ gitSafe(git_revwalk_push, walker.get(), &headCommitOid);
+ gitSafe(git_revwalk_hide, walker.get(), &lastCommitOid);
+
+ git_oid oid;
+ unsigned int count = 0;
+ // Walk through revisions
+ while (!git_revwalk_next(&oid, walker.get())) {
+ // Get commit
+ auto commit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &oid);
+
+ // Get commit's tree
+ auto currentTree = gitSafeGet(git_commit_tree, git_tree_free, commit.get());
+
+ // Collect all files change in commit from all parents
+ std::unique_ptr<git_tree, void (*)(git_tree *)> parentTree(nullptr, git_tree_free);
+ if (git_commit_parentcount(commit.get()) > 0) {
+ auto parentCommit = gitSafeGet(git_commit_parent, git_commit_free, commit.get(), 0U);
+ // Get parent tree
+ parentTree = gitSafeGet(git_commit_tree, git_tree_free, parentCommit.get());
}
- log->messagectf<UpdatedChangeLog>(IceTray::Logging::LogLevel::INFO, repoId, count);
+ // Get tree to tree diff
+ auto diff = gitSafeGet(
+ git_diff_tree_to_tree, git_diff_free, repo, currentTree.get(), parentTree.get(), nullptr);
+ // Compare trees
+ StringSet fs;
+ gitSafe(git_diff_foreach, diff.get(), onFile<float>, onFile<const git_diff_binary *>, nullptr, nullptr,
+ &fs);
+
+ // Insert commit into DB
+ auto sig = git_commit_author(commit.get());
+ cli->bindParamS(1, *oid);
+ cli->bindParamT(2, boost::posix_time::from_time_t(sig->when.time));
+ cli->bindParamS(3, git_commit_summary(commit.get()));
+ cli->bindParamS(4, git_commit_body(commit.get()));
+ cli->bindParamS(5, sig->name);
+ cli->bindParamS(6, sig->email);
+ cli->bindParamS(7, Slicer::packPqArray(fs));
+ count += cli->execute();
}
+ log->messagectf<UpdatedChangeLog>(IceTray::Logging::LogLevel::INFO, repoId, count);
+ }
- void
- Maintenance::updateRepositories(const Ice::Current &)
- {
- for (auto & repo : fetch<Gentoo::Repositories>(sql::maintenance::reposToUpdate)) {
- updateRepository(repo.path, repo.upstream, repo.branch);
- }
+ void
+ Maintenance::updateRepositories(const Ice::Current &)
+ {
+ for (auto & repo : fetch<Gentoo::Repositories>(sql::maintenance::reposToUpdate)) {
+ updateRepository(repo.path, repo.upstream, repo.branch);
}
+ }
- static int
- insertFileChange(const git_diff_delta * delta, void * ptr)
- {
- auto cs = static_cast<ChangeSet *>(ptr);
- switch (delta->status) {
- case GIT_DELTA_ADDED:
- case GIT_DELTA_MODIFIED:
- case GIT_DELTA_DELETED: {
- std::filesystem::path path(delta->new_file.path);
- cs->insert({path, {{path.begin(), path.end()}, delta->status}});
- } break;
- default:
- throw GitError("Insert Git file changes", 0, 0, "Unexpected change status.");
- }
- return 0;
+ static int
+ insertFileChange(const git_diff_delta * delta, void * ptr)
+ {
+ auto cs = static_cast<ChangeSet *>(ptr);
+ switch (delta->status) {
+ case GIT_DELTA_ADDED:
+ case GIT_DELTA_MODIFIED:
+ case GIT_DELTA_DELETED: {
+ std::filesystem::path path(delta->new_file.path);
+ cs->insert({path, {{path.begin(), path.end()}, delta->status}});
+ } break;
+ default:
+ throw GitError("Insert Git file changes", 0, 0, "Unexpected change status.");
}
+ return 0;
+ }
- template<typename T>
- static int
- insertFileChangeT(const git_diff_delta * delta, T, void * ptr)
- {
- return insertFileChange(delta, ptr);
- }
+ template<typename T>
+ static int
+ insertFileChangeT(const git_diff_delta * delta, T, void * ptr)
+ {
+ return insertFileChange(delta, ptr);
+ }
- static ChangeSet writeChangesToFileList(
- int64_t repoId, git_repository * repo, const git_oid & last, const git_oid & head);
-
- ChangeSet
- refreshRepository(DB::Connection * db, Ice::PropertiesPtr properties, const Repository & repository)
- {
- auto targetRef = properties->getProperty("GentooBrowseAPI.RefreshTarget." + repository.name);
- auto repo = gitSafeGet(git_repository_open, git_repository_free, repository.path.c_str());
- auto lastCommitOid = gitSafeGet(git_oid_fromstr, repository.lastcommit.c_str());
- auto headCommitOid = targetRef.empty() ? gitSafeGet(git_reference_name_to_id, repo.get(), "HEAD")
- : gitSafeGet(git_oid_fromstr, targetRef.c_str());
- auto updateLastCommit = sql::maintenance::repoSetLastCommit.modify(db);
- updateLastCommit->bindParamS(0, *headCommitOid);
- updateLastCommit->bindParamI(1, repository.repoid);
- updateLastCommit->execute();
-
- writeChangeLog(db, repository.repoid, repo.get(), lastCommitOid, headCommitOid);
- return writeChangesToFileList(repository.repoid, repo.get(), lastCommitOid, headCommitOid);
- }
+ static ChangeSet writeChangesToFileList(
+ int64_t repoId, git_repository * repo, const git_oid & last, const git_oid & head);
+
+ ChangeSet
+ refreshRepository(DB::Connection * db, const Ice::PropertiesPtr & properties, const Repository & repository)
+ {
+ auto targetRef = properties->getProperty("GentooBrowseAPI.RefreshTarget." + repository.name);
+ auto repo = gitSafeGet(git_repository_open, git_repository_free, repository.path.c_str());
+ auto lastCommitOid = gitSafeGet(git_oid_fromstr, repository.lastcommit.c_str());
+ auto headCommitOid = targetRef.empty() ? gitSafeGet(git_reference_name_to_id, repo.get(), "HEAD")
+ : gitSafeGet(git_oid_fromstr, targetRef.c_str());
+ auto updateLastCommit = sql::maintenance::repoSetLastCommit.modify(db);
+ updateLastCommit->bindParamS(0, *headCommitOid);
+ updateLastCommit->bindParamI(1, repository.repoid);
+ updateLastCommit->execute();
+
+ writeChangeLog(db, repository.repoid, repo.get(), lastCommitOid, headCommitOid);
+ return writeChangesToFileList(repository.repoid, repo.get(), lastCommitOid, headCommitOid);
+ }
- AdHocFormatter(FindingChanges, "Finding changes for repository %? with range %?...%?");
- ChangeSet
- writeChangesToFileList(
- int64_t repoId, git_repository * repo, const git_oid & lastCommitOid, const git_oid & headCommitOid)
- {
- auto log = LOGMANAGER()->getLogger(__FUNCTION__);
- log->messagectf<FindingChanges>(IceTray::Logging::LogLevel::DEBUG, repoId, lastCommitOid, headCommitOid);
- auto lastCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &lastCommitOid);
- auto headCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &headCommitOid);
- auto lastTree = gitSafeGet(git_commit_tree, git_tree_free, lastCommit.get());
- auto headTree = gitSafeGet(git_commit_tree, git_tree_free, headCommit.get());
- auto diff = gitSafeGet(git_diff_tree_to_tree, git_diff_free, repo, lastTree.get(), headTree.get(), nullptr);
- ChangeSet changes;
- gitSafe(git_diff_foreach, diff.get(), insertFileChangeT<float>, insertFileChangeT<const git_diff_binary *>,
- nullptr, nullptr, &changes);
- return changes;
- }
+ AdHocFormatter(FindingChanges, "Finding changes for repository %? with range %?...%?");
+ ChangeSet
+ writeChangesToFileList(
+ int64_t repoId, git_repository * repo, const git_oid & lastCommitOid, const git_oid & headCommitOid)
+ {
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<FindingChanges>(IceTray::Logging::LogLevel::DEBUG, repoId, lastCommitOid, headCommitOid);
+ auto lastCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &lastCommitOid);
+ auto headCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &headCommitOid);
+ auto lastTree = gitSafeGet(git_commit_tree, git_tree_free, lastCommit.get());
+ auto headTree = gitSafeGet(git_commit_tree, git_tree_free, headCommit.get());
+ auto diff = gitSafeGet(git_diff_tree_to_tree, git_diff_free, repo, lastTree.get(), headTree.get(), nullptr);
+ ChangeSet changes;
+ gitSafe(git_diff_foreach, diff.get(), insertFileChangeT<float>, insertFileChangeT<const git_diff_binary *>,
+ nullptr, nullptr, &changes);
+ return changes;
+ }
- constexpr const std::string_view NagiosServiceName("GB API Package Updates");
- void
- Maintenance::refreshPackageTree(const Ice::Current & c)
- {
- try {
- auto properties = c.adapter->getCommunicator()->getProperties();
- auto repoRoot
- = std::filesystem::path(properties->getPropertyWithDefault("GentooBrowseAPI.RepoRoot", "/"));
- auto dbc = db->get();
- DB::TransactionScope tx(*dbc.get());
- for (const auto & repo : fetch<Gentoo::Repositories>(dbc.get(), sql::maintenance::reposToGitRefresh)) {
- auto changes = refreshRepository(dbc.get(), properties, repo);
- this->applyFileChanges(dbc.get(), repoRoot, repo, changes);
- }
- time_t now = time(nullptr);
- sd_notifyf(0, "STATUS=Last update %s", ctime(&now));
- AdHoc::submitNagiosPassiveServiceCheck(
- NagiosServiceName, AdHoc::NagiosStatusCode::OK, "Package tree(s) updated");
- }
- catch (const std::exception & ex) {
- AdHoc::submitNagiosPassiveServiceCheck(NagiosServiceName, AdHoc::NagiosStatusCode::Warning, ex.what());
- throw;
+ constexpr const std::string_view NagiosServiceName("GB API Package Updates");
+ void
+ Maintenance::refreshPackageTree(const Ice::Current & c)
+ {
+ try {
+ auto properties = c.adapter->getCommunicator()->getProperties();
+ auto repoRoot = std::filesystem::path(properties->getPropertyWithDefault("GentooBrowseAPI.RepoRoot", "/"));
+ auto dbc = db->get();
+ DB::TransactionScope tx(*dbc.get());
+ for (const auto & repo : fetch<Gentoo::Repositories>(dbc.get(), sql::maintenance::reposToGitRefresh)) {
+ auto changes = refreshRepository(dbc.get(), properties, repo);
+ this->applyFileChanges(dbc.get(), repoRoot, repo, changes);
}
+ time_t now = time(nullptr);
+ sd_notifyf(0, "STATUS=Last update %s", ctime(&now));
+ AdHoc::submitNagiosPassiveServiceCheck(
+ NagiosServiceName, AdHoc::NagiosStatusCode::OK, "Package tree(s) updated");
}
+ catch (const std::exception & ex) {
+ AdHoc::submitNagiosPassiveServiceCheck(NagiosServiceName, AdHoc::NagiosStatusCode::Warning, ex.what());
+ throw;
+ }
+ }
- AdHocFormatter(UpdatingFileContent, "Updating file content");
- AdHocFormatter(UpdatedFileContent, "Updated file content");
- void
- Maintenance::applyFileChanges(DB::Connection * dbc, const std::filesystem::path & repoRoot,
- const Repository & repo, ChangeSet & changes) const
- {
- auto log = LOGMANAGER()->getLogger(__FUNCTION__);
- log->messagectf<UpdatingFileContent>(IceTray::Logging::LogLevel::DEBUG);
- // Map of phase, to order, to processor
- std::map<unsigned char, std::multimap<unsigned char, FileProcessorPtr>> fps;
- for (const auto & fpf : AdHoc::PluginManager::getDefault()->getAll<FileProcessorFactory>()) {
- FileProcessorPtr processor(fpf->implementation()->create());
- fps[processor->phase()].insert({processor->order(), processor})->second->prepare(dbc);
- }
- // Processor -> repoId, PathParts, Path
- typedef std::function<void(
- FileProcessorPtr, int64_t, const Gentoo::StringList &, const std::filesystem::path &)>
- FileHandleFunc;
- std::map<git_delta_t, FileHandleFunc> funcs;
- funcs[GIT_DELTA_DELETED] = std::bind(&AbstractFileProcessor::deleted, pl::_1, dbc, pl::_2, pl::_3);
- funcs[GIT_DELTA_MODIFIED]
- = std::bind(&AbstractFileProcessor::modified, pl::_1, dbc, pl::_2, pl::_3, pl::_4);
- funcs[GIT_DELTA_ADDED] = std::bind(&AbstractFileProcessor::created, pl::_1, dbc, pl::_2, pl::_3, pl::_4);
-
- const auto repoPath = repoRoot / std::filesystem::path(repo.path).lexically_relative("/");
- // Phases
- for (const auto & phase : fps) {
- std::set<FileProcessorPtr> usedProcessors;
- // Processors
- for (const auto & processorOrder : phase.second) {
- auto processor = processorOrder.second;
- // Changes
- for (auto change = changes.begin(); change != changes.end();) {
- if (processor->match(change->second.pathParts)) {
- funcs[change->second.changeType](
- processor, repo.repoid, change->second.pathParts, repoPath / change->first);
- usedProcessors.insert(processor);
- change = changes.erase(change);
- }
- else {
- change++;
- }
+ AdHocFormatter(UpdatingFileContent, "Updating file content");
+ AdHocFormatter(UpdatedFileContent, "Updated file content");
+ void
+ Maintenance::applyFileChanges(DB::Connection * dbc, const std::filesystem::path & repoRoot, const Repository & repo,
+ ChangeSet & changes) const
+ {
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<UpdatingFileContent>(IceTray::Logging::LogLevel::DEBUG);
+ // Map of phase, to order, to processor
+ std::map<unsigned char, std::multimap<unsigned char, FileProcessorPtr>> fps;
+ for (const auto & fpf : AdHoc::PluginManager::getDefault()->getAll<FileProcessorFactory>()) {
+ FileProcessorPtr processor(fpf->implementation()->create());
+ fps[processor->phase()].insert({processor->order(), processor})->second->prepare(dbc);
+ }
+ // Processor -> repoId, PathParts, Path
+ using FileHandleFunc = std::function<void(
+ FileProcessorPtr, int64_t, const Gentoo::StringList &, const std::filesystem::path &)>;
+ std::map<git_delta_t, FileHandleFunc> funcs;
+ funcs[GIT_DELTA_DELETED] = [dbc](auto && fp, auto && repo, auto && pathParts, auto &&) {
+ fp->deleted(dbc, std::forward<decltype(repo)>(repo), std::forward<decltype(pathParts)>(pathParts));
+ };
+ funcs[GIT_DELTA_MODIFIED] = [dbc](auto && fp, auto && repo, auto && pathParts, auto && path) {
+ fp->modified(dbc, std::forward<decltype(repo)>(repo), std::forward<decltype(pathParts)>(pathParts),
+ std::forward<decltype(path)>(path));
+ };
+ funcs[GIT_DELTA_ADDED] = [dbc](auto && fp, auto && repo, auto && pathParts, auto && path) {
+ fp->created(dbc, std::forward<decltype(repo)>(repo), std::forward<decltype(pathParts)>(pathParts),
+ std::forward<decltype(path)>(path));
+ };
+
+ const auto repoPath = repoRoot / std::filesystem::path(repo.path).lexically_relative("/");
+ // Phases
+ for (const auto & phase : fps) {
+ std::set<FileProcessorPtr> usedProcessors;
+ // Processors
+ for (const auto & processorOrder : phase.second) {
+ auto processor = processorOrder.second;
+ // Changes
+ for (auto change = changes.begin(); change != changes.end();) {
+ if (processor->match(change->second.pathParts)) {
+ funcs[change->second.changeType](
+ processor, repo.repoid, change->second.pathParts, repoPath / change->first);
+ usedProcessors.insert(processor);
+ change = changes.erase(change);
+ }
+ else {
+ change++;
}
- }
- for (const auto & processor : usedProcessors) {
- processor->apply(dbc, changes);
- }
- for (const auto & processor : phase.second) {
- processor.second->phaseEnd(dbc, changes);
}
}
- for (const auto & phase : fps) {
- for (const auto & processor : phase.second) {
- processor.second->tidy(dbc);
- }
+ for (const auto & processor : usedProcessors) {
+ processor->apply(dbc, changes);
+ }
+ for (const auto & processor : phase.second) {
+ processor.second->phaseEnd(dbc, changes);
}
- log->messagectf<UpdatedFileContent>(IceTray::Logging::LogLevel::DEBUG);
}
-
+ for (const auto & phase : fps) {
+ for (const auto & processor : phase.second) {
+ processor.second->tidy(dbc);
+ }
+ }
+ log->messagectf<UpdatedFileContent>(IceTray::Logging::LogLevel::DEBUG);
}
+
}
diff --git a/gentoobrowse-api/service/maintenanceimpl.h b/gentoobrowse-api/service/maintenanceimpl.h
index bad2a76..7b04921 100644
--- a/gentoobrowse-api/service/maintenanceimpl.h
+++ b/gentoobrowse-api/service/maintenanceimpl.h
@@ -6,39 +6,38 @@
#include <Ice/Properties.h>
#include <IceUtil/Timer.h>
#include <abstractDatabaseClient.h>
+#include <c++11Helpers.h>
#include <converters.h>
#include <maintenance.h>
#include <map>
#include <visibility.h>
-namespace Gentoo {
- namespace Service {
- class DLL_PUBLIC Maintenance : public Gentoo::Maintenance, public IceTray::AbstractDatabaseClient {
- public:
- Maintenance(const DB::ConnectionPoolPtr & d, const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p);
- virtual ~Maintenance();
-
- void refreshPackageTree(const Ice::Current &) override;
- void refreshBugs(const Ice::Current &) override;
- void updateRepositories(const Ice::Current &) override;
- Gentoo::UserNews getUserNews(const Ice::Current &) override;
- void sendNotifications(const Ice::Current &) override;
-
- protected:
- Maintenance(const DB::ConnectionPoolPtr & d);
- void applyFileChanges(
- DB::Connection *, const std::filesystem::path &, const Repository &, ChangeSet &) const;
-
- private:
- template<typename Task>
- void addTask(Ice::CommunicatorPtr ic, Ice::PropertiesPtr p, const std::string & whenCfg);
-
- static Ice::PropertiesPtr properties(const Ice::Current &);
-
- template<typename T> static FileProcessorPtr createFileProessor();
- IceUtil::TimerPtr taskRunner;
- };
- }
+namespace Gentoo::Service {
+ class DLL_PUBLIC Maintenance : public Gentoo::Maintenance, public IceTray::AbstractDatabaseClient {
+ public:
+ explicit Maintenance(DB::ConnectionPoolPtr d, const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p);
+ ~Maintenance() override;
+ SPECIAL_MEMBERS_DELETE(Maintenance);
+
+ void refreshPackageTree(const Ice::Current &) override;
+ void refreshBugs(const Ice::Current &) override;
+ void updateRepositories(const Ice::Current &) override;
+ Gentoo::UserNews getUserNews(const Ice::Current &) override;
+ void sendNotifications(const Ice::Current &) override;
+
+ protected:
+ explicit Maintenance(DB::ConnectionPoolPtr d);
+ void applyFileChanges(DB::Connection *, const std::filesystem::path &, const Repository &, ChangeSet &) const;
+
+ private:
+ template<typename Task>
+ void addTask(const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p, const std::string & whenCfg);
+
+ static Ice::PropertiesPtr properties(const Ice::Current &);
+
+ template<typename T> static FileProcessorPtr createFileProessor();
+ IceUtil::TimerPtr taskRunner;
+ };
}
#endif
diff --git a/gentoobrowse-api/service/mask.cpp b/gentoobrowse-api/service/mask.cpp
index 6f4d1ac..6dabb41 100644
--- a/gentoobrowse-api/service/mask.cpp
+++ b/gentoobrowse-api/service/mask.cpp
@@ -1,44 +1,41 @@
#include <lexer-regex.h>
#include <mask.h>
-namespace Portage {
- namespace Utils {
- static AdHoc::Lexer::PatternPtr maskHead
- = AdHoc::LexerMatchers::regex("^# ([^<\n]+)? ?(<(.+?@[^\n>]+)>?)? \\((\\d{4}-\\d{2}-\\d{1,2})\\)$\n",
- static_cast<GRegexCompileFlags>(
- G_REGEX_OPTIMIZE | G_REGEX_CASELESS | G_REGEX_UNGREEDY | G_REGEX_MULTILINE));
- static AdHoc::Lexer::PatternPtr maskDesc = AdHoc::LexerMatchers::regex("^# *([^\n]*)$\n", G_REGEX_MULTILINE);
- static AdHoc::Lexer::PatternPtr atom = AdHoc::LexerMatchers::regex("^([^\n/]+/[^\n]*)$\n?", G_REGEX_MULTILINE);
- static AdHoc::Lexer::PatternPtr end = AdHoc::LexerMatchers::regex("^\\s*$\n", G_REGEX_MULTILINE);
- static AdHoc::Lexer::PatternPtr discard = AdHoc::LexerMatchers::regex("^([^\n]*)$\n?", G_REGEX_MULTILINE);
+namespace Portage::Utils {
+ static AdHoc::Lexer::PatternPtr maskHead
+ = AdHoc::LexerMatchers::regex("^# ([^<\n]+)? ?(<(.+?@[^\n>]+)>?)? \\((\\d{4}-\\d{2}-\\d{1,2})\\)$\n",
+ static_cast<GRegexCompileFlags>(
+ G_REGEX_OPTIMIZE | G_REGEX_CASELESS | G_REGEX_UNGREEDY | G_REGEX_MULTILINE));
+ static AdHoc::Lexer::PatternPtr maskDesc = AdHoc::LexerMatchers::regex("^# *([^\n]*)$\n", G_REGEX_MULTILINE);
+ static AdHoc::Lexer::PatternPtr atom = AdHoc::LexerMatchers::regex("^([^\n/]+/[^\n]*)$\n?", G_REGEX_MULTILINE);
+ static AdHoc::Lexer::PatternPtr end = AdHoc::LexerMatchers::regex("^\\s*$\n", G_REGEX_MULTILINE);
+ static AdHoc::Lexer::PatternPtr discard = AdHoc::LexerMatchers::regex("^([^\n]*)$\n?", G_REGEX_MULTILINE);
- Masks::Masks() :
- AdHoc::Lexer({{{AdHoc::Lexer::InitialState}, maskHead,
- [&](auto e) {
- person = e->pattern()->match(1);
- email = e->pattern()->match(3);
- date = *e->pattern()->match(4);
- e->pushState("mask");
- }},
- {{"mask"}, maskDesc,
- [&](auto e) {
- message.push_back(*e->pattern()->match(1));
- }},
- {{"mask"}, atom,
- [&](auto e) {
- atoms.insert(*e->pattern()->match(1));
- }},
- {{"mask"}, end,
- [&](auto e) {
- ++n;
- consume();
- atoms.clear();
- message.clear();
- e->popState();
- }},
- {{AdHoc::Lexer::InitialState}, discard, [&](auto) {}}}),
- n(0)
- {
- }
+ Masks::Masks() :
+ AdHoc::Lexer({{{AdHoc::Lexer::InitialState}, maskHead,
+ [&](auto e) {
+ person = e->pattern()->match(1);
+ email = e->pattern()->match(3);
+ date = *e->pattern()->match(4);
+ e->pushState("mask");
+ }},
+ {{"mask"}, maskDesc,
+ [&](auto e) {
+ message.push_back(*e->pattern()->match(1));
+ }},
+ {{"mask"}, atom,
+ [&](auto e) {
+ atoms.insert(*e->pattern()->match(1));
+ }},
+ {{"mask"}, end,
+ [&](auto e) {
+ ++n;
+ consume();
+ atoms.clear();
+ message.clear();
+ e->popState();
+ }},
+ {{AdHoc::Lexer::InitialState}, discard, [&](auto) {}}})
+ {
}
}
diff --git a/gentoobrowse-api/service/mask.h b/gentoobrowse-api/service/mask.h
index abdf6b0..08f534b 100644
--- a/gentoobrowse-api/service/mask.h
+++ b/gentoobrowse-api/service/mask.h
@@ -1,27 +1,24 @@
-#ifndef GENTOOBROWSE_SERVICE_MASK_H
-#define GENTOOBROWSE_SERVICE_MASK_H
+#pragma once
#include "wrap/ustring.h"
+#include <c++11Helpers.h>
#include <lexer.h>
#include <list>
#include <optional>
-namespace Portage {
- namespace Utils {
- class Masks : public AdHoc::Lexer {
- protected:
- Masks();
- virtual ~Masks() = default;
+namespace Portage::Utils {
+ class Masks : public AdHoc::Lexer {
+ protected:
+ Masks();
+ virtual ~Masks() = default;
+ SPECIAL_MEMBERS_DEFAULT(Masks);
- virtual void consume() const = 0;
+ virtual void consume() const = 0;
- Glib::ustring date;
- std::optional<Glib::ustring> person, email;
- std::set<std::string> atoms;
- std::list<std::string> message;
- int n;
- };
- }
+ Glib::ustring date;
+ std::optional<Glib::ustring> person, email;
+ std::set<std::string> atoms;
+ std::list<std::string> message;
+ int n {0};
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/news.cpp b/gentoobrowse-api/service/news.cpp
index 62e33ef..1690959 100644
--- a/gentoobrowse-api/service/news.cpp
+++ b/gentoobrowse-api/service/news.cpp
@@ -2,114 +2,112 @@
#include <boost/algorithm/string/split.hpp>
#include <lexer-regex.h>
-AdHoc::Lexer::PatternPtr Title(AdHoc::LexerMatchers::regex(
- "^Title: (.+)$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-AdHoc::Lexer::PatternPtr DisplayIfInstalled(AdHoc::LexerMatchers::regex(
- "^Display-If-Installed: (.+)$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-AdHoc::Lexer::PatternPtr Author(AdHoc::LexerMatchers::regex(
- "^Author: (.+) <([^>]+)>$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-AdHoc::Lexer::PatternPtr Posted(AdHoc::LexerMatchers::regex("^Posted: ([0-9]{4}-[0-9]{2}-[0-9]{2})$\\s",
- static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-AdHoc::Lexer::PatternPtr IgnoredHeader(AdHoc::LexerMatchers::regex(
- "^[^ :]+: .+$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-AdHoc::Lexer::PatternPtr BlankLine(
- AdHoc::LexerMatchers::regex("^$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-AdHoc::Lexer::PatternPtr BodyText(AdHoc::LexerMatchers::regex(
- "^(.*)$\\s?", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-AdHoc::Lexer::PatternPtr Link(AdHoc::LexerMatchers::regex("^\\[[[:digit:]]+\\] ([[:alpha:]]+://.*)$\\s?",
- static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+namespace Portage::Utils {
+ AdHoc::Lexer::PatternPtr Title(AdHoc::LexerMatchers::regex(
+ "^Title: (.+)$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+ AdHoc::Lexer::PatternPtr DisplayIfInstalled(AdHoc::LexerMatchers::regex(
+ "^Display-If-Installed: (.+)$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+ AdHoc::Lexer::PatternPtr Author(AdHoc::LexerMatchers::regex(
+ "^Author: (.+) <([^>]+)>$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+ AdHoc::Lexer::PatternPtr Posted(AdHoc::LexerMatchers::regex("^Posted: ([0-9]{4}-[0-9]{2}-[0-9]{2})$\\s",
+ static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+ AdHoc::Lexer::PatternPtr IgnoredHeader(AdHoc::LexerMatchers::regex(
+ "^[^ :]+: .+$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+ AdHoc::Lexer::PatternPtr BlankLine(AdHoc::LexerMatchers::regex(
+ "^$\\s", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+ AdHoc::Lexer::PatternPtr BodyText(AdHoc::LexerMatchers::regex(
+ "^(.*)$\\s?", static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
+ AdHoc::Lexer::PatternPtr Link(AdHoc::LexerMatchers::regex(R"(^\[[[:digit:]]+\] ([[:alpha:]]+://.*)$\s?)",
+ static_cast<GRegexCompileFlags>(G_REGEX_OPTIMIZE | G_REGEX_MULTILINE)));
-const std::string Body("Body");
+ const std::string Body("Body");
-namespace Portage {
- namespace Utils {
- template<typename T, typename Y>
- Ice::optional<T>
- iuo(const std::optional<Y> & x)
- {
- if (x) {
- return Ice::optional<T>(*x);
- }
- return Ice::optional<T>();
+ template<typename T, typename Y>
+ Ice::optional<T>
+ iuo(const std::optional<Y> & x)
+ {
+ if (x) {
+ return Ice::optional<T>(*x);
}
+ return Ice::optional<T>();
+ }
- template<typename T, typename Y>
- std::vector<T>
- split(const std::optional<Y> & x)
- {
- std::vector<T> rtn;
- if (x) {
- boost::algorithm::split(rtn, *x, [](auto c) {
- return c == ',';
- });
- std::sort(rtn.begin(), rtn.end());
- }
- return rtn;
+ template<typename T, typename Y>
+ std::vector<T>
+ split(const std::optional<Y> & x)
+ {
+ std::vector<T> rtn;
+ if (x) {
+ boost::algorithm::split(rtn, *x, [](auto c) {
+ return c == ',';
+ });
+ std::sort(rtn.begin(), rtn.end());
}
+ return rtn;
+ }
- News::News() :
- AdHoc::Lexer({// title: words
- {{InitialState}, Title,
- [this](auto es) {
- news->title = *es->pattern()->match(1);
- }},
- // posted: date
- {{InitialState}, Posted,
- [this](auto es) {
- news->posted = *es->pattern()->match(1);
- }},
- // display-if-installed: atomspec
- {{InitialState}, DisplayIfInstalled,
- [this](auto es) {
- news->atomspec.push_back(*es->pattern()->match(1));
- }},
- // author: name <email>
- {{InitialState}, Author,
- [this](auto es) {
- news->authorname = es->pattern()->match(1)->raw();
- news->authoremail = es->pattern()->match(2)->raw();
- }},
- // other headers
- {{InitialState}, IgnoredHeader, [](auto) {}},
- // blank
- {{InitialState}, BlankLine,
- [this](auto es) {
- es->setState(Body);
- news->body.push_back(std::string());
- }},
- // body blank
- {{Body}, BlankLine,
- [this](auto) {
- news->body.push_back(std::string());
- }},
- // link
- {{Body}, Link,
- [this](auto es) {
- news->urls.push_back(*es->pattern()->match(1));
- }},
- // body text
- {{Body}, BodyText,
- [this](auto es) {
- if (!news->body.back().empty()) {
- news->body.back().append(" ");
- }
- news->body.back().append(*es->pattern()->match(1));
- }}}),
- news(std::make_shared<Gentoo::NewsItem>())
- {
- }
+ News::News() :
+ AdHoc::Lexer({// title: words
+ {{InitialState}, Title,
+ [this](auto es) {
+ news->title = *es->pattern()->match(1);
+ }},
+ // posted: date
+ {{InitialState}, Posted,
+ [this](auto es) {
+ news->posted = *es->pattern()->match(1);
+ }},
+ // display-if-installed: atomspec
+ {{InitialState}, DisplayIfInstalled,
+ [this](auto es) {
+ news->atomspec.push_back(*es->pattern()->match(1));
+ }},
+ // author: name <email>
+ {{InitialState}, Author,
+ [this](auto es) {
+ news->authorname = es->pattern()->match(1)->raw();
+ news->authoremail = es->pattern()->match(2)->raw();
+ }},
+ // other headers
+ {{InitialState}, IgnoredHeader, [](auto) {}},
+ // blank
+ {{InitialState}, BlankLine,
+ [this](auto es) {
+ es->setState(Body);
+ news->body.push_back(std::string());
+ }},
+ // body blank
+ {{Body}, BlankLine,
+ [this](auto) {
+ news->body.push_back(std::string());
+ }},
+ // link
+ {{Body}, Link,
+ [this](auto es) {
+ news->urls.push_back(*es->pattern()->match(1));
+ }},
+ // body text
+ {{Body}, BodyText,
+ [this](auto es) {
+ if (!news->body.back().empty()) {
+ news->body.back().append(" ");
+ }
+ news->body.back().append(*es->pattern()->match(1));
+ }}}),
+ news(std::make_shared<Gentoo::NewsItem>())
+ {
+ }
- Gentoo::NewsItemPtr
- News::parse(const std::basic_string_view<gchar> & str)
- {
- News d;
- d.extract(str.data(), str.length());
- d.news->body.erase(std::remove_if(d.news->body.begin(), d.news->body.end(),
- [](const auto & s) {
- return s.empty();
- }),
- d.news->body.end());
- return d.news;
- }
+ Gentoo::NewsItemPtr
+ News::parse(const std::basic_string_view<gchar> & str)
+ {
+ News d;
+ d.extract(str.data(), str.length());
+ d.news->body.erase(std::remove_if(d.news->body.begin(), d.news->body.end(),
+ [](const auto & s) {
+ return s.empty();
+ }),
+ d.news->body.end());
+ return d.news;
}
}
diff --git a/gentoobrowse-api/service/news.h b/gentoobrowse-api/service/news.h
index 23e3d12..d13263c 100644
--- a/gentoobrowse-api/service/news.h
+++ b/gentoobrowse-api/service/news.h
@@ -1,22 +1,17 @@
-#ifndef GENTOOBROWSE_SERVICE_NEWS_H
-#define GENTOOBROWSE_SERVICE_NEWS_H
+#pragma once
#include <istream>
#include <lexer.h>
#include <portage-models.h>
#include <vector>
-namespace Portage {
- namespace Utils {
- class News : AdHoc::Lexer {
- private:
- News();
+namespace Portage::Utils {
+ class News : AdHoc::Lexer {
+ private:
+ News();
- public:
- Gentoo::NewsItemPtr news;
- static Gentoo::NewsItemPtr parse(const std::basic_string_view<gchar> &);
- };
- }
+ public:
+ Gentoo::NewsItemPtr news;
+ static Gentoo::NewsItemPtr parse(const std::basic_string_view<gchar> &);
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/notificationsimpl.cpp b/gentoobrowse-api/service/notificationsimpl.cpp
index 76a0bfd..71b2a78 100644
--- a/gentoobrowse-api/service/notificationsimpl.cpp
+++ b/gentoobrowse-api/service/notificationsimpl.cpp
@@ -1,64 +1,62 @@
#include "notificationsimpl.h"
#include "xsltStreamSerializer.h"
+#include <cstring>
#include <libxml/parser.h>
#include <notifications/xslt/base.h>
#include <notifications/xslt/news.h>
#include <notifications/xslt/signup.h>
#include <slicer/slicer.h>
-#include <string.h>
#define BADCAST(str) reinterpret_cast<const unsigned char *>(str)
-namespace Gentoo {
- namespace Service {
- xmlDocPtr
- xsltDocLoaderFunc(const xmlChar * URI, xmlDictPtr, int, void *, xsltLoadType)
- {
+namespace Gentoo::Service {
+ xmlDocPtr
+ xsltDocLoaderFunc(const xmlChar * URI, xmlDictPtr, int, void *, xsltLoadType)
+ {
#define MATCH(name) \
if (xmlStrcmp(URI, BADCAST(#name ".xslt")) == 0) { \
return xmlParseMemory(reinterpret_cast<const char *>(name##_xslt), static_cast<int>(name##_xslt_len)); \
}
- MATCH(base)
- MATCH(news)
- MATCH(signup)
- return NULL;
+ MATCH(base)
+ MATCH(news)
+ MATCH(signup)
+ return nullptr;
#undef MATCH
- }
+ }
- Notifications::Notifications()
- {
- xsltSetLoaderFunc(&xsltDocLoaderFunc);
- news = xsltSSPtr(xsltParseStylesheetFile(BADCAST("news.xslt")), xsltFreeStylesheet);
- signup = xsltSSPtr(xsltParseStylesheetFile(BADCAST("signup.xslt")), xsltFreeStylesheet);
- xsltSetLoaderFunc(NULL);
- }
+ Notifications::Notifications()
+ {
+ xsltSetLoaderFunc(&xsltDocLoaderFunc);
+ news = xsltSSPtr(xsltParseStylesheetFile(BADCAST("news.xslt")), xsltFreeStylesheet);
+ signup = xsltSSPtr(xsltParseStylesheetFile(BADCAST("signup.xslt")), xsltFreeStylesheet);
+ xsltSetLoaderFunc(nullptr);
+ }
- IceTray::Mail::EmailPtr
- Notifications::getSignup(const Gentoo::NewUserPtr & u)
- {
- auto e = basicMail("Welcome", u);
- Slicer::SerializeAny<XsltStreamSerializer>(u, e, signup.get());
- return e;
- }
+ IceTray::Mail::EmailPtr
+ Notifications::getSignup(const Gentoo::NewUserPtr & u)
+ {
+ auto e = basicMail("Welcome", u);
+ Slicer::SerializeAny<XsltStreamSerializer>(u, e, signup.get());
+ return e;
+ }
- IceTray::Mail::EmailPtr
- Notifications::getNews(const Gentoo::UserPtr & u, const Gentoo::NewsContent & c)
- {
- auto e = basicMail("Latest updates", u);
- Slicer::SerializeAny<XsltStreamSerializer>(c, e, news.get());
- return e;
- }
+ IceTray::Mail::EmailPtr
+ Notifications::getNews(const Gentoo::UserPtr & u, const Gentoo::NewsContent & c)
+ {
+ auto e = basicMail("Latest updates", u);
+ Slicer::SerializeAny<XsltStreamSerializer>(c, e, news.get());
+ return e;
+ }
- IceTray::Mail::EmailPtr
- Notifications::basicMail(const std::string & subject, const Gentoo::UserPtr & u)
- {
- auto e = std::make_shared<IceTray::Mail::Email>();
- e->subject = "Gentoo Browse: " + subject;
- e->from.name = "Gentoo Browse";
- e->from.address = "noreply@gentoobrowse.randomdan.homeip.net";
- e->to.name = u->userrealname;
- e->to.address = u->useremail;
- return e;
- }
+ IceTray::Mail::EmailPtr
+ Notifications::basicMail(const std::string & subject, const Gentoo::UserPtr & u)
+ {
+ auto e = std::make_shared<IceTray::Mail::Email>();
+ e->subject = "Gentoo Browse: " + subject;
+ e->from.name = "Gentoo Browse";
+ e->from.address = "noreply@gentoobrowse.randomdan.homeip.net";
+ e->to.name = u->userrealname;
+ e->to.address = u->useremail;
+ return e;
}
}
diff --git a/gentoobrowse-api/service/notificationsimpl.h b/gentoobrowse-api/service/notificationsimpl.h
index 4ce0f26..afad26e 100644
--- a/gentoobrowse-api/service/notificationsimpl.h
+++ b/gentoobrowse-api/service/notificationsimpl.h
@@ -6,23 +6,21 @@
#include <notifications.h>
#include <visibility.h>
-namespace Gentoo {
- namespace Service {
- class DLL_PUBLIC Notifications : public Gentoo::Notifications {
- public:
- Notifications();
+namespace Gentoo::Service {
+ class DLL_PUBLIC Notifications : public Gentoo::Notifications {
+ public:
+ Notifications();
- IceTray::Mail::EmailPtr getSignup(const Gentoo::NewUserPtr &) override;
- IceTray::Mail::EmailPtr getNews(const Gentoo::UserPtr &, const Gentoo::NewsContent &) override;
+ IceTray::Mail::EmailPtr getSignup(const Gentoo::NewUserPtr &) override;
+ IceTray::Mail::EmailPtr getNews(const Gentoo::UserPtr &, const Gentoo::NewsContent &) override;
- private:
- IceTray::Mail::EmailPtr basicMail(const std::string &, const Gentoo::UserPtr & u);
+ private:
+ IceTray::Mail::EmailPtr basicMail(const std::string &, const Gentoo::UserPtr & u);
- typedef std::shared_ptr<xsltStylesheet> xsltSSPtr;
- xsltSSPtr news;
- xsltSSPtr signup;
- };
- }
+ using xsltSSPtr = std::shared_ptr<xsltStylesheet>;
+ xsltSSPtr news;
+ xsltSSPtr signup;
+ };
}
#endif
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp
index 5bceb6b..452de86 100644
--- a/gentoobrowse-api/service/portageimpl.cpp
+++ b/gentoobrowse-api/service/portageimpl.cpp
@@ -42,266 +42,264 @@
#include <sql/portage/getUserTrackedRecentVersions.sql.h>
#include <sql/portage/getUsesSearch.sql.h>
-namespace Gentoo {
- namespace Service {
- Portage::Portage(const DB::ConnectionPoolPtr & d) : IceTray::AbstractCachingDatabaseClient(d) { }
-
- Gentoo::CategoryPtr
- Portage::getCategory(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::CategoryPtr>(sql::portage::getCategory, 30, id);
- }
+namespace Gentoo::Service {
+ Portage::Portage(const DB::ConnectionPoolPtr & d) : IceTray::AbstractCachingDatabaseClient(d) { }
- Gentoo::CategoryPtr
- Portage::findCategory(const std::string_view name, const Ice::Current &)
- {
- return fetchCache<Gentoo::CategoryPtr>(sql::portage::findCategory, 30, name);
- }
+ Gentoo::CategoryPtr
+ Portage::getCategory(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::CategoryPtr>(sql::portage::getCategory, 30, id);
+ }
- Gentoo::Categories
- Portage::getAllCategories(const Ice::Current &)
- {
- return fetchCache<Gentoo::Categories>(sql::portage::getAllCategories, 30);
- }
+ Gentoo::CategoryPtr
+ Portage::findCategory(const std::string_view name, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::CategoryPtr>(sql::portage::findCategory, 30, name);
+ }
- Gentoo::Categories
- Portage::getCategoriesInSuper(const std::string_view super, const Ice::Current &)
- {
- return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesInSuper, 30, super);
- }
+ Gentoo::Categories
+ Portage::getAllCategories(const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Categories>(sql::portage::getAllCategories, 30);
+ }
- Gentoo::OverviewCategoriesBySuper
- Portage::getAllOverviewCategories(const Ice::Current &)
- {
- Gentoo::OverviewCategoriesBySuper rtn;
- auto cats = fetchCache<Gentoo::OverviewCategories>(sql::portage::getAllOverviewCategories, 30);
- for (const auto & c : cats) {
- auto hyphen = c->name.find('-');
- rtn[c->name.substr(0, hyphen)].push_back(c);
- }
- return rtn;
- }
+ Gentoo::Categories
+ Portage::getCategoriesInSuper(const std::string_view super, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesInSuper, 30, super);
+ }
- Gentoo::OverviewCategories
- Portage::getOverviewCategoriesInSuper(const std::string_view super, const Ice::Current &)
- {
- return fetchCache<Gentoo::OverviewCategories>(sql::portage::getOverviewCategoriesInSuper, 30, super);
+ Gentoo::OverviewCategoriesBySuper
+ Portage::getAllOverviewCategories(const Ice::Current &)
+ {
+ Gentoo::OverviewCategoriesBySuper rtn;
+ auto cats = fetchCache<Gentoo::OverviewCategories>(sql::portage::getAllOverviewCategories, 30);
+ for (const auto & c : cats) {
+ auto hyphen = c->name.find('-');
+ rtn[c->name.substr(0, hyphen)].push_back(c);
}
+ return rtn;
+ }
- Gentoo::PackagePtr
- Portage::getPackage(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::PackagePtr>(sql::portage::getPackage, 30, id);
- }
+ Gentoo::OverviewCategories
+ Portage::getOverviewCategoriesInSuper(const std::string_view super, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::OverviewCategories>(sql::portage::getOverviewCategoriesInSuper, 30, super);
+ }
- Gentoo::PackagePtr
- Portage::findPackage(const std::string_view cat, const std::string_view pkg, const Ice::Current &)
- {
- return fetchCache<Gentoo::PackagePtr>(sql::portage::findPackage, 30, cat, pkg);
- }
+ Gentoo::PackagePtr
+ Portage::getPackage(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::PackagePtr>(sql::portage::getPackage, 30, id);
+ }
- Gentoo::Packages
- Portage::getAllPackages(const Ice::Current &)
- {
- return fetchCache<Gentoo::Packages>(sql::portage::getAllPackages, 30);
- }
+ Gentoo::PackagePtr
+ Portage::findPackage(const std::string_view cat, const std::string_view pkg, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::PackagePtr>(sql::portage::findPackage, 30, cat, pkg);
+ }
- Gentoo::Packages
- Portage::getPackagesInCategory(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::Packages>(sql::portage::getPackagesInCategory, 30, id);
- }
+ Gentoo::Packages
+ Portage::getAllPackages(const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Packages>(sql::portage::getAllPackages, 30);
+ }
- Gentoo::SearchResultPackages
- Portage::getPackagesSearch(const std::string_view query, const Ice::Current &)
- {
- return fetchCache<Gentoo::SearchResultPackages>(sql::portage::getPackagesSearch, 30, query, query);
- }
+ Gentoo::Packages
+ Portage::getPackagesInCategory(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Packages>(sql::portage::getPackagesInCategory, 30, id);
+ }
- Gentoo::Ebuilds
- Portage::getPackageVersions(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::Ebuilds>(sql::portage::getPackageVersions, 30, id);
- }
+ Gentoo::SearchResultPackages
+ Portage::getPackagesSearch(const std::string_view query, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::SearchResultPackages>(sql::portage::getPackagesSearch, 30, query, query);
+ }
- Gentoo::EbuildDetails
- Portage::getPackageVersionDetails(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::EbuildDetails>(sql::portage::getPackageVersionDetails, 30, id);
- }
+ Gentoo::Ebuilds
+ Portage::getPackageVersions(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Ebuilds>(sql::portage::getPackageVersions, 30, id);
+ }
- Gentoo::ChangeLog
- Portage::getPackageChangeLog(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::ChangeLog>(sql::portage::getPackageChangeLog, 30, id);
- }
+ Gentoo::EbuildDetails
+ Portage::getPackageVersionDetails(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::EbuildDetails>(sql::portage::getPackageVersionDetails, 30, id);
+ }
- Gentoo::Ebuilds
- Portage::getRecentAdditions(Ice::Int syncDays, const Ice::Current &)
- {
- return fetchCache<Gentoo::Ebuilds>(sql::portage::getRecentAdditions, 30, syncDays);
- }
+ Gentoo::ChangeLog
+ Portage::getPackageChangeLog(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::ChangeLog>(sql::portage::getPackageChangeLog, 30, id);
+ }
- Gentoo::Packages
- Portage::getPackagesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &)
- {
- return fetchCache<Gentoo::Packages>(sql::portage::getPackagesWithRecentAdditions, 30, syncDays);
- }
+ Gentoo::Ebuilds
+ Portage::getRecentAdditions(Ice::Int syncDays, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Ebuilds>(sql::portage::getRecentAdditions, 30, syncDays);
+ }
- Gentoo::Packages
- Portage::getTopTrackedPackages(Ice::Int n, const Ice::Current &)
- {
- return fetchCache<Gentoo::Packages>(sql::portage::getTopTrackedPackages, 30, n);
- }
+ Gentoo::Packages
+ Portage::getPackagesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Packages>(sql::portage::getPackagesWithRecentAdditions, 30, syncDays);
+ }
- Gentoo::Packages
- Portage::getUserTrackedPackages(Ice::Int userid, const Ice::Current &)
- {
- return fetchCache<Gentoo::Packages>(sql::portage::getUserTrackedPackages, 30, userid);
- }
+ Gentoo::Packages
+ Portage::getTopTrackedPackages(Ice::Int n, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Packages>(sql::portage::getTopTrackedPackages, 30, n);
+ }
- Gentoo::Ebuilds
- Portage::getUserTrackedRecentVersions(Ice::Int userid, Ice::Int limit, const Ice::Current &)
- {
- return fetchCache<Gentoo::Ebuilds>(sql::portage::getUserTrackedRecentVersions, 30, userid, limit);
- }
+ Gentoo::Packages
+ Portage::getUserTrackedPackages(Ice::Int userid, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Packages>(sql::portage::getUserTrackedPackages, 30, userid);
+ }
- Gentoo::StringList
- Portage::getPackageUrls(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::StringList>(sql::portage::getPackageUrls, 30, id);
- }
+ Gentoo::Ebuilds
+ Portage::getUserTrackedRecentVersions(Ice::Int userid, Ice::Int limit, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Ebuilds>(sql::portage::getUserTrackedRecentVersions, 30, userid, limit);
+ }
- Gentoo::Ebuilds
- Portage::getEbuildsByFilter(const std::string_view filter, const Ice::Current &)
- {
- return fetchCache<Gentoo::Ebuilds>(sql::portage::getEbuildsByFilter, 30, filter);
- }
+ Gentoo::StringList
+ Portage::getPackageUrls(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::StringList>(sql::portage::getPackageUrls, 30, id);
+ }
- Gentoo::Categories
- Portage::getCategoriesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &)
- {
- return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesWithRecentAdditions, 30, syncDays);
- }
+ Gentoo::Ebuilds
+ Portage::getEbuildsByFilter(const std::string_view filter, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Ebuilds>(sql::portage::getEbuildsByFilter, 30, filter);
+ }
- Gentoo::PackageDependencyPackages
- Portage::getPackageDependencies(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackageDependencies, 30, id);
- }
+ Gentoo::Categories
+ Portage::getCategoriesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesWithRecentAdditions, 30, syncDays);
+ }
- Gentoo::PackageDependencyPackages
- Portage::getPackageRuntimeDependencies(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackageRuntimeDependencies, 30, id);
- }
+ Gentoo::PackageDependencyPackages
+ Portage::getPackageDependencies(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackageDependencies, 30, id);
+ }
- Gentoo::PackageDependencyPackages
- Portage::getPackagesDepending(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackagesDepending, 30, id);
- }
+ Gentoo::PackageDependencyPackages
+ Portage::getPackageRuntimeDependencies(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackageRuntimeDependencies, 30, id);
+ }
- Gentoo::PackageMasks
- Portage::getPackageMasks(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::PackageMasks>(sql::portage::getPackageMasks, 30, id);
- }
+ Gentoo::PackageDependencyPackages
+ Portage::getPackagesDepending(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackagesDepending, 30, id);
+ }
- Gentoo::Uses
- Portage::getPackageUses(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::Uses>(sql::portage::getPackageUses, 30, id);
- }
+ Gentoo::PackageMasks
+ Portage::getPackageMasks(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::PackageMasks>(sql::portage::getPackageMasks, 30, id);
+ }
- Gentoo::UsePtr
- Portage::getUse(const std::string_view use, const Ice::Current &)
- {
- return fetchCache<Gentoo::UsePtr>(sql::portage::getUse, 30, use, use);
- }
+ Gentoo::Uses
+ Portage::getPackageUses(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Uses>(sql::portage::getPackageUses, 30, id);
+ }
- Gentoo::Uses
- Portage::getGlobalUses(const Ice::Current &)
- {
- return fetchCache<Gentoo::Uses>(sql::portage::getGlobalUses, 30);
- }
+ Gentoo::UsePtr
+ Portage::getUse(const std::string_view use, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::UsePtr>(sql::portage::getUse, 30, use, use);
+ }
- Gentoo::Uses
- Portage::getGroupUses(const std::string_view group, const Ice::Current &)
- {
- return fetchCache<Gentoo::Uses>(sql::portage::getGroupUses, 30, group);
- }
+ Gentoo::Uses
+ Portage::getGlobalUses(const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Uses>(sql::portage::getGlobalUses, 30);
+ }
- Gentoo::StringList
- Portage::getUseGroups(const Ice::Current &)
- {
- return fetchCache<Gentoo::StringList>(sql::portage::getUseGroups, 30);
- }
+ Gentoo::Uses
+ Portage::getGroupUses(const std::string_view group, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Uses>(sql::portage::getGroupUses, 30, group);
+ }
- Gentoo::Uses
- Portage::getUseUsage(const std::string_view use, const Ice::Current &)
- {
- return fetchCache<Gentoo::Uses>(sql::portage::getUseUsage, 30, use, use, use, use);
- }
+ Gentoo::StringList
+ Portage::getUseGroups(const Ice::Current &)
+ {
+ return fetchCache<Gentoo::StringList>(sql::portage::getUseGroups, 30);
+ }
- Gentoo::Packages
- Portage::getUsePackages(const std::string_view use, const Ice::Current &)
- {
- return fetchCache<Gentoo::Packages>(sql::portage::getUsePackages, 30, use, use);
- }
+ Gentoo::Uses
+ Portage::getUseUsage(const std::string_view use, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Uses>(sql::portage::getUseUsage, 30, use, use, use, use);
+ }
- Gentoo::Uses
- Portage::getUsesSearch(const std::string_view query, const Ice::Current &)
- {
- return fetchCache<Gentoo::Uses>(sql::portage::getUsesSearch, 30, query);
- }
+ Gentoo::Packages
+ Portage::getUsePackages(const std::string_view use, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Packages>(sql::portage::getUsePackages, 30, use, use);
+ }
- Gentoo::BugPtr
- Portage::getBug(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::BugPtr>(sql::portage::getBug, 30, id);
- }
+ Gentoo::Uses
+ Portage::getUsesSearch(const std::string_view query, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Uses>(sql::portage::getUsesSearch, 30, query);
+ }
- Gentoo::Bugs
- Portage::getPackageBugs(Ice::Int packageId, const Ice::Current &)
- {
- return fetchCache<Gentoo::Bugs>(sql::portage::getPackageBugs, 30, packageId);
- }
+ Gentoo::BugPtr
+ Portage::getBug(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::BugPtr>(sql::portage::getBug, 30, id);
+ }
- Gentoo::SearchResultBugs
- Portage::getBugsSearch(const std::string_view query, const Ice::Current &)
- {
- return fetchCache<Gentoo::SearchResultBugs>(sql::portage::getBugsSearch, 30, query, query);
- }
+ Gentoo::Bugs
+ Portage::getPackageBugs(Ice::Int packageId, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Bugs>(sql::portage::getPackageBugs, 30, packageId);
+ }
- Gentoo::NewsItemPtr
- Portage::getNewsItem(const std::string_view id, const Ice::Current &)
- {
- return fetchCache<Gentoo::NewsItemPtr>(sql::portage::getNewsItem, 30, id);
- }
+ Gentoo::SearchResultBugs
+ Portage::getBugsSearch(const std::string_view query, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::SearchResultBugs>(sql::portage::getBugsSearch, 30, query, query);
+ }
- Gentoo::News
- Portage::getNewsSearch(const std::string_view query, const Ice::Current &)
- {
- return fetchCache<Gentoo::News>(sql::portage::getNewsSearch, 30, query);
- }
+ Gentoo::NewsItemPtr
+ Portage::getNewsItem(const std::string_view id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::NewsItemPtr>(sql::portage::getNewsItem, 30, id);
+ }
- Gentoo::News
- Portage::getNewsRecent(Ice::Int items, const Ice::Current &)
- {
- return fetchCache<Gentoo::News>(sql::portage::getNewsRecent, 30, items);
- }
+ Gentoo::News
+ Portage::getNewsSearch(const std::string_view query, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::News>(sql::portage::getNewsSearch, 30, query);
+ }
- Gentoo::Repository
- Portage::getRepository(Ice::Int id, const Ice::Current &)
- {
- return fetchCache<Gentoo::Repository>(sql::portage::getRepository, 30, id);
- }
+ Gentoo::News
+ Portage::getNewsRecent(Ice::Int items, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::News>(sql::portage::getNewsRecent, 30, items);
+ }
- Gentoo::Repositories
- Portage::getRepositories(const Ice::Current &)
- {
- return fetchCache<Gentoo::Repositories>(sql::portage::getRepositories, 30);
- }
+ Gentoo::Repository
+ Portage::getRepository(Ice::Int id, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Repository>(sql::portage::getRepository, 30, id);
+ }
+
+ Gentoo::Repositories
+ Portage::getRepositories(const Ice::Current &)
+ {
+ return fetchCache<Gentoo::Repositories>(sql::portage::getRepositories, 30);
}
}
diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h
index 77d2e61..b4b2dfe 100644
--- a/gentoobrowse-api/service/portageimpl.h
+++ b/gentoobrowse-api/service/portageimpl.h
@@ -5,64 +5,59 @@
#include <portage.h>
#include <visibility.h>
-namespace Gentoo {
- namespace Service {
- class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatabaseClient {
- public:
- Portage(const DB::ConnectionPoolPtr & d);
-
- Gentoo::CategoryPtr getCategory(Ice::Int id, const Ice::Current &) override;
- Gentoo::CategoryPtr findCategory(const std::string_view name, const Ice::Current &) override;
- Gentoo::Categories getAllCategories(const Ice::Current &) override;
- Gentoo::Categories getCategoriesInSuper(const std::string_view, const Ice::Current &) override;
- Gentoo::OverviewCategoriesBySuper getAllOverviewCategories(const Ice::Current &) override;
- Gentoo::OverviewCategories getOverviewCategoriesInSuper(
- const std::string_view, const Ice::Current &) override;
-
- Gentoo::PackagePtr getPackage(Ice::Int id, const Ice::Current &) override;
- Gentoo::PackagePtr findPackage(
- const std::string_view, const std::string_view, const Ice::Current &) override;
- Gentoo::Packages getPackagesInCategory(Ice::Int id, const Ice::Current &) override;
- Gentoo::Packages getAllPackages(const Ice::Current &) override;
- Gentoo::SearchResultPackages getPackagesSearch(const std::string_view query, const Ice::Current &) override;
- Gentoo::Ebuilds getPackageVersions(Ice::Int id, const Ice::Current &) override;
- Gentoo::EbuildDetails getPackageVersionDetails(Ice::Int id, const Ice::Current &) override;
- Gentoo::ChangeLog getPackageChangeLog(Ice::Int id, const Ice::Current &) override;
- Gentoo::Ebuilds getRecentAdditions(Ice::Int syncDays, const Ice::Current &) override;
- Gentoo::Packages getPackagesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &) override;
- Gentoo::Categories getCategoriesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &) override;
- Gentoo::Packages getTopTrackedPackages(Ice::Int n, const Ice::Current &) override;
- Gentoo::PackageDependencyPackages getPackageDependencies(Ice::Int id, const Ice::Current &) override;
- Gentoo::PackageDependencyPackages getPackageRuntimeDependencies(Ice::Int id, const Ice::Current &) override;
- Gentoo::PackageDependencyPackages getPackagesDepending(Ice::Int id, const Ice::Current &) override;
- Gentoo::PackageMasks getPackageMasks(Ice::Int id, const Ice::Current &) override;
- Gentoo::Uses getPackageUses(Ice::Int id, const Ice::Current &) override;
- Gentoo::Packages getUserTrackedPackages(Ice::Int userid, const Ice::Current &) override;
- Gentoo::Ebuilds getUserTrackedRecentVersions(
- Ice::Int userid, Ice::Int limit, const Ice::Current &) override;
- Gentoo::StringList getPackageUrls(Ice::Int id, const Ice::Current &) override;
- Gentoo::Ebuilds getEbuildsByFilter(const std::string_view, const Ice::Current &) override;
-
- Gentoo::UsePtr getUse(const std::string_view, const Ice::Current &) override;
- Gentoo::Uses getGlobalUses(const Ice::Current &) override;
- Gentoo::Uses getGroupUses(const std::string_view, const Ice::Current &) override;
- Gentoo::StringList getUseGroups(const Ice::Current &) override;
- Gentoo::Uses getUseUsage(const std::string_view, const Ice::Current &) override;
- Gentoo::Packages getUsePackages(const std::string_view, const Ice::Current &) override;
- Gentoo::Uses getUsesSearch(const std::string_view, const Ice::Current &) override;
-
- Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override;
- Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override;
- Gentoo::SearchResultBugs getBugsSearch(const std::string_view query, const Ice::Current &) override;
-
- Gentoo::NewsItemPtr getNewsItem(const std::string_view, const Ice::Current &) override;
- Gentoo::News getNewsSearch(const std::string_view, const Ice::Current &) override;
- Gentoo::News getNewsRecent(Ice::Int, const Ice::Current &) override;
-
- Gentoo::Repository getRepository(Ice::Int, const Ice::Current &) override;
- Gentoo::Repositories getRepositories(const Ice::Current &) override;
- };
- }
+namespace Gentoo::Service {
+ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatabaseClient {
+ public:
+ explicit Portage(const DB::ConnectionPoolPtr & d);
+
+ Gentoo::CategoryPtr getCategory(Ice::Int id, const Ice::Current &) override;
+ Gentoo::CategoryPtr findCategory(const std::string_view name, const Ice::Current &) override;
+ Gentoo::Categories getAllCategories(const Ice::Current &) override;
+ Gentoo::Categories getCategoriesInSuper(const std::string_view, const Ice::Current &) override;
+ Gentoo::OverviewCategoriesBySuper getAllOverviewCategories(const Ice::Current &) override;
+ Gentoo::OverviewCategories getOverviewCategoriesInSuper(const std::string_view, const Ice::Current &) override;
+
+ Gentoo::PackagePtr getPackage(Ice::Int id, const Ice::Current &) override;
+ Gentoo::PackagePtr findPackage(const std::string_view, const std::string_view, const Ice::Current &) override;
+ Gentoo::Packages getPackagesInCategory(Ice::Int id, const Ice::Current &) override;
+ Gentoo::Packages getAllPackages(const Ice::Current &) override;
+ Gentoo::SearchResultPackages getPackagesSearch(const std::string_view query, const Ice::Current &) override;
+ Gentoo::Ebuilds getPackageVersions(Ice::Int id, const Ice::Current &) override;
+ Gentoo::EbuildDetails getPackageVersionDetails(Ice::Int id, const Ice::Current &) override;
+ Gentoo::ChangeLog getPackageChangeLog(Ice::Int id, const Ice::Current &) override;
+ Gentoo::Ebuilds getRecentAdditions(Ice::Int syncDays, const Ice::Current &) override;
+ Gentoo::Packages getPackagesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &) override;
+ Gentoo::Categories getCategoriesWithRecentAdditions(Ice::Int syncDays, const Ice::Current &) override;
+ Gentoo::Packages getTopTrackedPackages(Ice::Int n, const Ice::Current &) override;
+ Gentoo::PackageDependencyPackages getPackageDependencies(Ice::Int id, const Ice::Current &) override;
+ Gentoo::PackageDependencyPackages getPackageRuntimeDependencies(Ice::Int id, const Ice::Current &) override;
+ Gentoo::PackageDependencyPackages getPackagesDepending(Ice::Int id, const Ice::Current &) override;
+ Gentoo::PackageMasks getPackageMasks(Ice::Int id, const Ice::Current &) override;
+ Gentoo::Uses getPackageUses(Ice::Int id, const Ice::Current &) override;
+ Gentoo::Packages getUserTrackedPackages(Ice::Int userid, const Ice::Current &) override;
+ Gentoo::Ebuilds getUserTrackedRecentVersions(Ice::Int userid, Ice::Int limit, const Ice::Current &) override;
+ Gentoo::StringList getPackageUrls(Ice::Int id, const Ice::Current &) override;
+ Gentoo::Ebuilds getEbuildsByFilter(const std::string_view, const Ice::Current &) override;
+
+ Gentoo::UsePtr getUse(const std::string_view, const Ice::Current &) override;
+ Gentoo::Uses getGlobalUses(const Ice::Current &) override;
+ Gentoo::Uses getGroupUses(const std::string_view, const Ice::Current &) override;
+ Gentoo::StringList getUseGroups(const Ice::Current &) override;
+ Gentoo::Uses getUseUsage(const std::string_view, const Ice::Current &) override;
+ Gentoo::Packages getUsePackages(const std::string_view, const Ice::Current &) override;
+ Gentoo::Uses getUsesSearch(const std::string_view, const Ice::Current &) override;
+
+ Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override;
+ Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override;
+ Gentoo::SearchResultBugs getBugsSearch(const std::string_view query, const Ice::Current &) override;
+
+ Gentoo::NewsItemPtr getNewsItem(const std::string_view, const Ice::Current &) override;
+ Gentoo::News getNewsSearch(const std::string_view, const Ice::Current &) override;
+ Gentoo::News getNewsRecent(Ice::Int, const Ice::Current &) override;
+
+ Gentoo::Repository getRepository(Ice::Int, const Ice::Current &) override;
+ Gentoo::Repositories getRepositories(const Ice::Current &) override;
+ };
}
#endif
diff --git a/gentoobrowse-api/service/usersimpl.cpp b/gentoobrowse-api/service/usersimpl.cpp
index d62bd7e..a95e22b 100644
--- a/gentoobrowse-api/service/usersimpl.cpp
+++ b/gentoobrowse-api/service/usersimpl.cpp
@@ -17,122 +17,120 @@
#include <sql/users/untrack.sql.h>
#include <sql/users/verify.sql.h>
-namespace Gentoo {
- namespace Service {
- Users::Users(const DB::ConnectionPoolPtr & d) : IceTray::AbstractCachingDatabaseClient(d) { }
-
- Gentoo::UserPtr
- Users::authenticate(const std::string_view username, const std::string_view password, const Ice::Current &)
- {
- return fetchCache<Gentoo::UserPtr>(sql::users::authenticate, 30, username, password);
- }
+namespace Gentoo::Service {
+ Users::Users(const DB::ConnectionPoolPtr & d) : IceTray::AbstractCachingDatabaseClient(d) { }
- Gentoo::UserPtr
- Users::verify(const std::string_view username, const std::string_view verifyguid, const Ice::Current &)
- {
- return fetch<Gentoo::UserPtr>(sql::users::verify, username, verifyguid);
- }
+ Gentoo::UserPtr
+ Users::authenticate(const std::string_view username, const std::string_view password, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::UserPtr>(sql::users::authenticate, 30, username, password);
+ }
- Gentoo::UserPtr
- Users::get(Ice::Int id, const Ice::Current &)
- {
- return fetch<Gentoo::UserPtr>(sql::users::get, id);
- }
+ Gentoo::UserPtr
+ Users::verify(const std::string_view username, const std::string_view verifyguid, const Ice::Current &)
+ {
+ return fetch<Gentoo::UserPtr>(sql::users::verify, username, verifyguid);
+ }
- Gentoo::NewUserPtr
- Users::getNew(const std::string_view username, const std::string_view password, const Ice::Current &)
- {
- return fetch<Gentoo::NewUserPtr>(sql::users::getNew, username, password);
- }
+ Gentoo::UserPtr
+ Users::get(Ice::Int id, const Ice::Current &)
+ {
+ return fetch<Gentoo::UserPtr>(sql::users::get, id);
+ }
- Gentoo::UserPtr
- Users::find(const std::string_view username, const Ice::Current &)
- {
- return fetch<Gentoo::UserPtr>(sql::users::find, username);
- }
+ Gentoo::NewUserPtr
+ Users::getNew(const std::string_view username, const std::string_view password, const Ice::Current &)
+ {
+ return fetch<Gentoo::NewUserPtr>(sql::users::getNew, username, password);
+ }
+
+ Gentoo::UserPtr
+ Users::find(const std::string_view username, const Ice::Current &)
+ {
+ return fetch<Gentoo::UserPtr>(sql::users::find, username);
+ }
- Gentoo::NewUserPtr
- Users::authOrCreate(const std::string_view & username, const std::string_view & password,
- const std::string_view & realname, const std::string_view & email)
- {
- auto existing = fetch<IceUtil::Optional<Gentoo::NewUserPtr>>(sql::users::getNew, username, password);
- if (existing && *existing) {
- return *existing;
- }
- return fetch<Gentoo::NewUserPtr>(sql::users::create, username, password, realname, email);
+ Gentoo::NewUserPtr
+ Users::authOrCreate(const std::string_view & username, const std::string_view & password,
+ const std::string_view & realname, const std::string_view & email)
+ {
+ auto existing = fetch<IceUtil::Optional<Gentoo::NewUserPtr>>(sql::users::getNew, username, password);
+ if (existing && *existing) {
+ return *existing;
}
+ return fetch<Gentoo::NewUserPtr>(sql::users::create, username, password, realname, email);
+ }
- Gentoo::NewUserPtr
- Users::create(const std::string_view username, const std::string_view password, const std::string_view realname,
- const std::string_view email, const Ice::Current &)
- {
- auto notifications = IceTray::Cube::get<Notifications>();
- auto mailServer = IceTray::Cube::get<IceTray::Mail::MailServer>();
+ Gentoo::NewUserPtr
+ Users::create(const std::string_view username, const std::string_view password, const std::string_view realname,
+ const std::string_view email, const Ice::Current &)
+ {
+ auto notifications = IceTray::Cube::get<Notifications>();
+ auto mailServer = IceTray::Cube::get<IceTray::Mail::MailServer>();
- auto dbc = db->get();
- DB::TransactionScope tx(*dbc.get());
+ auto dbc = db->get();
+ DB::TransactionScope tx(*dbc.get());
- auto newUser = authOrCreate(username, password, realname, email);
- auto mail = notifications->getSignup(newUser);
- mailServer->sendEmail(mail);
+ auto newUser = authOrCreate(username, password, realname, email);
+ auto mail = notifications->getSignup(newUser);
+ mailServer->sendEmail(mail);
- return newUser;
- }
+ return newUser;
+ }
- void
- Users::mailshotsent(Ice::Int id, const Ice::Current &)
- {
- auto dbc = db->get();
- auto upd = sql::users::mailshotsent.modify(dbc.get());
- upd->bindParamI(0, id);
- upd->execute();
- }
+ void
+ Users::mailshotsent(Ice::Int id, const Ice::Current &)
+ {
+ auto dbc = db->get();
+ auto upd = sql::users::mailshotsent.modify(dbc.get());
+ upd->bindParamI(0, id);
+ upd->execute();
+ }
- void
- Users::remove(Ice::Int id, const std::string_view password, const Ice::Current &)
- {
- auto dbc = db->get();
- auto del = sql::users::safeDelete.modify(dbc.get());
- del->bindParamI(0, id);
- del->bindParamS(1, password);
- del->execute();
- }
+ void
+ Users::remove(Ice::Int id, const std::string_view password, const Ice::Current &)
+ {
+ auto dbc = db->get();
+ auto del = sql::users::safeDelete.modify(dbc.get());
+ del->bindParamI(0, id);
+ del->bindParamS(1, password);
+ del->execute();
+ }
- void
- Users::prune(const Ice::Current & current)
- {
- auto properties = current.adapter->getCommunicator()->getProperties();
- auto prunePeriod = properties->getPropertyWithDefault("GentooBrowseAPI.Users.PrunePeriod", "8 weeks");
- auto dbc = db->get();
- auto prune = sql::users::prune.modify(dbc.get());
- prune->bindParamS(0, prunePeriod);
- prune->execute();
- }
+ void
+ Users::prune(const Ice::Current & current)
+ {
+ auto properties = current.adapter->getCommunicator()->getProperties();
+ auto prunePeriod = properties->getPropertyWithDefault("GentooBrowseAPI.Users.PrunePeriod", "8 weeks");
+ auto dbc = db->get();
+ auto prune = sql::users::prune.modify(dbc.get());
+ prune->bindParamS(0, prunePeriod);
+ prune->execute();
+ }
- void
- Users::track(Ice::Int userId, Ice::Int packageId, const Ice::Current &)
- {
- auto dbc = db->get();
- auto track = sql::users::track.modify(dbc.get());
- track->bindParamI(0, userId);
- track->bindParamI(1, packageId);
- track->execute();
- }
+ void
+ Users::track(Ice::Int userId, Ice::Int packageId, const Ice::Current &)
+ {
+ auto dbc = db->get();
+ auto track = sql::users::track.modify(dbc.get());
+ track->bindParamI(0, userId);
+ track->bindParamI(1, packageId);
+ track->execute();
+ }
- void
- Users::untrack(Ice::Int userId, Ice::Int packageId, const Ice::Current &)
- {
- auto dbc = db->get();
- auto untrack = sql::users::untrack.modify(dbc.get());
- untrack->bindParamI(0, userId);
- untrack->bindParamI(1, packageId);
- untrack->execute();
- }
+ void
+ Users::untrack(Ice::Int userId, Ice::Int packageId, const Ice::Current &)
+ {
+ auto dbc = db->get();
+ auto untrack = sql::users::untrack.modify(dbc.get());
+ untrack->bindParamI(0, userId);
+ untrack->bindParamI(1, packageId);
+ untrack->execute();
+ }
- Gentoo::PackageIds
- Users::tracked(Ice::Int userId, const Ice::Current &)
- {
- return fetchCache<Gentoo::PackageIds>(sql::users::tracked, 10, userId);
- }
+ Gentoo::PackageIds
+ Users::tracked(Ice::Int userId, const Ice::Current &)
+ {
+ return fetchCache<Gentoo::PackageIds>(sql::users::tracked, 10, userId);
}
}
diff --git a/gentoobrowse-api/service/usersimpl.h b/gentoobrowse-api/service/usersimpl.h
index 79c5623..75d1644 100644
--- a/gentoobrowse-api/service/usersimpl.h
+++ b/gentoobrowse-api/service/usersimpl.h
@@ -5,33 +5,31 @@
#include <users.h>
#include <visibility.h>
-namespace Gentoo {
- namespace Service {
- class DLL_PUBLIC Users : public Gentoo::Users, IceTray::AbstractCachingDatabaseClient {
- public:
- Users(const DB::ConnectionPoolPtr & d);
+namespace Gentoo::Service {
+ class DLL_PUBLIC Users : public Gentoo::Users, IceTray::AbstractCachingDatabaseClient {
+ public:
+ explicit Users(const DB::ConnectionPoolPtr & d);
- Gentoo::UserPtr authenticate(const std::string_view, const std::string_view, const Ice::Current &) override;
- Gentoo::UserPtr verify(const std::string_view, const std::string_view, const Ice::Current &) override;
+ Gentoo::UserPtr authenticate(const std::string_view, const std::string_view, const Ice::Current &) override;
+ Gentoo::UserPtr verify(const std::string_view, const std::string_view, const Ice::Current &) override;
- Gentoo::UserPtr get(Ice::Int id, const Ice::Current &) override;
- Gentoo::NewUserPtr getNew(const std::string_view, const std::string_view, const Ice::Current &) override;
- Gentoo::UserPtr find(const std::string_view username, const Ice::Current &) override;
- Gentoo::NewUserPtr create(const std::string_view, const std::string_view, const std::string_view,
- const std::string_view, const Ice::Current &) override;
- void mailshotsent(Ice::Int id, const Ice::Current &) override;
- void remove(Ice::Int id, const std::string_view, const Ice::Current &) override;
- void prune(const Ice::Current &) override;
+ Gentoo::UserPtr get(Ice::Int id, const Ice::Current &) override;
+ Gentoo::NewUserPtr getNew(const std::string_view, const std::string_view, const Ice::Current &) override;
+ Gentoo::UserPtr find(const std::string_view username, const Ice::Current &) override;
+ Gentoo::NewUserPtr create(const std::string_view, const std::string_view, const std::string_view,
+ const std::string_view, const Ice::Current &) override;
+ void mailshotsent(Ice::Int id, const Ice::Current &) override;
+ void remove(Ice::Int id, const std::string_view, const Ice::Current &) override;
+ void prune(const Ice::Current &) override;
- void track(Ice::Int, Ice::Int, const Ice::Current &) override;
- void untrack(Ice::Int, Ice::Int, const Ice::Current &) override;
- Gentoo::PackageIds tracked(Ice::Int, const Ice::Current &) override;
+ void track(Ice::Int, Ice::Int, const Ice::Current &) override;
+ void untrack(Ice::Int, Ice::Int, const Ice::Current &) override;
+ Gentoo::PackageIds tracked(Ice::Int, const Ice::Current &) override;
- private:
- DLL_PRIVATE Gentoo::NewUserPtr authOrCreate(const std::string_view &, const std::string_view &,
- const std::string_view &, const std::string_view &);
- };
- }
+ private:
+ DLL_PRIVATE Gentoo::NewUserPtr authOrCreate(
+ const std::string_view &, const std::string_view &, const std::string_view &, const std::string_view &);
+ };
}
#endif
diff --git a/gentoobrowse-api/service/utils/dbUtils.cpp b/gentoobrowse-api/service/utils/dbUtils.cpp
index c281265..d0ae626 100644
--- a/gentoobrowse-api/service/utils/dbUtils.cpp
+++ b/gentoobrowse-api/service/utils/dbUtils.cpp
@@ -5,53 +5,48 @@
#include <buffer.h>
#include <tablepatch.h>
-namespace Gentoo {
- namespace Utils {
- namespace Database {
- std::string
- emptyClone(DB::Connection * db, const std::string & orig)
- {
- auto tempTable = orig;
- auto dot = tempTable.rfind('.');
- if (dot != std::string::npos) {
- tempTable = tempTable.substr(dot + 1);
- }
- tempTable += "_clone_" + boost::lexical_cast<std::string>(db);
- db->execute("CREATE TEMPORARY TABLE " + tempTable + " AS SELECT * FROM " + orig + " WHERE false");
- return tempTable;
- }
+namespace Gentoo::Utils::Database {
+ std::string
+ emptyClone(DB::Connection * db, const std::string & orig)
+ {
+ auto tempTable = orig;
+ auto dot = tempTable.rfind('.');
+ if (dot != std::string::npos) {
+ tempTable = tempTable.substr(dot + 1);
+ }
+ tempTable += "_clone_" + boost::lexical_cast<std::string>(db);
+ db->execute("CREATE TEMPORARY TABLE " + tempTable + " AS SELECT * FROM " + orig + " WHERE false");
+ return tempTable;
+ }
- std::pair<std::string, DB::ModifyCommandPtr>
- namedTemp(DB::Connection * db, const std::string & tempTable,
- const std::map<std::string, const std::string> & cols)
- {
- std::set<std::string> keys;
- std::set<std::string> defs;
- for (auto c : cols) {
- keys.insert(c.first);
- defs.insert(c.first + " " + c.second);
- }
- db->execute("CREATE TEMPORARY TABLE " + tempTable + "(" + boost::join(defs, ",") + ")");
- return {tempTable, tablePatchInserter(db, tempTable, keys)};
- }
+ std::pair<std::string, DB::ModifyCommandPtr>
+ namedTemp(DB::Connection * db, const std::string & tempTable, const std::map<std::string, const std::string> & cols)
+ {
+ std::set<std::string> keys;
+ std::set<std::string> defs;
+ for (const auto & c : cols) {
+ keys.insert(c.first);
+ defs.insert(c.first + " " + c.second);
+ }
+ db->execute("CREATE TEMPORARY TABLE " + tempTable + "(" + boost::join(defs, ",") + ")");
+ return {tempTable, tablePatchInserter(db, tempTable, keys)};
+ }
- void
- drop(DB::Connection * db, const std::string & table)
- {
- db->execute("DROP TABLE " + table);
- }
+ void
+ drop(DB::Connection * db, const std::string & table)
+ {
+ db->execute("DROP TABLE " + table);
+ }
- DB::ModifyCommandPtr
- tablePatchInserter(DB::Connection * dbc, const DB::TablePatch & p)
- {
- return tablePatchInserter(dbc, p.src, p.cols);
- }
- DB::ModifyCommandPtr
- tablePatchInserter(DB::Connection * dbc, const std::string & t, const std::set<std::string> & c)
- {
- return dbc->modify("INSERT INTO " + t + "(" + boost::algorithm::join(c, ", ") + ") VALUES("
- + boost::algorithm::join(std::vector<std::string>(c.size(), "?"), ", ") + ")");
- }
- }
+ DB::ModifyCommandPtr
+ tablePatchInserter(DB::Connection * dbc, const DB::TablePatch & p)
+ {
+ return tablePatchInserter(dbc, p.src, p.cols);
+ }
+ DB::ModifyCommandPtr
+ tablePatchInserter(DB::Connection * dbc, const std::string & t, const std::set<std::string> & c)
+ {
+ return dbc->modify("INSERT INTO " + t + "(" + boost::algorithm::join(c, ", ") + ") VALUES("
+ + boost::algorithm::join(std::vector<std::string>(c.size(), "?"), ", ") + ")");
}
}
diff --git a/gentoobrowse-api/service/utils/dbUtils.h b/gentoobrowse-api/service/utils/dbUtils.h
index cdd9c07..dee1b2d 100644
--- a/gentoobrowse-api/service/utils/dbUtils.h
+++ b/gentoobrowse-api/service/utils/dbUtils.h
@@ -1,5 +1,4 @@
-#ifndef GENTOOBROWSE_API_SERVICE_DBUTILS_H
-#define GENTOOBROWSE_API_SERVICE_DBUTILS_H
+#pragma once
#include <IceUtil/Exception.h>
#include <IceUtil/Optional.h>
@@ -7,18 +6,11 @@
#include <connection.h>
#include <modifycommand.h>
-namespace Gentoo {
- namespace Utils {
- namespace Database {
- std::string emptyClone(DB::Connection *, const std::string &);
- std::pair<std::string, DB::ModifyCommandPtr> namedTemp(
- DB::Connection *, const std::string &, const std::map<std::string, const std::string> & cols);
- void drop(DB::Connection *, const std::string &);
- DB::ModifyCommandPtr tablePatchInserter(DB::Connection *, const DB::TablePatch &);
- DB::ModifyCommandPtr tablePatchInserter(
- DB::Connection *, const std::string &, const std::set<std::string> &);
- }
- }
+namespace Gentoo::Utils::Database {
+ std::string emptyClone(DB::Connection *, const std::string &);
+ std::pair<std::string, DB::ModifyCommandPtr> namedTemp(
+ DB::Connection *, const std::string &, const std::map<std::string, const std::string> & cols);
+ void drop(DB::Connection *, const std::string &);
+ DB::ModifyCommandPtr tablePatchInserter(DB::Connection *, const DB::TablePatch &);
+ DB::ModifyCommandPtr tablePatchInserter(DB::Connection *, const std::string &, const std::set<std::string> &);
}
-
-#endif
diff --git a/gentoobrowse-api/service/utils/ebuildCacheParser.cpp b/gentoobrowse-api/service/utils/ebuildCacheParser.cpp
index cd50d1a..c3fef41 100644
--- a/gentoobrowse-api/service/utils/ebuildCacheParser.cpp
+++ b/gentoobrowse-api/service/utils/ebuildCacheParser.cpp
@@ -1,36 +1,34 @@
#include "ebuildCacheParser.h"
-namespace Gentoo {
- namespace Utils {
- EbuildCacheParser::EbuildCacheParser(const std::filesystem::path & p) : AdHoc::FileUtils::MemMap(p)
- {
- auto chardata = sv();
- for (auto eq = chardata.find('='); eq != std::string_view::npos; eq = chardata.find('=')) {
- if (auto nl = chardata.find('\n', eq + 1); nl != std::string_view::npos) {
- kvs.insert({chardata.substr(0, eq), chardata.substr(eq + 1, nl - eq - 1)});
- chardata.remove_prefix(nl + 1);
- }
+namespace Gentoo::Utils {
+ EbuildCacheParser::EbuildCacheParser(const std::filesystem::path & p) : AdHoc::FileUtils::MemMap(p)
+ {
+ auto chardata = sv();
+ for (auto eq = chardata.find('='); eq != std::string_view::npos; eq = chardata.find('=')) {
+ if (auto nl = chardata.find('\n', eq + 1); nl != std::string_view::npos) {
+ kvs.insert({chardata.substr(0, eq), chardata.substr(eq + 1, nl - eq - 1)});
+ chardata.remove_prefix(nl + 1);
}
}
+ }
- std::optional<Glib::ustring>
- EbuildCacheParser::get(const std::string & key) const
- {
- auto kvi = kvs.find(key);
- if (kvi == kvs.end()) {
- return {};
- }
- return Glib::ustring(kvi->second.data(), kvi->second.length());
+ std::optional<Glib::ustring>
+ EbuildCacheParser::get(const std::string & key) const
+ {
+ auto kvi = kvs.find(key);
+ if (kvi == kvs.end()) {
+ return {};
}
+ return Glib::ustring(kvi->second.data(), kvi->second.length());
+ }
- std::optional<std::string_view>
- EbuildCacheParser::getRange(const std::string & key) const
- {
- auto kvi = kvs.find(key);
- if (kvi == kvs.end()) {
- return {};
- }
- return kvi->second;
+ std::optional<std::string_view>
+ EbuildCacheParser::getRange(const std::string & key) const
+ {
+ auto kvi = kvs.find(key);
+ if (kvi == kvs.end()) {
+ return {};
}
+ return kvi->second;
}
}
diff --git a/gentoobrowse-api/service/utils/ebuildCacheParser.h b/gentoobrowse-api/service/utils/ebuildCacheParser.h
index 4fed766..ee3977f 100644
--- a/gentoobrowse-api/service/utils/ebuildCacheParser.h
+++ b/gentoobrowse-api/service/utils/ebuildCacheParser.h
@@ -1,5 +1,4 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_EBUILDCACHEPARSER_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_EBUILDCACHEPARSER_H
+#pragma once
#include "wrap/ustring.h"
#include <fileUtils.h>
@@ -8,21 +7,17 @@
#include <optional>
#include <string_view>
-namespace Gentoo {
- namespace Utils {
- class EbuildCacheParser : public AdHoc::FileUtils::MemMap {
- public:
- typedef std::map<std::string_view, const std::string_view> KVs;
+namespace Gentoo::Utils {
+ class EbuildCacheParser : public AdHoc::FileUtils::MemMap {
+ public:
+ using KVs = std::map<std::string_view, const std::string_view, std::less<>>;
- explicit EbuildCacheParser(const std::filesystem::path & p);
+ explicit EbuildCacheParser(const std::filesystem::path & p);
- std::optional<Glib::ustring> get(const std::string & key) const;
- std::optional<std::string_view> getRange(const std::string & key) const;
+ [[nodiscard]] std::optional<Glib::ustring> get(const std::string & key) const;
+ [[nodiscard]] std::optional<std::string_view> getRange(const std::string & key) const;
- private:
- KVs kvs;
- };
- }
+ private:
+ KVs kvs;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/utils/entityWhereFilter.cpp b/gentoobrowse-api/service/utils/entityWhereFilter.cpp
index 1deb6ef..be74f2e 100644
--- a/gentoobrowse-api/service/utils/entityWhereFilter.cpp
+++ b/gentoobrowse-api/service/utils/entityWhereFilter.cpp
@@ -2,57 +2,55 @@
#include <buffer.h>
#include <command.h>
-namespace Gentoo {
- namespace Utils {
- template<typename T> EntityWhereFilter<T>::EntityWhereFilter(const std::string & en) : entityColName(en) { }
+namespace Gentoo::Utils {
+ template<typename T> EntityWhereFilter<T>::EntityWhereFilter(std::string en) : entityColName(std::move(en)) { }
- template<typename T>
- EntityWhereFilter<T>::EntityWhereFilter(const std::string & en, const T & e) : entityColName(en)
- {
- entityIds.insert(e);
- }
+ template<typename T>
+ EntityWhereFilter<T>::EntityWhereFilter(std::string en, T e) :
+ entityIds {std::move(e)}, entityColName(std::move(en))
+ {
+ }
- template<typename T>
- EntityWhereFilter<T>::EntityWhereFilter(const std::string & en, const EntityIds & e) :
- entityIds(e), entityColName(en)
- {
- }
+ template<typename T>
+ EntityWhereFilter<T>::EntityWhereFilter(std::string en, EntityIds e) :
+ entityIds(std::move(e)), entityColName(std::move(en))
+ {
+ }
- template<typename T>
- void
- EntityWhereFilter<T>::writeSql(AdHoc::Buffer & sql)
- {
- sql.appendbf("a.%s IN (", entityColName);
- for (auto ei = entityIds.begin(); ei != entityIds.end(); ++ei) {
- if (ei != entityIds.begin()) {
- sql.append(", ?");
- }
- else {
- sql.append("?");
- }
+ template<typename T>
+ void
+ EntityWhereFilter<T>::writeSql(AdHoc::Buffer & sql)
+ {
+ sql.appendbf("a.%s IN (", entityColName);
+ for (auto ei = entityIds.begin(); ei != entityIds.end(); ++ei) {
+ if (ei != entityIds.begin()) {
+ sql.append(", ?");
}
- sql.append(")");
- }
-
- template<>
- void
- EntityWhereFilter<int64_t>::bindParams(DB::Command * c, unsigned int & offset)
- {
- for (const auto & entityId : entityIds) {
- c->bindParamI(offset++, entityId);
+ else {
+ sql.append("?");
}
}
+ sql.append(")");
+ }
- template<>
- void
- EntityWhereFilter<std::string>::bindParams(DB::Command * c, unsigned int & offset)
- {
- for (const auto & entityId : entityIds) {
- c->bindParamS(offset++, entityId);
- }
+ template<>
+ void
+ EntityWhereFilter<int64_t>::bindParams(DB::Command * c, unsigned int & offset)
+ {
+ for (const auto & entityId : entityIds) {
+ c->bindParamI(offset++, entityId);
}
+ }
- template class EntityWhereFilter<int64_t>;
- template class EntityWhereFilter<std::string>;
+ template<>
+ void
+ EntityWhereFilter<std::string>::bindParams(DB::Command * c, unsigned int & offset)
+ {
+ for (const auto & entityId : entityIds) {
+ c->bindParamS(offset++, entityId);
+ }
}
+
+ template class EntityWhereFilter<int64_t>;
+ template class EntityWhereFilter<std::string>;
}
diff --git a/gentoobrowse-api/service/utils/entityWhereFilter.h b/gentoobrowse-api/service/utils/entityWhereFilter.h
index 0c172dd..ccb92a0 100644
--- a/gentoobrowse-api/service/utils/entityWhereFilter.h
+++ b/gentoobrowse-api/service/utils/entityWhereFilter.h
@@ -1,26 +1,21 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_ENTITYWHEREFILTER_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_ENTITYWHEREFILTER_H
+#pragma once
#include <set>
#include <sqlWriter.h>
-namespace Gentoo {
- namespace Utils {
- template<typename T> class EntityWhereFilter : public DB::SqlWriter {
- public:
- typedef std::set<T> EntityIds;
+namespace Gentoo::Utils {
+ template<typename T> class EntityWhereFilter : public DB::SqlWriter {
+ public:
+ using EntityIds = std::set<T>;
- explicit EntityWhereFilter(const std::string & en);
- EntityWhereFilter(const std::string & en, const T & e);
- EntityWhereFilter(const std::string & en, const EntityIds & e);
+ explicit EntityWhereFilter(std::string en);
+ EntityWhereFilter(std::string en, T e);
+ EntityWhereFilter(std::string en, EntityIds e);
- void writeSql(AdHoc::Buffer & sql) override;
- void bindParams(DB::Command * c, unsigned int & offset) override;
+ void writeSql(AdHoc::Buffer & sql) override;
+ void bindParams(DB::Command * c, unsigned int & offset) override;
- EntityIds entityIds;
- const std::string entityColName;
- };
- }
+ EntityIds entityIds;
+ const std::string entityColName;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp
index b21edf2..c2e94b7 100644
--- a/gentoobrowse-api/service/utils/git.cpp
+++ b/gentoobrowse-api/service/utils/git.cpp
@@ -4,99 +4,88 @@
#include <logger.h>
#include <maintenance.h>
-namespace Gentoo {
- namespace Utils {
- namespace Git {
- void
- throwError(void * const func, int err)
- {
-#if LIBGIT2_VER_MINOR >= 28
- const git_error * e = git_error_last();
-#else
- const git_error * e = giterr_last();
-#endif
- char ** fn = backtrace_symbols(&func, 1);
- assert(fn);
- assert(*fn);
- std::string funcName(*fn);
- free(fn);
- throw ::Gentoo::GitError(funcName, err, e->klass, e->message);
- }
+namespace Gentoo::Utils::Git {
+ void
+ throwError(void * const func, int err)
+ {
+ const git_error * e = git_error_last();
+ std::unique_ptr<char *, decltype(&free)> fn {backtrace_symbols(&func, 1), free};
+ assert(fn);
+ assert(*fn);
+ throw ::Gentoo::GitError(*fn, err, e->klass, e->message);
+ }
- std::string
- operator*(const git_oid & oid)
- {
- std::string str(GIT_OID_HEXSZ, ' ');
- git_oid_tostr(&str.front(), GIT_OID_HEXSZ + 1, &oid);
- return str;
- }
+ std::string
+ operator*(const git_oid & oid)
+ {
+ std::string str(GIT_OID_HEXSZ, ' ');
+ git_oid_tostr(&str.front(), GIT_OID_HEXSZ + 1, &oid);
+ return str;
+ }
- AdHocFormatter(RefSpec, "refs/heads/%?:refs/remotes/%?/%?");
- GitAnnotatedCommitPtr
- gitFetch(git_repository * repo, git_remote * remote, const char * remoteBranchName)
- {
- auto opts = gitSafeGet(git_fetch_init_options, static_cast<unsigned int>(GIT_FETCH_OPTIONS_VERSION));
- opts.prune = GIT_FETCH_PRUNE;
- opts.update_fetchhead = 1;
- auto localBranch = gitSafeGet(git_repository_head, git_reference_free, repo);
- auto localBranchName = gitSafeGet(git_branch_name, localBranch.get());
- auto refspec = RefSpec::get(localBranchName, git_remote_name(remote), remoteBranchName);
- char * s[] = {&refspec.front()};
- git_strarray refs = {s, 1};
- gitSafe(git_remote_fetch, remote, &refs, &opts, nullptr);
- return gitSafeGet(git_annotated_commit_from_revspec, git_annotated_commit_free, repo, "FETCH_HEAD");
- }
+ AdHocFormatter(RefSpec, "refs/heads/%?:refs/remotes/%?/%?");
+ GitAnnotatedCommitPtr
+ gitFetch(git_repository * repo, git_remote * remote, const char * remoteBranchName)
+ {
+ auto opts = gitSafeGet(git_fetch_init_options, static_cast<unsigned int>(GIT_FETCH_OPTIONS_VERSION));
+ opts.prune = GIT_FETCH_PRUNE;
+ opts.update_fetchhead = 1;
+ auto localBranch = gitSafeGet(git_repository_head, git_reference_free, repo);
+ auto localBranchName = gitSafeGet(git_branch_name, localBranch.get());
+ auto refspec = RefSpec::get(localBranchName, git_remote_name(remote), remoteBranchName);
+ std::array<char *, 1> s {refspec.data()};
+ git_strarray refs = {s.data(), 1};
+ gitSafe(git_remote_fetch, remote, &refs, &opts, nullptr);
+ return gitSafeGet(git_annotated_commit_from_revspec, git_annotated_commit_free, repo, "FETCH_HEAD");
+ }
- AdHocFormatter(FastForward, "Performing fast-forward %? -> %?");
- AdHocFormatter(CheckOut, "Checking out %?");
- git_oid
- gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head)
- {
- auto log = LOGMANAGER()->getLogger(__FUNCTION__);
- // Test fast-forward is possible
- const git_annotated_commit * heads[] = {fetch_head};
- git_merge_analysis_t analysis = GIT_MERGE_ANALYSIS_NONE;
- git_merge_preference_t preference = GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY;
- gitSafe(git_merge_analysis, &analysis, &preference, repo, heads, 1LU);
+ AdHocFormatter(FastForward, "Performing fast-forward %? -> %?");
+ AdHocFormatter(CheckOut, "Checking out %?");
+ git_oid
+ gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head)
+ {
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ // Test fast-forward is possible
+ std::array<const git_annotated_commit *, 1> heads {fetch_head};
+ git_merge_analysis_t analysis = GIT_MERGE_ANALYSIS_NONE;
+ git_merge_preference_t preference = GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY;
+ gitSafe(git_merge_analysis, &analysis, &preference, repo, heads.data(), 1LU);
- auto head = gitSafeGet(git_repository_head, git_reference_free, repo);
- if (analysis == GIT_MERGE_ANALYSIS_UP_TO_DATE) {
- return *git_reference_target(head.get());
- }
- if (!(analysis & (GIT_MERGE_ANALYSIS_NORMAL | GIT_MERGE_ANALYSIS_FASTFORWARD))) {
- throw GitError("Merge analysis", 0, 0, "Could not fast-forward branch");
- }
+ auto head = gitSafeGet(git_repository_head, git_reference_free, repo);
+ if (analysis == GIT_MERGE_ANALYSIS_UP_TO_DATE) {
+ return *git_reference_target(head.get());
+ }
+ if (!(analysis & (GIT_MERGE_ANALYSIS_NORMAL | GIT_MERGE_ANALYSIS_FASTFORWARD))) {
+ throw GitError("Merge analysis", 0, 0, "Could not fast-forward branch");
+ }
- // Perform fast-forward
- auto fetch_head_id = *git_annotated_commit_id(fetch_head);
- auto fetch_head_object
- = gitSafeGet(git_object_lookup, git_object_free, repo, &fetch_head_id, GIT_OBJ_ANY);
- log->messagectf<FastForward>(
- IceTray::Logging::LogLevel::INFO, *git_reference_target(head.get()), fetch_head_id);
- gitSafeGet(git_reference_set_target, git_reference_free, head.get(), &fetch_head_id, "fast-forward");
+ // Perform fast-forward
+ auto fetch_head_id = *git_annotated_commit_id(fetch_head);
+ auto fetch_head_object = gitSafeGet(git_object_lookup, git_object_free, repo, &fetch_head_id, GIT_OBJ_ANY);
+ log->messagectf<FastForward>(
+ IceTray::Logging::LogLevel::INFO, *git_reference_target(head.get()), fetch_head_id);
+ gitSafeGet(git_reference_set_target, git_reference_free, head.get(), &fetch_head_id, "fast-forward");
- // Checkout new head
- log->messagectf<CheckOut>(IceTray::Logging::LogLevel::INFO, fetch_head_id);
- auto checkout_options = gitSafeGet(git_checkout_init_options, 0u + GIT_CHECKOUT_OPTIONS_VERSION);
- checkout_options.checkout_strategy = GIT_CHECKOUT_FORCE;
- gitSafe(git_checkout_head, repo, &checkout_options);
- return fetch_head_id;
- }
+ // Checkout new head
+ log->messagectf<CheckOut>(IceTray::Logging::LogLevel::INFO, fetch_head_id);
+ auto checkout_options = gitSafeGet(git_checkout_init_options, 0U + GIT_CHECKOUT_OPTIONS_VERSION);
+ checkout_options.checkout_strategy = GIT_CHECKOUT_FORCE;
+ gitSafe(git_checkout_head, repo, &checkout_options);
+ return fetch_head_id;
+ }
- AdHocFormatter(Updating, "Updating repository in %? from %?/%?");
- AdHocFormatter(UpdateComplete, "Update complete to %?");
- void
- updateRepository(const std::string & path, const std::string & upstream, const std::string & branch)
- {
- auto log = LOGMANAGER()->getLogger(__FUNCTION__);
- log->messagectf<Updating>(IceTray::Logging::LogLevel::INFO, path, upstream, branch);
- auto repo = gitSafeGet(git_repository_open, git_repository_free, path.c_str());
- auto origin = gitSafeGet(git_remote_lookup, git_remote_free, repo.get(), upstream.c_str());
- auto fetchHead = gitFetch(repo.get(), origin.get(), branch.c_str());
- auto oid = gitFastForward(repo.get(), fetchHead.get());
- log->messagectf<UpdateComplete>(IceTray::Logging::LogLevel::INFO, oid);
- }
- }
+ AdHocFormatter(Updating, "Updating repository in %? from %?/%?");
+ AdHocFormatter(UpdateComplete, "Update complete to %?");
+ void
+ updateRepository(const std::string & path, const std::string & upstream, const std::string & branch)
+ {
+ auto log = LOGMANAGER()->getLogger(__FUNCTION__);
+ log->messagectf<Updating>(IceTray::Logging::LogLevel::INFO, path, upstream, branch);
+ auto repo = gitSafeGet(git_repository_open, git_repository_free, path.c_str());
+ auto origin = gitSafeGet(git_remote_lookup, git_remote_free, repo.get(), upstream.c_str());
+ auto fetchHead = gitFetch(repo.get(), origin.get(), branch.c_str());
+ auto oid = gitFastForward(repo.get(), fetchHead.get());
+ log->messagectf<UpdateComplete>(IceTray::Logging::LogLevel::INFO, oid);
}
}
@@ -104,9 +93,9 @@ namespace std {
std::ostream &
operator<<(std::ostream & s, const git_oid & oid)
{
- char str[GIT_OID_HEXSZ + 1];
- git_oid_tostr(str, sizeof(str), &oid);
- s.write(str, GIT_OID_HEXSZ);
+ std::array<char, GIT_OID_HEXSZ + 1> str {};
+ git_oid_tostr(str.data(), str.size(), &oid);
+ s.write(str.data(), GIT_OID_HEXSZ);
return s;
}
}
diff --git a/gentoobrowse-api/service/utils/git.h b/gentoobrowse-api/service/utils/git.h
index b9191e1..d240b51 100644
--- a/gentoobrowse-api/service/utils/git.h
+++ b/gentoobrowse-api/service/utils/git.h
@@ -1,58 +1,51 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_GIT_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_GIT_H
+#pragma once
#include <git2.h>
#include <memory>
#include <ostream>
-namespace Gentoo {
- namespace Utils {
- namespace Git {
- void throwError(void * const func, int err);
-
- template<typename... P, typename... A>
- void
- gitSafe(int (*func)(P...), A... p)
- {
- if (int giterror_ = func(p...) < 0) {
- throwError(reinterpret_cast<void * const>(func), giterror_);
- }
- }
-
- template<typename T> using GitTPtr = std::unique_ptr<T, void (*)(T *)>;
-
- template<typename R, typename... P, typename... A>
- GitTPtr<R>
- gitSafeGet(int (*get)(R **, P...), void (*release)(R *), A... p)
- {
- R * r = nullptr;
- gitSafe(get, &r, p...);
- return GitTPtr<R>(r, release);
- }
-
- template<typename R, typename... P, typename... A>
- R
- gitSafeGet(int (*get)(R *, P...), A... p)
- {
- R r;
- gitSafe(get, &r, p...);
- return r;
- }
-
- std::string operator*(const git_oid &);
-
- using GitAnnotatedCommitPtr = GitTPtr<git_annotated_commit>;
- GitAnnotatedCommitPtr gitFetch(git_repository * repo, git_remote * remote, const char * branch);
-
- git_oid gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head);
-
- void updateRepository(const std::string & path, const std::string & upstream, const std::string & branch);
+namespace Gentoo::Utils::Git {
+ void throwError(void * const func, int err);
+
+ template<typename... P, typename... A>
+ void
+ gitSafe(int (*func)(P...), A... p)
+ {
+ if (int giterror_ = func(p...) < 0) {
+ throwError(reinterpret_cast<void * const>(func), giterror_);
}
}
+
+ template<typename T> using GitTPtr = std::unique_ptr<T, void (*)(T *)>;
+
+ template<typename R, typename... P, typename... A>
+ GitTPtr<R>
+ gitSafeGet(int (*get)(R **, P...), void (*release)(R *), A... p)
+ {
+ R * r = nullptr;
+ gitSafe(get, &r, p...);
+ return GitTPtr<R>(r, release);
+ }
+
+ template<typename R, typename... P, typename... A>
+ R
+ gitSafeGet(int (*get)(R *, P...), A... p)
+ {
+ R r {};
+ gitSafe(get, &r, p...);
+ return r;
+ }
+
+ std::string operator*(const git_oid &);
+
+ using GitAnnotatedCommitPtr = GitTPtr<git_annotated_commit>;
+ GitAnnotatedCommitPtr gitFetch(git_repository * repo, git_remote * remote, const char * branch);
+
+ git_oid gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head);
+
+ void updateRepository(const std::string & path, const std::string & upstream, const std::string & branch);
}
namespace std {
std::ostream & operator<<(std::ostream &, const git_oid &);
}
-
-#endif
diff --git a/gentoobrowse-api/service/utils/splitEbuildProps.cpp b/gentoobrowse-api/service/utils/splitEbuildProps.cpp
index ec9df6b..f9e1b6e 100644
--- a/gentoobrowse-api/service/utils/splitEbuildProps.cpp
+++ b/gentoobrowse-api/service/utils/splitEbuildProps.cpp
@@ -3,27 +3,23 @@
#include <buffer.h>
#include <command.h>
-namespace Gentoo {
- namespace Utils {
- SplitEbuildProps::SplitEbuildProps(
- const std::string & ce, int64_t e, const std::string & cp, const std::optional<Glib::ustring> & p) :
- entityId(e),
- colEntityName(ce), colPropName(cp), props(p)
- {
- }
+namespace Gentoo::Utils {
+ SplitEbuildProps::SplitEbuildProps(std::string ce, int64_t e, std::string cp, std::optional<Glib::ustring> p) :
+ entityId(e), colEntityName(std::move(ce)), colPropName(std::move(cp)), props(std::move(p))
+ {
+ }
- void
- SplitEbuildProps::writeSql(AdHoc::Buffer & sql)
- {
- sql.appendbf("(SELECT DISTINCT ?::int %s, trim(regexp_split_to_table(?, '\\s+'), '+') %s)", colEntityName,
- colPropName);
- }
+ void
+ SplitEbuildProps::writeSql(AdHoc::Buffer & sql)
+ {
+ sql.appendbf("(SELECT DISTINCT ?::int %s, trim(regexp_split_to_table(?, '\\s+'), '+') %s)", colEntityName,
+ colPropName);
+ }
- void
- SplitEbuildProps::bindParams(DB::Command * c, unsigned int & offset)
- {
- c->bindParamI(offset++, entityId);
- c->bindParamS(offset++, props);
- }
+ void
+ SplitEbuildProps::bindParams(DB::Command * c, unsigned int & offset)
+ {
+ c->bindParamI(offset++, entityId);
+ c->bindParamS(offset++, props);
}
}
diff --git a/gentoobrowse-api/service/utils/splitEbuildProps.h b/gentoobrowse-api/service/utils/splitEbuildProps.h
index 3945b6a..c413a51 100644
--- a/gentoobrowse-api/service/utils/splitEbuildProps.h
+++ b/gentoobrowse-api/service/utils/splitEbuildProps.h
@@ -1,25 +1,19 @@
-#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_SPLITEBUILDPROPS_H
-#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_SPLITEBUILDPROPS_H
+#pragma once
#include "wrap/ustring.h"
#include <optional>
#include <sqlWriter.h>
-namespace Gentoo {
- namespace Utils {
- class SplitEbuildProps : public DB::SqlWriter {
- public:
- SplitEbuildProps(
- const std::string & ce, int64_t e, const std::string & cp, const std::optional<Glib::ustring> & p);
+namespace Gentoo::Utils {
+ class SplitEbuildProps : public DB::SqlWriter {
+ public:
+ SplitEbuildProps(std::string ce, int64_t e, std::string cp, std::optional<Glib::ustring> p);
- void writeSql(AdHoc::Buffer & sql) override;
- void bindParams(DB::Command * c, unsigned int & offset) override;
+ void writeSql(AdHoc::Buffer & sql) override;
+ void bindParams(DB::Command * c, unsigned int & offset) override;
- const int64_t entityId;
- const std::string colEntityName, colPropName;
- const std::optional<Glib::ustring> props;
- };
- }
+ const int64_t entityId;
+ const std::string colEntityName, colPropName;
+ const std::optional<Glib::ustring> props;
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/utils/xmlUtils.cpp b/gentoobrowse-api/service/utils/xmlUtils.cpp
index 1ddc16e..195b054 100644
--- a/gentoobrowse-api/service/utils/xmlUtils.cpp
+++ b/gentoobrowse-api/service/utils/xmlUtils.cpp
@@ -1,22 +1,20 @@
#include "xmlUtils.h"
-namespace Gentoo {
- namespace Utils {
- XmlDoc::XmlDoc(const std::filesystem::path & path) : xmlpp::DomParser(path) { }
+namespace Gentoo::Utils {
+ XmlDoc::XmlDoc(const std::filesystem::path & path) : xmlpp::DomParser(path) { }
- std::optional<Glib::ustring>
- XmlDoc::getXPathValue(const Glib::ustring & xp)
- {
- auto ns = get_document()->get_root_node()->find(xp);
- if (ns.size() >= 1) {
- if (auto cn = dynamic_cast<const xmlpp::ContentNode *>(ns.front())) {
- return cn->get_content();
- }
+ std::optional<Glib::ustring>
+ XmlDoc::getXPathValue(const Glib::ustring & xp)
+ {
+ auto ns = get_document()->get_root_node()->find(xp);
+ if (ns.size() >= 1) {
+ if (auto cn = dynamic_cast<const xmlpp::ContentNode *>(ns.front())) {
+ return cn->get_content();
}
- else if (ns.size() > 1) {
- throw std::logic_error("Ambiguous xpath " + xp);
- }
- return {};
}
+ else if (ns.size() > 1) {
+ throw std::logic_error("Ambiguous xpath " + xp);
+ }
+ return {};
}
}
diff --git a/gentoobrowse-api/service/utils/xmlUtils.h b/gentoobrowse-api/service/utils/xmlUtils.h
index 51da33a..0e44a73 100644
--- a/gentoobrowse-api/service/utils/xmlUtils.h
+++ b/gentoobrowse-api/service/utils/xmlUtils.h
@@ -1,19 +1,14 @@
-#ifndef GENTOOBROWSE_API_SERVICE_XMLUTILS_H
-#define GENTOOBROWSE_API_SERVICE_XMLUTILS_H
+#pragma once
#include "wrap/domparser.h"
#include <filesystem>
#include <optional>
-namespace Gentoo {
- namespace Utils {
- class XmlDoc : public xmlpp::DomParser {
- public:
- explicit XmlDoc(const std::filesystem::path &);
+namespace Gentoo::Utils {
+ class XmlDoc : public xmlpp::DomParser {
+ public:
+ explicit XmlDoc(const std::filesystem::path &);
- std::optional<Glib::ustring> getXPathValue(const Glib::ustring &);
- };
- }
+ std::optional<Glib::ustring> getXPathValue(const Glib::ustring &);
+ };
}
-
-#endif
diff --git a/gentoobrowse-api/service/xsltStreamSerializer.cpp b/gentoobrowse-api/service/xsltStreamSerializer.cpp
index b7fd624..90dff01 100644
--- a/gentoobrowse-api/service/xsltStreamSerializer.cpp
+++ b/gentoobrowse-api/service/xsltStreamSerializer.cpp
@@ -26,8 +26,8 @@ namespace Gentoo {
return len;
}
- XsltStreamSerializer::XsltStreamSerializer(const IceTray::Mail::EmailPtr & e, xsltStylesheet * ss) :
- Slicer::XmlDocumentSerializer(doc), mail(e), doc(nullptr), stylesheet(ss)
+ XsltStreamSerializer::XsltStreamSerializer(IceTray::Mail::EmailPtr e, xsltStylesheet * ss) :
+ Slicer::XmlDocumentSerializer(doc), mail(std::move(e)), doc(nullptr), stylesheet(ss)
{
}
@@ -52,7 +52,7 @@ namespace Gentoo {
XsltStreamSerializer::getHtml(xmlDoc * result)
{
std::stringstream strm;
- xmlOutputBufferPtr buf = xmlOutputBufferCreateIO(xmlstrmwritecallback, xmlstrmclosecallback, &strm, NULL);
+ xmlOutputBufferPtr buf = xmlOutputBufferCreateIO(xmlstrmwritecallback, xmlstrmclosecallback, &strm, nullptr);
htmlDocContentDumpFormatOutput(buf, result, "utf-8", 0);
xmlOutputBufferClose(buf);
return std::make_shared<MultiPart>(Headers {}, "related",
@@ -70,21 +70,21 @@ namespace Gentoo {
XsltStreamSerializer::getText(xmlDoc * result)
{
std::stringstream strm;
- std::vector<std::string> callLynx;
- callLynx.push_back("/usr/bin/lynx");
- callLynx.push_back("-dump");
- callLynx.push_back("-stdin");
- std::string widthArg = "-width=78";
- callLynx.push_back(widthArg);
+ std::vector<std::string> callLynx {
+ "/usr/bin/lynx",
+ "-dump",
+ "-stdin",
+ "-width=78",
+ };
AdHoc::System::ProcessPipes fds(callLynx, true, true, false);
FILE * lynxIn = fdopen(fds.fdIn(), "w");
// Fixed encoding as we want the result to go back into a ustring
htmlNodeDumpFileFormat(lynxIn, result, xmlDocGetRootElement(result), "utf-8", 0);
fclose(lynxIn);
- char buf[1024];
+ std::array<char, BUFSIZ> buf {};
ssize_t r;
- while ((r = read(fds.fdOut(), buf, sizeof(buf))) > 0) {
- strm.write(buf, r);
+ while ((r = read(fds.fdOut(), buf.data(), buf.size())) > 0) {
+ strm.write(buf.data(), r);
}
int status;
waitpid(fds.pid(), &status, 0);
diff --git a/gentoobrowse-api/service/xsltStreamSerializer.h b/gentoobrowse-api/service/xsltStreamSerializer.h
index 5e73d59..9076a3f 100644
--- a/gentoobrowse-api/service/xsltStreamSerializer.h
+++ b/gentoobrowse-api/service/xsltStreamSerializer.h
@@ -1,6 +1,7 @@
#ifndef ICESPIDER_CORE_XSLTSTREAMSERIALIZER_H
#define ICESPIDER_CORE_XSLTSTREAMSERIALIZER_H
+#include <c++11Helpers.h>
#include <libxslt/transform.h>
#include <notifications.h>
#include <slicer/xml/serializer.h>
@@ -9,8 +10,9 @@
namespace Gentoo {
class DLL_PUBLIC XsltStreamSerializer : public Slicer::XmlDocumentSerializer {
public:
- XsltStreamSerializer(const IceTray::Mail::EmailPtr &, xsltStylesheet *);
- ~XsltStreamSerializer();
+ XsltStreamSerializer(IceTray::Mail::EmailPtr, xsltStylesheet *);
+ ~XsltStreamSerializer() override;
+ SPECIAL_MEMBERS_DELETE(XsltStreamSerializer);
void Serialize(Slicer::ModelPartForRootPtr mp) override;
diff --git a/gentoobrowse-api/unittests/mockDefs.cpp b/gentoobrowse-api/unittests/mockDefs.cpp
index 2152220..02ce761 100644
--- a/gentoobrowse-api/unittests/mockDefs.cpp
+++ b/gentoobrowse-api/unittests/mockDefs.cpp
@@ -54,8 +54,8 @@ TestClient::TestClient() :
BOOST_REQUIRE(u);
}
-std::pair<IceTray::Mime::TextPart *, IceTray::Mime::TextPart *>
-TestClient::humanReadableParts(IceTray::Mail::EmailPtr e)
+std::array<IceTray::Mime::TextPart *, 2>
+TestClient::humanReadableParts(const IceTray::Mail::EmailPtr & e) const
{
BOOST_REQUIRE(e);
@@ -77,7 +77,7 @@ TestClient::humanReadableParts(IceTray::Mail::EmailPtr e)
}
void
-TestClient::lintable_test_files(std::string_view name, IceTray::Mail::EmailPtr e)
+TestClient::lintable_test_files(std::string_view name, const IceTray::Mail::EmailPtr & e) const
{
auto [plainPart, htmlPart] = humanReadableParts(e);
diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h
index 327f293..d965a94 100644
--- a/gentoobrowse-api/unittests/mockDefs.h
+++ b/gentoobrowse-api/unittests/mockDefs.h
@@ -43,8 +43,8 @@ public:
IceTray::Mail::MailServerPtr ms;
Gentoo::UsersPrxPtr u;
- void lintable_test_files(std::string_view name, IceTray::Mail::EmailPtr e);
- std::pair<IceTray::Mime::TextPart *, IceTray::Mime::TextPart *> humanReadableParts(IceTray::Mail::EmailPtr e);
+ void lintable_test_files(std::string_view name, const IceTray::Mail::EmailPtr & e) const;
+ std::array<IceTray::Mime::TextPart *, 2> humanReadableParts(const IceTray::Mail::EmailPtr & e) const;
};
#define SQL_REQUIRE_EQUAL(sql, type, expected) \
diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp
index b90c659..0dc09c0 100644
--- a/gentoobrowse-api/unittests/testMaintenance.cpp
+++ b/gentoobrowse-api/unittests/testMaintenance.cpp
@@ -19,12 +19,12 @@ BOOST_FIXTURE_TEST_SUITE(maintenance, MaintenanceClientCombined)
const std::filesystem::path treeDir(binDir / "tree");
const std::filesystem::path fixturesDir(rootDir / "fixtures");
-void dumpDb(DB::ConnectionPtr db);
+static void dumpDb(const DB::ConnectionPtr & db);
void
-doRefreshPackageTree(DB::ConnectionPtr db, int64_t cats, int64_t devvcs, int64_t pkgs, int64_t ebs, int64_t ebus,
- int64_t ebas, int64_t pus, int64_t ug, int64_t ul, int64_t ugs, int64_t ugds, int64_t deps, int64_t rdeps,
- int64_t news, int64_t masks, int64_t ebuildMasks)
+doRefreshPackageTree(const DB::ConnectionPtr & db, int64_t cats, int64_t devvcs, int64_t pkgs, int64_t ebs,
+ int64_t ebus, int64_t ebas, int64_t pus, int64_t ug, int64_t ul, int64_t ugs, int64_t ugds, int64_t deps,
+ int64_t rdeps, int64_t news, int64_t masks, int64_t ebuildMasks)
{
dumpDb(db);
@@ -47,9 +47,9 @@ doRefreshPackageTree(DB::ConnectionPtr db, int64_t cats, int64_t devvcs, int64_t
}
void
-dumpDb(DB::ConnectionPtr db)
+dumpDb(const DB::ConnectionPtr & db)
{
-#if DUMBDB
+#if DUMPDB
db->execute("COPY gentoobrowse.categories TO '/tmp/categories.tsv'");
db->execute("COPY gentoobrowse.packages TO '/tmp/packages.tsv'");
db->execute("COPY gentoobrowse.ebuilds TO '/tmp/ebuilds.tsv'");
@@ -70,9 +70,9 @@ dumpDb(DB::ConnectionPtr db)
class M2 : public Gentoo::Service::Maintenance {
public:
- typedef std::map<std::filesystem::path, size_t> FileMap;
+ using FileMap = std::map<std::filesystem::path, size_t>;
- M2(const DB::ConnectionPoolPtr & d) : Gentoo::Service::Maintenance(d) { }
+ explicit M2(const DB::ConnectionPoolPtr & d) : Gentoo::Service::Maintenance(d) { }
void
applyDiffOfFolders(const std::filesystem::path & from, const std::filesystem::path & to) const
@@ -146,7 +146,7 @@ public:
};
#define BOOST_TEST_CONTEXT_VAR(VAR, EXPR) \
- BOOST_TEST_CONTEXT(#EXPR) for (auto VAR = EXPR, *__context__run = &VAR; __context__run; __context__run = NULL)
+ BOOST_TEST_CONTEXT(#EXPR) for (auto VAR = EXPR, *__context__run = &VAR; __context__run; __context__run = nullptr)
BOOST_AUTO_TEST_CASE(refreshPackageTree)
{
@@ -228,7 +228,7 @@ create_initial_commit(git_repository * repo)
BOOST_REQUIRE_EQUAL(0, git_repository_index(&index, repo));
BOOST_REQUIRE_EQUAL(0, git_index_write_tree(&tree_id, index));
BOOST_REQUIRE_EQUAL(0, git_tree_lookup(&tree, repo, &tree_id));
- BOOST_REQUIRE_EQUAL(0, git_commit_create_v(&commit_id, repo, "HEAD", sig, sig, NULL, "Initial commit", tree, 0));
+ BOOST_REQUIRE_EQUAL(0, git_commit_create_v(&commit_id, repo, "HEAD", sig, sig, nullptr, "Initial commit", tree, 0));
git_index_free(index);
git_tree_free(tree);
@@ -250,8 +250,8 @@ BOOST_AUTO_TEST_CASE(testUpdateGitRepository)
BOOST_REQUIRE_EQUAL(0, git_remote_create(&origin, repo, "origin", "http://git.randomdan.homeip.net/git/portage"));
git_remote_free(origin);
auto commitOid = create_initial_commit(repo);
- char commit[GIT_OID_HEXSZ + 1];
- git_oid_tostr(commit, GIT_OID_HEXSZ, &commitOid);
+ std::array<char, GIT_OID_HEXSZ + 1> commit {};
+ git_oid_tostr(commit.data(), commit.size(), &commitOid);
git_repository_free(repo);
git_libgit2_shutdown();
// Reference it
@@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(testUpdateGitRepository)
insRepo->bindParamS(1, testRepo.string());
insRepo->bindParamS(2, "origin");
insRepo->bindParamS(3, "master");
- insRepo->bindParamS(4, commit);
+ insRepo->bindParamS(4, commit.data());
insRepo->execute();
// Update
diff --git a/gentoobrowse-api/unittests/testNotifications.cpp b/gentoobrowse-api/unittests/testNotifications.cpp
index 1049b58..ff5bbc3 100644
--- a/gentoobrowse-api/unittests/testNotifications.cpp
+++ b/gentoobrowse-api/unittests/testNotifications.cpp
@@ -16,14 +16,14 @@ BOOST_GLOBAL_FIXTURE(Mail);
BOOST_FIXTURE_TEST_SUITE(tp, TestClient);
-bool
+static bool
isHtml(const std::string & body)
{
return body.find("<html") != std::string::npos;
}
-void
-commonAssert(IceTray::Mail::EmailPtr e)
+static void
+commonAssert(const IceTray::Mail::EmailPtr & e)
{
auto body = std::dynamic_pointer_cast<IceTray::Mime::BasicMultiPart>(e->content);
BOOST_REQUIRE(body);
@@ -76,10 +76,12 @@ BOOST_AUTO_TEST_CASE(testSignup)
}
}
+// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
BOOST_AUTO_TEST_CASE(testNews)
{
Gentoo::UserPtr u = std::make_shared<Gentoo::User>(
1, "testuser", "Test User", "test@user.com", "2017-10-01T12:34:56", IceUtil::None);
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
Gentoo::NewsContent nc {{std::make_shared<Gentoo::Category>(1, "app-test", "Test cat1"s),
std::make_shared<Gentoo::Category>(2, "sys-test", "Test cat2"s),
std::make_shared<Gentoo::Category>(3, "no-show", "Unused cat"s)},
@@ -102,8 +104,7 @@ BOOST_AUTO_TEST_CASE(testNews)
auto e = n->getNews(u, nc);
commonAssert(e);
lintable_test_files("news", e);
- auto [plainPart, htmlPart] = humanReadableParts(e);
- for (const auto text : {plainPart, htmlPart}) {
+ for (const auto text : humanReadableParts(e)) {
BOOST_REQUIRE(text);
BOOST_REQUIRE(text->payload.find("Latest news") != std::string::npos);
BOOST_REQUIRE(
@@ -112,6 +113,7 @@ BOOST_AUTO_TEST_CASE(testNews)
!= std::string::npos);
BOOST_REQUIRE(text->payload.find("no-show") == std::string::npos);
}
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp
index a530e34..ada192d 100644
--- a/gentoobrowse-api/unittests/testPortage.cpp
+++ b/gentoobrowse-api/unittests/testPortage.cpp
@@ -10,11 +10,10 @@ namespace std {
ostream &
operator<<(ostream & s, const Ice::optional<T> & o)
{
- if (o)
- s << *o;
- else
- s << "-empty optional-";
- return s;
+ if (o) {
+ return s << *o;
+ }
+ return s << "-empty optional-";
}
}
diff --git a/gentoobrowse-api/util/update.cpp b/gentoobrowse-api/util/update.cpp
index ab4d2a5..2af64a9 100644
--- a/gentoobrowse-api/util/update.cpp
+++ b/gentoobrowse-api/util/update.cpp
@@ -9,21 +9,23 @@ main(int c, char ** v)
{
std::string endpoint;
bool background, tree, bugs, sendNotifications, pull;
- po::options_description opts("Gentoo Browse Util::Update options");
- opts.add_options()("endpoint", po::value(&endpoint)->default_value("tcp -p 9001"), "Service endpoint")(
- "background,b", po::value(&background)->default_value(false)->zero_tokens(), "Background")("bugs",
- po::value(&bugs)->default_value(true),
- "Update bugs")("tree", po::value(&tree)->default_value(true), "Update tree")(
- "pull", po::value(&pull)->default_value(true), "Perform a git pull on repositories")("notifications",
- po::value(&sendNotifications)->default_value(true), "Send notification emails")("help,h", "Show help");
-
- po::variables_map vm;
- po::store(po::command_line_parser(c, v).options(opts).run(), vm);
- po::notify(vm);
-
- if (vm.count("help")) {
- std::cerr << opts << std::endl;
- exit(1);
+ {
+ po::options_description opts("Gentoo Browse Util::Update options");
+ opts.add_options()("endpoint", po::value(&endpoint)->default_value("tcp -p 9001"), "Service endpoint")(
+ "background,b", po::value(&background)->default_value(false)->zero_tokens(), "Background")("bugs",
+ po::value(&bugs)->default_value(true),
+ "Update bugs")("tree", po::value(&tree)->default_value(true), "Update tree")(
+ "pull", po::value(&pull)->default_value(true), "Perform a git pull on repositories")("notifications",
+ po::value(&sendNotifications)->default_value(true), "Send notification emails")("help,h", "Show help");
+
+ po::variables_map vm;
+ po::store(po::command_line_parser(c, v).options(opts).run(), vm);
+ po::notify(vm);
+
+ if (vm.count("help")) {
+ std::cerr << opts << std::endl;
+ exit(1);
+ }
}
auto ic = Ice::initialize(c, v);
@@ -31,12 +33,15 @@ main(int c, char ** v)
m->ice_ping();
std::vector<std::future<void>> jobs;
- if (bugs)
+ if (bugs) {
jobs.push_back(m->refreshBugsAsync());
- if (pull)
+ }
+ if (pull) {
m->updateRepositories();
- if (tree)
+ }
+ if (tree) {
jobs.push_back(m->refreshPackageTreeAsync());
+ }
int failures = 0;
if (!background) {