[hamster-applet/gnome-2-28] fixes bug 596617 - be more careful when looking for end times of activities without one. also don't
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet/gnome-2-28] fixes bug 596617 - be more careful when looking for end times of activities without one. also don't
- Date: Tue, 29 Sep 2009 00:21:04 +0000 (UTC)
commit 7063b16b3c5b793f853438f8d07d8325bd599a3e
Author: Toms Bauģis <toms baugis gmail com>
Date: Tue Sep 29 01:18:36 2009 +0100
fixes bug 596617 - be more careful when looking for end times of activities without one. also don't die when editing past activity without end time
hamster/db.py | 13 +++++++++----
hamster/edit_activity.py | 2 ++
2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/hamster/db.py b/hamster/db.py
index 1ca4715..9f45076 100644
--- a/hamster/db.py
+++ b/hamster/db.py
@@ -271,21 +271,26 @@ class Storage(storage.Storage):
# we are checking if our start time is in the middle of anything
# or maybe there is something after us - so we know to adjust end time
+ # in the latter case go only few days ahead. everything else is madness, heh
query = """
SELECT a.*, b.name
FROM facts a
LEFT JOIN activities b on b.id = a.activity_id
- WHERE ((start_time < ? and end_time > ?) or start_time > ?)
+ WHERE ((start_time < ? and end_time > ?)
+ OR (start_time > ? and start_time < ?))
ORDER BY start_time
LIMIT 1
"""
- fact = self.fetchone(query, (start_time, start_time, start_time))
+ fact = self.fetchone(query, (start_time,
+ start_time,
+ start_time,
+ start_time + dt.timedelta(days=2)))
end_time = None
if fact:
- if fact["start_time"] < start_time and fact["end_time"]:
- #we are in middle of a task
+ if fact["end_time"] and start_time > fact["start_time"]:
+ #we are in middle of a fact - truncate it to our start
self.execute("UPDATE facts SET end_time=? WHERE id=?",
(start_time, fact["id"]))
end_time = fact["end_time"]
diff --git a/hamster/edit_activity.py b/hamster/edit_activity.py
index 61b9ddd..f6064e0 100644
--- a/hamster/edit_activity.py
+++ b/hamster/edit_activity.py
@@ -262,6 +262,8 @@ class Dayline(graphics.Area):
else:
if fact["start_time"].date() > dt.date.today() - dt.timedelta(days=1):
end_minutes = self._minutes_from_start(dt.datetime.now())
+ else:
+ end_minutes = start_minutes
if self.get_pixel(end_minutes) > 0 and \
self.get_pixel(start_minutes) < self.width:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]