1. Trevor Caira
  2. timebook

Commits

James Hartzell  committed f832a71

Fixed bug where 't n' was testing current sheet, not spec'd sheet, for error-checking

  • Participants
  • Parent commits 79e4ffc
  • Branches default

Comments (0)

Files changed (2)

File timebook/commands.py

View file
         ''', (args[0],))
 
     if opts.verbose:
-        entry_count = dbutil.get_entry_count(db)
+        entry_count = dbutil.get_entry_count(db, sheet)
         if entry_count == 0:
             print u'switched to empty timesheet "%s"' % sheet
         else:
     else:
         sheet = dbutil.get_current_sheet(db)
 
-    entry_count = dbutil.get_entry_count(db)
+    entry_count = dbutil.get_entry_count(db, sheet)
     if entry_count == 0:
         raise SystemExit, '%(prog)s: error: sheet is empty. For program \
 usage, see "%(prog)s --help".' % {'prog': os.path.basename(sys.argv[0])}

File timebook/dbutil.py

View file
     ''')
     return db.fetchone()
 
-def get_entry_count(db):
+def get_entry_count(db, sheet):
     db.execute(u'''
     select
         count(*)
     from
         entry e
-    inner join
-        meta m
-    on
-        key = 'current_sheet'
     where
-        sheet = m.value;
-    ''')
+        sheet = ?
+    ''', (sheet,))
     return db.fetchone()[0]
 
 def get_most_recent_clockout(db, sheet):