[billreminder] Use eagerload for querying bills; commented out several calls to timeline and chart widgets to get u



commit 74b19972ba842913717bbf764339860b7252897f
Author: Og B. Maciel <ogmaciel gnome org>
Date:   Mon Sep 28 23:50:31 2009 -0400

    Use eagerload for querying bills; commented out several calls to timeline and chart widgets to get ui to display records for the time being; treeview for bills needs to be changed to handle new datatypes.

 src/gui/maindialog.py       |    9 +++++----
 src/gui/widgets/viewbill.py |   10 +++++-----
 src/lib/actions.py          |    3 ++-
 3 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/gui/maindialog.py b/src/gui/maindialog.py
index 87a4dd8..2f64018 100644
--- a/src/gui/maindialog.py
+++ b/src/gui/maindialog.py
@@ -124,7 +124,7 @@ class MainDialog:
         # Timeline
         self.timelinebox = gtk.HBox(homogeneous=False, spacing=4)
         self.timeline = Timeline(callback=self.on_timeline_cb)
-        self.timeline.connect("value-changed", self._on_timeline_changed)
+        #self.timeline.connect("value-changed", self._on_timeline_changed)
         ## Pack it all up
         self.timelinebox.pack_start(self.timeline, expand=True, fill=True)
 
@@ -256,9 +256,9 @@ class MainDialog:
         # Populate treeview
         self._populateTreeView(records)
         # Update status bar
-        self._update_statusbar()
+        #self._update_statusbar()
         # populate chart
-        self._populate_chart(status, first, last)
+        #self._populate_chart(status, first, last)
 
         return len(records)
 
@@ -268,7 +268,7 @@ class MainDialog:
         formatted = [
             row.id,
             create_pixbuf(color="#000"),
-            row.category[0],
+            len(row.category) > 0 and row.category[0] or '',
             row.payee,
             row.dueDate,
             row.amount,
@@ -595,6 +595,7 @@ class MainDialog:
         self.timeline.refresh()
 
     def on_timeline_cb(self, date):
+        return None
         # TODO: Improve tooltip
         # TODO: Improve cache
         if not date in self._bullet_cache.keys():
diff --git a/src/gui/widgets/viewbill.py b/src/gui/widgets/viewbill.py
index a193c74..e4f9333 100644
--- a/src/gui/widgets/viewbill.py
+++ b/src/gui/widgets/viewbill.py
@@ -31,7 +31,7 @@ class ViewBill(GenericListView):
 
     def payee_cell_data_function(self, column, cell, model, iter):
         payee = model.get_value(iter, 3)
-        paid = int(model.get_value(iter, 7))
+        paid = model.get_value(iter, 7)
         if not paid:
             text = '<b>%(payee)s</b>'
         else:
@@ -39,11 +39,11 @@ class ViewBill(GenericListView):
         cell.set_property('markup', text % {'payee': payee})
 
     def duedate_cell_data_function(self, column, cell, model, iter):
-        dueDate = float(model.get_value (iter, 4))
+        dueDate = model.get_value (iter, 4)
         # Format the dueDate field
-        dueDate = datetime.datetime.fromtimestamp(dueDate)
+        #dueDate = datetime.datetime.fromtimestamp(dueDate)
         # TRANSLATORS: This is a date format. You can change the order.
-        dueDate = dueDate.strftime(_('%m/%d').encode('ASCII'))
+        #dueDate = dueDate.strftime(_('%m/%d').encode('ASCII'))
         cell.set_property('text', dueDate)
         cell.set_property('xalign', 0.5)
 
@@ -53,7 +53,7 @@ class ViewBill(GenericListView):
             amountDue = model.get_value(iter, 5).replace(',', '.')
         else:
             amountDue = ""
-        paid = int(model.get_value(iter, 7))
+        paid = model.get_value(iter, 7)
         amountDue = len(amountDue) > 0 and amountDue or 0
         amountDue = utils.float_to_currency(float(amountDue))
         if paid:
diff --git a/src/lib/actions.py b/src/lib/actions.py
index 9b15498..3e02de1 100644
--- a/src/lib/actions.py
+++ b/src/lib/actions.py
@@ -8,6 +8,7 @@ import dal
 import time
 import datetime
 from db.entities import Bill, Category
+from sqlalchemy.orm import eagerload
 from lib import common, scheduler
 from lib.utils import force_string
 from lib.utils import verify_dbus_service
@@ -28,7 +29,7 @@ class Actions(object):
 
         try:
             session = self.dal.Session()
-            records = session.query(Bill).filter(Bill.dueDate >= start).filter(Bill.dueDate <= end).all()
+            records = session.query(Bill).options(eagerload('category')).filter(Bill.dueDate >= start).filter(Bill.dueDate <= end).all()
         except Exception, e:
             print str(e)
             pass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]