From cd11c51cacc276ed8bde491d60e33bb120fec1bd Mon Sep 17 00:00:00 2001
From: Eli Ribble <eli@authentise.com>
Date: Tue, 28 Jun 2016 16:06:14 -0600
Subject: [PATCH] Add last updated field to accounts table

The query here isn't quite right, but I don't have a network connection
so I can't be bothered to do the actual research to find out how to do
the SQL correctly. Also, I don't really care until I can do more
updates, so that's fine too
---
 templates/accounts.html      | 2 +-
 vanth/platform/ofxaccount.py | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/templates/accounts.html b/templates/accounts.html
index 1f7fd15..fab87ba 100644
--- a/templates/accounts.html
+++ b/templates/accounts.html
@@ -9,7 +9,7 @@
     <td>{{ account.name }}</td>
     <td>{{ account.type }}</td>
     <td>{{ account.source.name }}</td>
-    <td>Never</td>
+    <td>{{ account.last_updated }}</td>
     <td>
       <form method="POST" action="/update/">
         <input type="hidden" name="account_uuid" value="{{ account.uuid }}"></input>
diff --git a/vanth/platform/ofxaccount.py b/vanth/platform/ofxaccount.py
index f931939..c75db77 100644
--- a/vanth/platform/ofxaccount.py
+++ b/vanth/platform/ofxaccount.py
@@ -18,8 +18,11 @@ def _select():
         vanth.tables.OFXAccount.c.uuid,
         vanth.tables.OFXSource.c.name.label('source.name'),
         vanth.tables.OFXSource.c.uuid.label('source.uuid'),
+        vanth.tables.OFXUpdate.c.created,
     ]).where(
         vanth.tables.OFXAccount.c.source == vanth.tables.OFXSource.c.uuid
+    ).where(
+        vanth.tables.OFXAccount.c.uuid == vanth.tables.OFXUpdate.c.ofxaccount
     )
 
 def _execute_and_convert(query):
@@ -28,6 +31,7 @@ def _execute_and_convert(query):
     return [{
         'account_id'    : result[vanth.tables.OFXAccount.c.account_id],
         'name'          : result[vanth.tables.OFXAccount.c.name],
+        'last_updated'  : result[vanth.tables.OFXUpdate.c.created],
         'password'      : result[vanth.tables.OFXAccount.c.password],
         'source'        : {
             'name'      : result[vanth.tables.OFXSource.c.name.label('source.name')],