diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-06 10:21:15 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-06 10:36:36 +0200 |
commit | f1e496f7c12ebc787ed47a4c048015f2098e65d9 (patch) | |
tree | ab903283757f4a19b4957992316a1eed4276091f /common/query.h | |
parent | c9a99b4f544adb3ae7eef8f07e0b52b714d919b1 (diff) | |
download | sink-f1e496f7c12ebc787ed47a4c048015f2098e65d9.tar.gz sink-f1e496f7c12ebc787ed47a4c048015f2098e65d9.zip |
Moved standard quries to a separate header.
Diffstat (limited to 'common/query.h')
-rw-r--r-- | common/query.h | 46 |
1 files changed, 1 insertions, 45 deletions
diff --git a/common/query.h b/common/query.h index 85307aa..00ae086 100644 --- a/common/query.h +++ b/common/query.h | |||
@@ -59,7 +59,6 @@ public: | |||
59 | Comparators comparator; | 59 | Comparators comparator; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | |||
63 | template <typename T> | 62 | template <typename T> |
64 | Query &request() | 63 | Query &request() |
65 | { | 64 | { |
@@ -289,7 +288,7 @@ public: | |||
289 | * a result set is generated containing all entries with the same value. | 288 | * a result set is generated containing all entries with the same value. |
290 | * | 289 | * |
291 | * Example: | 290 | * Example: |
292 | * For an input result set of one mail; return all emails with the same threadId. | 291 | * For an input set of one mail; return all emails with the same threadId. |
293 | */ | 292 | */ |
294 | class Bloom : public FilterStage { | 293 | class Bloom : public FilterStage { |
295 | public: | 294 | public: |
@@ -308,49 +307,6 @@ public: | |||
308 | mFilterStages << bloom; | 307 | mFilterStages << bloom; |
309 | } | 308 | } |
310 | 309 | ||
311 | //Query fixtures | ||
312 | |||
313 | /** | ||
314 | * Returns the complete thread, containing all mails from all folders. | ||
315 | */ | ||
316 | static Query completeThread(const ApplicationDomain::Mail &mail) | ||
317 | { | ||
318 | Sink::Query query; | ||
319 | if (!mail.resourceInstanceIdentifier().isEmpty()) { | ||
320 | query.resourceFilter(mail.resourceInstanceIdentifier()); | ||
321 | } | ||
322 | query.filter(mail.identifier()); | ||
323 | query.sort<ApplicationDomain::Mail::Date>(); | ||
324 | query.bloom<ApplicationDomain::Mail::ThreadId>(); | ||
325 | return query; | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * Returns thread leaders only, sorted by date. | ||
330 | */ | ||
331 | static Query threadLeaders(const ApplicationDomain::Folder &folder) | ||
332 | { | ||
333 | Sink::Query query; | ||
334 | if (!folder.resourceInstanceIdentifier().isEmpty()) { | ||
335 | query.resourceFilter(folder.resourceInstanceIdentifier()); | ||
336 | } | ||
337 | query.filter<ApplicationDomain::Mail::Folder>(folder); | ||
338 | query.sort<ApplicationDomain::Mail::Date>(); | ||
339 | query.reduce<ApplicationDomain::Mail::ThreadId>(Query::Reduce::Selector::max<ApplicationDomain::Mail::Date>()); | ||
340 | return query; | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * Outgoing mails. | ||
345 | */ | ||
346 | static Query outboxMails() | ||
347 | { | ||
348 | Sink::Query query; | ||
349 | query.resourceContainsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); | ||
350 | query.sort<ApplicationDomain::Mail::Date>(); | ||
351 | return query; | ||
352 | } | ||
353 | |||
354 | private: | 310 | private: |
355 | Filter mResourceFilter; | 311 | Filter mResourceFilter; |
356 | Filter mBaseFilterStage; | 312 | Filter mBaseFilterStage; |