[hamster-applet] ability to specify category id when fetching facts
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Subject: [hamster-applet] ability to specify category id when fetching facts
- Date: Sun, 7 Jun 2009 11:21:40 -0400 (EDT)
commit 5c5f4b1f6c2c2ad296754977f47977ac4c24b653
Author: Toms Bauģis <toms baugis gmail com>
Date: Sun Jun 7 16:03:30 2009 +0100
ability to specify category id when fetching facts
---
hamster/db.py | 8 ++++++--
hamster/storage.py | 4 ++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/hamster/db.py b/hamster/db.py
index 51c647d..06d215e 100644
--- a/hamster/db.py
+++ b/hamster/db.py
@@ -345,7 +345,7 @@ class Storage(hamster.storage.Storage):
return self.__get_fact(fact_id)
- def __get_facts(self, date, end_date = None):
+ def __get_facts(self, date, end_date = None, category_id = None):
query = """
SELECT a.id AS id,
a.start_time AS start_time,
@@ -357,8 +357,12 @@ class Storage(hamster.storage.Storage):
LEFT JOIN activities b ON a.activity_id = b.id
LEFT JOIN categories c ON b.category_id = c.id
WHERE (a.end_time >= ? OR a.end_time IS NULL) AND a.start_time <= ?
- ORDER BY a.start_time
"""
+
+ if category_id:
+ query += " and b.category_id = %d" % category_id
+
+ query += " ORDER BY a.start_time"
end_date = end_date or date
#FIXME: add preference to set that
diff --git a/hamster/storage.py b/hamster/storage.py
index d83e1c4..05b1da1 100644
--- a/hamster/storage.py
+++ b/hamster/storage.py
@@ -47,8 +47,8 @@ class Storage(object):
self.dispatch('day_updated', fact['start_time'])
return result
- def get_facts(self, date, end_date = None):
- return self.__get_facts(date, end_date)
+ def get_facts(self, date, end_date = None, category_id = None):
+ return self.__get_facts(date, end_date, category_id)
def get_popular_categories(self):
return self.__get_popular_categories()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]