[Zeitgeist] [Merge] lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist

2012-03-13 Thread Trever Fischer
Trever Fischer has proposed merging lp:~tdfischer/zeitgeist/common-where into 
lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)

For more details, see:
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270

Consolidates a lot of WHERE SQL generation into a common method for re-use by 
other components.
-- 
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270
Your team Zeitgeist Framework Team is requested to review the proposed merge of 
lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist.
=== modified file 'src/db-reader.vala'
--- src/db-reader.vala	2012-02-05 14:52:13 +
+++ src/db-reader.vala	2012-03-13 18:40:22 +
@@ -160,47 +160,10 @@
 return results;
 }
 
-public uint32[] find_event_ids (TimeRange time_range,
-GenericArrayEvent event_templates,
-uint storage_state, uint max_events, uint result_type,
+public uint32[] find_event_ids_for_clause (WhereClause where,
+uint max_events, uint result_type,
 BusName? sender=null) throws EngineError
 {
-
-WhereClause where = new WhereClause (WhereClause.Type.AND);
-
-/**
- * We are using the unary operator here to tell SQLite to not use
- * the index on the timestamp column at the first place. This is a
- * fix for (LP: #672965) based on some benchmarks, which suggest
- * a performance win, but we might not oversee all implications.
- * (See http://www.sqlite.org/optoverview.html, section 6.0).
- *-- Markus Korn, 29/11/2010
- */
-if (time_range.start != 0)
-where.add ((+timestamp = % + int64.FORMAT).printf(
-time_range.start));
-if (time_range.end != 0)
-where.add ((+timestamp = % + int64.FORMAT).printf(
-time_range.end));
-
-if (storage_state == StorageState.AVAILABLE ||
-storage_state == StorageState.NOT_AVAILABLE)
-{
-where.add ((subj_storage_state=? OR subj_storage_state IS NULL),
-storage_state.to_string ());
-}
-else if (storage_state != StorageState.ANY)
-{
-throw new EngineError.INVALID_ARGUMENT(
-Unknown storage state '%u'.printf(storage_state));
-}
-
-WhereClause tpl_conditions = get_where_clause_from_event_templates (
-event_templates);
-where.extend (tpl_conditions);
-//if (!where.may_have_results ())
-//return new uint32[0];
-
 string sql = SELECT id FROM event_view ;
 string where_sql = ;
 if (!where.is_empty ())
@@ -352,6 +315,20 @@
 return event_ids;
 }
 
+public uint32[] find_event_ids (TimeRange time_range,
+GenericArrayEvent event_templates,
+uint storage_state, uint max_events, uint result_type,
+BusName? sender=null) throws EngineError
+{
+WhereClause where = get_where_clause_for_query (time_range,
+event_templates, storage_state);
+
+//if (!where.may_have_results ())
+//return new uint32[0];
+
+return find_event_ids_for_clause (where, max_events, result_type);
+}
+
 public GenericArrayEvent? find_events (TimeRange time_range,
 GenericArrayEvent event_templates,
 uint storage_state, uint max_events, uint result_type,
@@ -361,6 +338,46 @@
 storage_state, max_events, result_type));
 }
 
+public WhereClause get_where_clause_for_query (TimeRange time_range,
+GenericArrayEvent event_templates, uint storage_state,
+BusName? sender=null) throws EngineError
+{
+WhereClause where = new WhereClause (WhereClause.Type.AND);
+
+/**
+ * We are using the unary operator here to tell SQLite to not use
+ * the index on the timestamp column at the first place. This is a
+ * fix for (LP: #672965) based on some benchmarks, which suggest
+ * a performance win, but we might not oversee all implications.
+ * (See http://www.sqlite.org/optoverview.html, section 6.0).
+ *-- Markus Korn, 29/11/2010
+ */
+if (time_range.start != 0)
+where.add ((+timestamp = % + int64.FORMAT).printf(
+time_range.start));
+if (time_range.end != 0)
+where.add ((+timestamp = % + int64.FORMAT).printf(
+time_range.end));
+
+if (storage_state == StorageState.AVAILABLE ||
+storage_state == StorageState.NOT_AVAILABLE)
+{
+where.add ((subj_storage_state=? OR subj_storage_state IS NULL),
+storage_state.to_string ());
+}
+else if (storage_state != StorageState.ANY)
+{
+throw new EngineError.INVALID_ARGUMENT(
+Unknown storage state '%u'.printf(storage_state));
+}
+
+WhereClause tpl_conditions

Re: [Zeitgeist] [Merge] lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist

2012-03-13 Thread Trever Fischer
Updated branch with removed arguments.
-- 
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


Re: [Zeitgeist] [Merge] lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist

2012-03-13 Thread Siegfried Gevatter
Review: Approve


-- 
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


[Zeitgeist] [Merge] lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist

2012-03-13 Thread Siegfried Gevatter
The proposal to merge lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist 
has been updated.

Status: Needs review = Approved

For more details, see:
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270
-- 
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


[Zeitgeist] [Merge] lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist

2012-03-13 Thread noreply
The proposal to merge lp:~tdfischer/zeitgeist/common-where into lp:zeitgeist 
has been updated.

Status: Approved = Merged

For more details, see:
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270
-- 
https://code.launchpad.net/~tdfischer/zeitgeist/common-where/+merge/97270
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp