summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/query.h11
-rw-r--r--sinksh/syntax_modules/sink_list.cpp7
2 files changed, 14 insertions, 4 deletions
diff --git a/common/query.h b/common/query.h
index 1e7b41d..fd79105 100644
--- a/common/query.h
+++ b/common/query.h
@@ -247,14 +247,19 @@ public:
247 //Potentially pass-in an identifier under which the result will be available in the result set. 247 //Potentially pass-in an identifier under which the result will be available in the result set.
248 }; 248 };
249 249
250 template <typename T> 250 Reduce &reduce(const QByteArray &name, const Reduce::Selector &s)
251 Reduce &reduce(const Reduce::Selector &s)
252 { 251 {
253 auto reduction = QSharedPointer<Reduce>::create(T::name, s); 252 auto reduction = QSharedPointer<Reduce>::create(name, s);
254 mFilterStages << reduction; 253 mFilterStages << reduction;
255 return *reduction; 254 return *reduction;
256 } 255 }
257 256
257 template <typename T>
258 Reduce &reduce(const Reduce::Selector &s)
259 {
260 return reduce(T::name, s);
261 }
262
258 /** 263 /**
259 * "Bloom" on a property. 264 * "Bloom" on a property.
260 * 265 *
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp
index 92c1e77..63ce527 100644
--- a/sinksh/syntax_modules/sink_list.cpp
+++ b/sinksh/syntax_modules/sink_list.cpp
@@ -92,7 +92,7 @@ QStringList printToList(const Sink::ApplicationDomain::ApplicationDomainType &o,
92bool list(const QStringList &args_, State &state) 92bool list(const QStringList &args_, State &state)
93{ 93{
94 if (args_.isEmpty()) { 94 if (args_.isEmpty()) {
95 state.printError(QObject::tr("Options: $type [--resource $resource] [--compact] [--filter $property=$value] [--id $id] [--showall|--show $property]")); 95 state.printError(QObject::tr("Options: $type [--resource $resource] [--compact] [--filter $property=$value] [--id $id] [--showall|--show $property] [--reduce $reduceProperty:$selectorProperty] [--sort $sortProperty] [--limit $count]"));
96 return false; 96 return false;
97 } 97 }
98 98
@@ -114,6 +114,11 @@ bool list(const QStringList &args_, State &state)
114 query.setSortProperty(options.options.value("sort").first().toUtf8()); 114 query.setSortProperty(options.options.value("sort").first().toUtf8());
115 } 115 }
116 116
117 if (options.options.contains("reduce")) {
118 auto value = options.options.value("reduce").first().toUtf8();
119 query.reduce(value.split(':').value(0), Sink::Query::Reduce::Selector(value.split(':').value(1), Sink::Query::Reduce::Selector::Max));
120 }
121
117 auto compact = options.options.contains("compact"); 122 auto compact = options.options.contains("compact");
118 if (!options.options.contains("showall")) { 123 if (!options.options.contains("showall")) {
119 if (options.options.contains("show")) { 124 if (options.options.contains("show")) {