[hamster-applet] take into account also times in the fact if they somehow went there (allows once again passing in ju
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] take into account also times in the fact if they somehow went there (allows once again passing in ju
- Date: Sun, 23 Oct 2011 16:25:05 +0000 (UTC)
commit 8c434b84ebae018c37a0259e1a185e234f20e442
Author: Toms BauÄis <toms baugis gmail com>
Date: Sun Oct 23 10:49:41 2011 -0500
take into account also times in the fact if they somehow went there (allows once again passing in just the fully serialized fact)
src/hamster/db.py | 3 +++
src/hamster/storage.py | 14 ++++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/hamster/db.py b/src/hamster/db.py
index 33da02e..5ee7b05 100644
--- a/src/hamster/db.py
+++ b/src/hamster/db.py
@@ -499,6 +499,9 @@ class Storage(storage.Storage):
start_time = start_time,
end_time = end_time)
+ start_time = start_time or fact.start_time
+ end_time = end_time or fact.end_time
+
if not fact.activity or start_time is None: # sanity check
return 0
diff --git a/src/hamster/storage.py b/src/hamster/storage.py
index 0462115..10fd821 100644
--- a/src/hamster/storage.py
+++ b/src/hamster/storage.py
@@ -22,6 +22,7 @@ import dbus, dbus.service
import datetime as dt
from calendar import timegm
import gio
+from lib import stuff
def to_dbus_fact(fact):
"""Perform the conversion between fact database query and
@@ -106,21 +107,18 @@ class Storage(dbus.service.Object):
# facts
@dbus.service.method("org.gnome.Hamster", in_signature='siib', out_signature='i')
def AddFact(self, fact, start_time, end_time, temporary = False):
- start_time = start_time or None
- if start_time:
- start_time = dt.datetime.utcfromtimestamp(start_time)
+ start_time = dt.datetime.utcfromtimestamp(start_time) if start_time else None
+ end_time = dt.datetime.utcfromtimestamp(end_time) if end_time else None
- end_time = end_time or None
- if end_time:
- end_time = dt.datetime.utcfromtimestamp(end_time)
+ fact = stuff.Fact(fact, start_time = start_time, end_time = end_time)
+ start_time = fact.start_time or dt.datetime.now().replace(second = 0, microsecond = 0)
self.start_transaction()
- result = self.__add_fact(fact, start_time, end_time, temporary)
+ result = self.__add_fact(fact.serialized_name(), start_time, end_time, temporary)
self.end_transaction()
if result:
self.FactsChanged()
-
return result or 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]