Changeset 3063
- Timestamp:
- 01/15/08 18:15:28 (1 year ago)
- Files:
-
- worklogplugin/0.11/worklog/api.py (modified) (4 diffs)
- worklogplugin/0.11/worklog/manager.py (modified) (6 diffs)
- worklogplugin/0.11/worklog/timeline_hook.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
worklogplugin/0.11/worklog/api.py
r2734 r3063 29 29 def __init__(self): 30 30 self.db_version_key = 'WorklogPlugin_Db_Version' 31 self.db_version = 231 self.db_version = 3 32 32 self.db_installed_version = None 33 33 … … 73 73 # Do the staged updates 74 74 try: 75 # This var is to deal with a problem case with pgsql and the "user" 76 # keyword. We need to skip over new installations but not upgrades 77 # for other db backends. 78 skip = False 79 75 80 if self.db_installed_version < 1: 76 81 print 'Creating work_log table' 77 82 cursor.execute('CREATE TABLE work_log (' 78 ' userTEXT,'83 'worker TEXT,' 79 84 'ticket INTEGER,' 80 85 'lastchange INTEGER,' … … 82 87 'endtime INTEGER' 83 88 ')') 89 skip = True 84 90 85 91 if self.db_installed_version < 2: … … 88 94 'ADD COLUMN comment TEXT') 89 95 90 #if self.db_installed_version < 3: 91 # print 'Updating work_log table (v3)' 96 if self.db_installed_version < 3: 97 print 'Updating work_log table (v3)' 98 if not skip: 99 # This whole section is just to rename the "user" column to "worker" 100 # This column used to be created in step 1 above, but we 101 # can no longer do this in order to support pgsql. 102 # This step is skipped if step 1 was also run (e.g. new installs) 103 # The below seems to be the only way to rename (or drop) a column on sqlite *sigh* 104 cursor.execute('CREATE TABLE work_log_tmp (' 105 'worker TEXT,' 106 'ticket INTEGER,' 107 'lastchange INTEGER,' 108 'starttime INTEGER,' 109 'endtime INTEGER,' 110 'comment TEXT' 111 ')') 112 cursor.execute('INSERT INTO work_log_tmp (worker, ticket, lastchange, starttime, endtime, comment) ' 113 'SELECT user, ticket, lastchange, starttime, endtime, comment FROM work_log') 114 cursor.execute('DROP TABLE work_log') 115 cursor.execute('ALTER TABLE work_log_tmp RENAME TO work_log') 116 117 #if self.db_installed_version < 4: 118 # print 'Updating work_log table (v4)' 92 119 # cursor.execute('...') 93 120 worklogplugin/0.11/worklog/manager.py
r2679 r3063 143 143 144 144 cursor = db.cursor() 145 cursor.execute('INSERT INTO work_log ( user, ticket, lastchange, starttime, endtime) '145 cursor.execute('INSERT INTO work_log (worker, ticket, lastchange, starttime, endtime) ' 146 146 'VALUES (%s, %s, %s, %s, %s)', 147 147 (self.authname, ticket, self.now, self.now, 0)) … … 172 172 cursor.execute('UPDATE work_log ' 173 173 'SET endtime=%s, lastchange=%s, comment=%s ' 174 'WHERE user=%s AND lastchange=%s AND endtime=0',174 'WHERE worker=%s AND lastchange=%s AND endtime=0', 175 175 (stoptime, stoptime, comment, self.authname, active['lastchange'])) 176 176 db.commit() … … 222 222 db = self.env.get_db_cnx() 223 223 cursor = db.cursor() 224 cursor.execute('SELECT user,starttime FROM work_log WHERE ticket=%s AND endtime=0', (ticket,))224 cursor.execute('SELECT worker,starttime FROM work_log WHERE ticket=%s AND endtime=0', (ticket,)) 225 225 try: 226 226 who,since = cursor.fetchone() … … 239 239 db = self.env.get_db_cnx() 240 240 cursor = db.cursor() 241 cursor.execute('SELECT MAX(lastchange) FROM work_log WHERE user=%s', (self.authname,))241 cursor.execute('SELECT MAX(lastchange) FROM work_log WHERE worker=%s', (self.authname,)) 242 242 row = cursor.fetchone() 243 243 if not row or not row[0]: … … 247 247 248 248 task = {} 249 cursor.execute('SELECT wl. user, wl.ticket, t.summary, wl.lastchange, wl.starttime, wl.endtime, wl.comment '249 cursor.execute('SELECT wl.worker, wl.ticket, t.summary, wl.lastchange, wl.starttime, wl.endtime, wl.comment ' 250 250 'FROM work_log wl ' 251 251 'LEFT JOIN ticket t ON wl.ticket=t.id ' 252 'WHERE wl. user=%s AND wl.lastchange=%s', (self.authname, lastchange))252 'WHERE wl.worker=%s AND wl.lastchange=%s', (self.authname, lastchange)) 253 253 254 254 for user,ticket,summary,lastchange,starttime,endtime,comment in cursor: … … 281 281 cursor = db.cursor() 282 282 if mode == 'user': 283 cursor.execute('SELECT wl. user, s.value, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment '283 cursor.execute('SELECT wl.worker, s.value, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment ' 284 284 'FROM work_log wl ' 285 285 'INNER JOIN ticket t ON wl.ticket=t.id ' 286 'LEFT JOIN session_attribute s ON wl. user=s.sid AND s.name=\'name\' '287 'WHERE wl. user=%s '286 'LEFT JOIN session_attribute s ON wl.worker=s.sid AND s.name=\'name\' ' 287 'WHERE wl.worker=%s ' 288 288 'ORDER BY wl.lastchange DESC', (self.authname,)) 289 289 elif mode == 'summary': 290 cursor.execute('SELECT wl. user, s.value, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment '291 'FROM (SELECT user,MAX(lastchange) lastchange FROM work_log GROUP BY user) wlt '292 'INNER JOIN work_log wl ON wlt. user=wl.user AND wlt.lastchange=wl.lastchange '290 cursor.execute('SELECT wl.worker, s.value, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment ' 291 'FROM (SELECT worker,MAX(lastchange) lastchange FROM work_log GROUP BY worker) wlt ' 292 'INNER JOIN work_log wl ON wlt.worker=wl.worker AND wlt.lastchange=wl.lastchange ' 293 293 'INNER JOIN ticket t ON wl.ticket=t.id ' 294 'LEFT JOIN session_attribute s ON wl. user=s.sid AND s.name=\'name\' '295 'ORDER BY wl.lastchange DESC, wl. user')294 'LEFT JOIN session_attribute s ON wl.worker=s.sid AND s.name=\'name\' ' 295 'ORDER BY wl.lastchange DESC, wl.worker') 296 296 else: 297 cursor.execute('SELECT wl. user, s.value, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment '297 cursor.execute('SELECT wl.worker, s.value, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment ' 298 298 'FROM work_log wl ' 299 299 'INNER JOIN ticket t ON wl.ticket=t.id ' 300 'LEFT JOIN session_attribute s ON wl. user=s.sid AND s.name=\'name\' '301 'ORDER BY wl.lastchange DESC, wl. user')300 'LEFT JOIN session_attribute s ON wl.worker=s.sid AND s.name=\'name\' ' 301 'ORDER BY wl.lastchange DESC, wl.worker') 302 302 303 303 rv = [] worklogplugin/0.11/worklog/timeline_hook.py
r3062 r3063 34 34 cursor = db.cursor() 35 35 36 cursor.execute("""SELECT wl. user,wl.ticket,wl.time,wl.starttime,wl.comment,wl.kind,t.summary,t.status,t.resolution,t.type36 cursor.execute("""SELECT wl.worker,wl.ticket,wl.time,wl.starttime,wl.comment,wl.kind,t.summary,t.status,t.resolution,t.type 37 37 FROM ( 38 38 39 SELECT user, ticket, starttime AS time, starttime, comment, 'start' AS kind39 SELECT worker, ticket, starttime AS time, starttime, comment, 'start' AS kind 40 40 FROM work_log 41 41 42 42 UNION 43 43 44 SELECT user, ticket, endtime AS time, starttime, comment, 'stop' AS kind44 SELECT worker, ticket, endtime AS time, starttime, comment, 'stop' AS kind 45 45 FROM work_log 46 46
