Changeset 2349
- Timestamp:
- 06/28/07 09:23:54 (2 years ago)
- Files:
-
- timingandestimationplugin/branches/trac0.10/setup.py (modified) (2 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/api.py (modified) (8 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/dbhelper.py (modified) (2 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/migrate (added)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/migrate/__init__.py (added)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/migrate/upgrade4.py (added)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/reports.py (modified) (9 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/usermanual.py (modified) (3 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/webui.py (modified) (1 diff)
- timingandestimationplugin/branches/trac0.11/setup.py (modified) (2 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/api.py (modified) (8 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/dbhelper.py (modified) (2 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/migrate (added)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/migrate/__init__.py (added)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/migrate/upgrade4.py (added)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/reports.py (modified) (9 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/usermanual.py (modified) (3 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/webui.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
timingandestimationplugin/branches/trac0.10/setup.py
r2331 r2349 8 8 description='Plugin to make Trac support time estimation and tracking', 9 9 keywords='trac plugin estimation timetracking', 10 version='0.4. 2',10 version='0.4.3', 11 11 url='', 12 12 license='http://www.opensource.org/licenses/mit-license.php', … … 19 19 """, 20 20 packages=[PACKAGE], 21 package_data={PACKAGE : ['templates/*.cs', 'htdocs/*' ]},21 package_data={PACKAGE : ['templates/*.cs', 'htdocs/*', 'migrate/*.py']}, 22 22 entry_points={'trac.plugins': '%s = %s' % (PACKAGE, PACKAGE)}) 23 23 timingandestimationplugin/branches/trac0.10/timingandestimationplugin/api.py
r1840 r2349 83 83 """ 84 84 dbhelper.execute_non_query(self.env.get_db_cnx(), sql) 85 dbhelper.set_plugin_db_version(self.env.get_db_cnx); 85 dbhelper.migrate_up_to_version(self.env.get_db_cnx, dbhelper) 86 dbhelper.set_plugin_db_version(self.env.get_db_cnx) 86 87 87 88 def reports_need_upgrade(self): … … 91 92 return True 92 93 93 #make versions hash 94 _versions = dbhelper.get_result_set(self.env.get_db_cnx(), 95 """ 96 SELECT report as id, version, r.title as title 97 FROM report_version 98 JOIN report r ON r.Id = report_version.report 99 """) 94 #make versions hash 95 try: 96 _versions = dbhelper.get_result_set(self.env.get_db_cnx(),""" 97 SELECT report as id, version, r.title as title 98 FROM report_version 99 JOIN report r ON r.Id = report_version.report 100 WHERE tags LIKE '%T&E%' """) 101 except Exception: 102 return True; 100 103 versions = {} 104 105 if _versions.rows == None: 106 return True 107 101 108 for (id, version, title) in _versions.rows: 102 109 versions[title] = (id, version) 103 110 104 111 105 112 for report_group in all_reports: … … 132 139 FROM report_version 133 140 JOIN report r ON r.Id = report_version.report 141 WHERE tags LIKE '%T&E%' 134 142 """) 135 143 versions = {} … … 139 147 biggestId = dbhelper.get_scalar(self.env.get_db_cnx(), 140 148 "SELECT ID FROM report ORDER BY ID DESC LIMIT 1") 141 def insert_report_version(id, ver ):149 def insert_report_version(id, ver, tag): 142 150 sql = "DELETE FROM report_version WHERE report = %s;" 143 151 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, id ) 144 152 sql = """ 145 INSERT INTO report_version (report, version )146 VALUES (%s, %s );"""153 INSERT INTO report_version (report, version, tags) 154 VALUES (%s, %s, %s);""" 147 155 # print "about to insert report_version" 148 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, id, ver )156 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, id, ver, tag ) 149 157 # print "inserted report_version" 150 158 151 159 for report_group in all_reports: 152 160 rlist = report_group["reports"] 161 group_title = report_group["title"] 162 tag = "T&E %s" % group_title 153 163 for report in rlist: 154 164 title = report["title"] … … 164 174 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, 165 175 biggestId, title, report["sql"]) 166 insert_report_version(biggestId, new_version )176 insert_report_version(biggestId, new_version, tag) 167 177 168 178 report["reportnumber"] = biggestId … … 184 194 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, 185 195 report["sql"], report_id ) 186 insert_report_version( report_id, new_version )196 insert_report_version( report_id, new_version, tag ) 187 197 elif ver < new_version: 188 198 sql = """ … … 196 206 sql = """ 197 207 UPDATE report_version 198 SET version = %s 208 SET version = %s, tags = %s 209 199 210 WHERE report = %s 200 211 """ 201 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, new_version, report_id)212 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, new_version, tag, report_id) 202 213 203 214 def ticket_fields_need_upgrade(self): … … 303 314 304 315 305 306 316 317 318 timingandestimationplugin/branches/trac0.10/timingandestimationplugin/dbhelper.py
r1693 r2349 1 1 db_version_key = 'TimingAndEstimationPlugin_Db_Version'; 2 db_version = 32 db_version = 4 3 3 mylog = None; 4 4 … … 104 104 return ResultSet(get_all(db, sql, *params)) 105 105 106 def migrate_up_to_version( db_fn, helper ): 107 try: 108 start = int(get_plugin_db_version(db_fn())) 109 except Exception: 110 start = 1 111 end = db_version 112 r = range( start+1, end+1) 113 import migrate 114 for i in r: 115 key = "upgrade"+str(i) 116 try: 117 m = __import__("migrate."+key, globals(), locals(), ["up"]) 118 m.up(db_fn, helper) 119 except Exception, e: 120 print "no migration for %s %s %s "% (key, e.args, dir(e)) 121 122 106 123 class ResultSet: 107 124 """ the result of calling getResultSet """ timingandestimationplugin/branches/trac0.10/timingandestimationplugin/reports.py
r2331 r2349 9 9 "title":"Ticket Work Summary", 10 10 "reportnumber":None, 11 "version":1 3,11 "version":14, 12 12 "sql":""" 13 13 SELECT __ticket__ as __group__, __style__, __ticket__, … … 50 50 "title":"Milestone Work Summary", 51 51 "reportnumber":None, 52 "version":1 2,52 "version":13, 53 53 "sql":""" 54 54 … … 97 97 "title":"Developer Work Summary", 98 98 "reportnumber":None, 99 "version":1 2,99 "version":13, 100 100 "sql":""" 101 101 SELECT author as __group__,__style__, ticket, … … 138 138 "title": "Ticket Hours", 139 139 "reportnumber": None, 140 "version": 9,140 "version":10, 141 141 "sql": """ 142 142 SELECT __color__, __style__, ticket, summary, component ,version, severity, … … 207 207 "title": "Ticket Hours with Description", 208 208 "reportnumber": None, 209 "version":1 0,209 "version":11, 210 210 "sql": """ 211 211 SELECT __color__, __style__, ticket, summary, component ,version, severity, … … 285 285 "title":"Ticket Hours Grouped By Component", 286 286 "reportnumber":None, 287 "version": 9,287 "version":10, 288 288 "sql": """ 289 289 SELECT __color__, __group__, __style__, ticket, summary, __component__ ,version, … … 365 365 "title":"Ticket Hours Grouped By Component with Description", 366 366 "reportnumber":None, 367 "version": 8,367 "version":9, 368 368 "sql": """ 369 369 SELECT __color__, __group__, __style__, ticket, summary, __component__ , … … 440 440 "title":"Ticket Hours Grouped By Milestone", 441 441 "reportnumber":None, 442 "version": 9,442 "version":10, 443 443 "sql": """ 444 444 SELECT __color__, __group__, __style__, ticket, summary, component ,version, … … 516 516 "title":"Ticket Hours Grouped By MileStone with Description", 517 517 "reportnumber":None, 518 "version": 9,518 "version":10, 519 519 "sql": """ 520 520 SELECT __color__, __group__, __style__, ticket, summary, component ,version, severity, timingandestimationplugin/branches/trac0.10/timingandestimationplugin/usermanual.py
r2284 r2349 1 1 user_manual_title = "Timing and Estimation Plugin User Manual" 2 user_manual_version = 82 user_manual_version = 9 3 3 user_manual_wiki_title = "TimingAndEstimationPluginUserManual" 4 4 user_manual_content = """ … … 37 37 38 38 == Reports == 39 === Report Types === 39 40 We provide a few different reports for querying different types of data: 40 41 * '''Billing Reports''' Currently the billing reports are the only time based reports, and are therefore useful for getting an estimate what tickets had times (and totals), and which developers spent their time where. … … 49 50 * Ticket Hours Grouped By Milestone 50 51 * Ticket Hours Grouped By Milestone with Description 52 === Adding More Reports === 53 To add reports to the Management screen sections, you must run the following sql against your trac database 54 Remember to fill in the @reportID of the report you want to insert, and to select the insert statement for the section of your choice. 55 * '''INSERT INTO report_version (report, version, tags) VALUES ( @reportID , 1, 'Ticket/Hour Reports');''' 56 * '''INSERT INTO report_version (report, version, tags) VALUES ( @reportID , 1, 'Billing Reports');''' 57 58 === Removing a Report === 59 To remove reports from the Management page, run the following query. 60 Remember to fill in the @reportID of the report you want to insert, and to select the insert statement for the section of your choice. 61 * To remove for this version of the plugin (will be over written in future plugin upgrades) 62 * '''UPDATE report_version SET tags=!'' WHERE report = @reportID ;''' 63 * To remove permanently (wont be over written in future plugin upgrades) 64 * '''UPDATE report_version SET version=9999, tags=!'' WHERE report = @reportID ;''' 65 66 === TAKE NOTE === 67 '''The reports can only be called from the Management Page. They will not work from the Trac View Tickets page. (Due to the custom variables that need values).''' 51 68 52 69 == Future Improvements == timingandestimationplugin/branches/trac0.10/timingandestimationplugin/webui.py
r2291 r2349 22 22 new_reports = [] 23 23 sql = "SELECT id, title FROM report ORDER BY ID" 24 self.reportmap = dbhelper.get_all(self.env.get_db_cnx(), sql)[1]24 reportmap = dbhelper.get_all(self.env.get_db_cnx(), sql)[1] 25 25 26 26 for report_group in all_reports: 27 27 new_group = { "title" : report_group["title"] } 28 reports_list = report_group["reports"] 28 sql = """ 29 SELECT id, title 30 FROM report 31 JOIN report_version on report.id = report_version.report 32 WHERE tags LIKE '%%%s%%' 33 ORDER BY ID""" % report_group["title"] 34 reportmap = dbhelper.get_all(self.env.get_db_cnx(), sql)[1] 29 35 new_reports_list = [] 30 for report in reports_list:31 title = report["title"]36 37 for (r_id, r_name) in reportmap: 32 38 #find the report id for the name 33 try: 34 reportid = [r_id 35 for (r_id, r_name) in self.reportmap 36 if r_name == title][0] 37 38 new_report = {"title" : title, 39 "reportnumber" : reportid, 40 "href" : "%s/%s" % (req.href.report(), reportid)} 41 new_reports_list.extend([ new_report ]) 42 except: 43 pass 39 new_report = {"title" : r_name, 40 "reportnumber" : r_id, 41 "href" : "%s/%s" % (req.href.report(), r_id)} 42 new_reports_list.extend([ new_report ]) 44 43 new_group["reports"] = new_reports_list 45 44 new_reports.extend([new_group]) timingandestimationplugin/branches/trac0.11/setup.py
r2331 r2349 8 8 description='Plugin to make Trac support time estimation and tracking', 9 9 keywords='trac plugin estimation timetracking', 10 version='0.4. 2',10 version='0.4.3', 11 11 url='http://trac-hacks.org/wiki/TimingAndEstimationPlugin', 12 12 license='http://www.opensource.org/licenses/mit-license.php', … … 19 19 """, 20 20 packages=[PACKAGE], 21 package_data={PACKAGE : ['templates/*. html', 'htdocs/*']},21 package_data={PACKAGE : ['templates/*.cs', 'htdocs/*', 'migrate/*.py']}, 22 22 entry_points={'trac.plugins': '%s = %s' % (PACKAGE, PACKAGE)}) 23 23 timingandestimationplugin/branches/trac0.11/timingandestimationplugin/api.py
r2298 r2349 84 84 """ 85 85 dbhelper.execute_non_query(self.env.get_db_cnx(), sql) 86 dbhelper.set_plugin_db_version(self.env.get_db_cnx); 86 dbhelper.migrate_up_to_version(self.env.get_db_cnx, dbhelper) 87 dbhelper.set_plugin_db_version(self.env.get_db_cnx) 87 88 88 89 def reports_need_upgrade(self): … … 92 93 return True 93 94 94 #make versions hash 95 _versions = dbhelper.get_result_set(self.env.get_db_cnx(), 96 """ 97 SELECT report as id, version, r.title as title 98 FROM report_version 99 JOIN report r ON r.Id = report_version.report 100 """) 95 #make versions hash 96 try: 97 _versions = dbhelper.get_result_set(self.env.get_db_cnx(),""" 98 SELECT report as id, version, r.title as title 99 FROM report_version 100 JOIN report r ON r.Id = report_version.report 101 WHERE tags LIKE '%T&E%' """) 102 except Exception: 103 return True; 101 104 versions = {} 105 106 if _versions.rows == None: 107 return True 108 102 109 for (id, version, title) in _versions.rows: 103 110 versions[title] = (id, version) 104 111 105 112 106 113 for report_group in all_reports: … … 133 140 FROM report_version 134 141 JOIN report r ON r.Id = report_version.report 142 WHERE tags LIKE '%T&E%' 135 143 """) 136 144 versions = {} … … 140 148 biggestId = dbhelper.get_scalar(self.env.get_db_cnx(), 141 149 "SELECT ID FROM report ORDER BY ID DESC LIMIT 1") 142 def insert_report_version(id, ver ):150 def insert_report_version(id, ver, tag): 143 151 sql = "DELETE FROM report_version WHERE report = %s;" 144 152 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, id ) 145 153 sql = """ 146 INSERT INTO report_version (report, version )147 VALUES (%s, %s );"""154 INSERT INTO report_version (report, version, tags) 155 VALUES (%s, %s, %s);""" 148 156 # print "about to insert report_version" 149 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, id, ver )157 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, id, ver, tag ) 150 158 # print "inserted report_version" 151 159 152 160 for report_group in all_reports: 153 161 rlist = report_group["reports"] 162 group_title = report_group["title"] 163 tag = "T&E %s" % group_title 154 164 for report in rlist: 155 165 title = report["title"] … … 165 175 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, 166 176 biggestId, title, report["sql"]) 167 insert_report_version(biggestId, new_version )177 insert_report_version(biggestId, new_version, tag) 168 178 169 179 report["reportnumber"] = biggestId … … 185 195 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, 186 196 report["sql"], report_id ) 187 insert_report_version( report_id, new_version )197 insert_report_version( report_id, new_version, tag ) 188 198 elif ver < new_version: 189 199 sql = """ … … 197 207 sql = """ 198 208 UPDATE report_version 199 SET version = %s 209 SET version = %s, tags = %s 210 200 211 WHERE report = %s 201 212 """ 202 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, new_version, report_id)213 dbhelper.execute_non_query(self.env.get_db_cnx(), sql, new_version, tag, report_id) 203 214 204 215 def ticket_fields_need_upgrade(self): … … 304 315 305 316 306 307 317 318 319 timingandestimationplugin/branches/trac0.11/timingandestimationplugin/dbhelper.py
r1693 r2349 1 1 db_version_key = 'TimingAndEstimationPlugin_Db_Version'; 2 db_version = 32 db_version = 4 3 3 mylog = None; 4 4 … … 104 104 return ResultSet(get_all(db, sql, *params)) 105 105 106 def migrate_up_to_version( db_fn, helper ): 107 try: 108 start = int(get_plugin_db_version(db_fn())) 109 except Exception: 110 start = 1 111 end = db_version 112 r = range( start+1, end+1) 113 import migrate 114 for i in r: 115 key = "upgrade"+str(i) 116 try: 117 m = __import__("migrate."+key, globals(), locals(), ["up"]) 118 m.up(db_fn, helper) 119 except Exception, e: 120 print "no migration for %s %s %s "% (key, e.args, dir(e)) 121 122 106 123 class ResultSet: 107 124 """ the result of calling getResultSet """ timingandestimationplugin/branches/trac0.11/timingandestimationplugin/reports.py
r2331 r2349 9 9 "title":"Ticket Work Summary", 10 10 "reportnumber":None, 11 "version":1 3,11 "version":14, 12 12 "sql":""" 13 13 SELECT __ticket__ as __group__, __style__, __ticket__, … … 50 50 "title":"Milestone Work Summary", 51 51 "reportnumber":None, 52 "version":1 2,52 "version":13, 53 53 "sql":""" 54 54 … … 97 97 "title":"Developer Work Summary", 98 98 "reportnumber":None, 99 "version":1 2,99 "version":13, 100 100 "sql":""" 101 101 SELECT author as __group__,__style__, ticket, … … 138 138 "title": "Ticket Hours", 139 139 "reportnumber": None, 140 "version": 9,140 "version":10, 141 141 "sql": """ 142 142 SELECT __color__, __style__, ticket, summary, component ,version, severity, … … 207 207 "title": "Ticket Hours with Description", 208 208 "reportnumber": None, 209 "version":1 0,209 "version":11, 210 210 "sql": """ 211 211 SELECT __color__, __style__, ticket, summary, component ,version, severity, … … 285 285 "title":"Ticket Hours Grouped By Component", 286 286 "reportnumber":None, 287 "version": 9,287 "version":10, 288 288 "sql": """ 289 289 SELECT __color__, __group__, __style__, ticket, summary, __component__ ,version, … … 365 365 "title":"Ticket Hours Grouped By Component with Description", 366 366 "reportnumber":None, 367 "version": 8,367 "version":9, 368 368 "sql": """ 369 369 SELECT __color__, __group__, __style__, ticket, summary, __component__ , … … 440 440 "title":"Ticket Hours Grouped By Milestone", 441 441 "reportnumber":None, 442 "version": 9,442 "version":10, 443 443 "sql": """ 444 444 SELECT __color__, __group__, __style__, ticket, summary, component ,version, … … 516 516 "title":"Ticket Hours Grouped By MileStone with Description", 517 517 "reportnumber":None, 518 "version": 9,518 "version":10, 519 519 "sql": """ 520 520 SELECT __color__, __group__, __style__, ticket, summary, component ,version, severity, timingandestimationplugin/branches/trac0.11/timingandestimationplugin/usermanual.py
r2284 r2349 1 1 user_manual_title = "Timing and Estimation Plugin User Manual" 2 user_manual_version = 82 user_manual_version = 9 3 3 user_manual_wiki_title = "TimingAndEstimationPluginUserManual" 4 4 user_manual_content = """ … … 37 37 38 38 == Reports == 39 === Report Types === 39 40 We provide a few different reports for querying different types of data: 40 41 * '''Billing Reports''' Currently the billing reports are the only time based reports, and are therefore useful for getting an estimate what tickets had times (and totals), and which developers spent their time where. … … 49 50 * Ticket Hours Grouped By Milestone 50 51 * Ticket Hours Grouped By Milestone with Description 52 === Adding More Reports === 53 To add reports to the Management screen sections, you must run the following sql against your trac database 54 Remember to fill in the @reportID of the report you want to insert, and to select the insert statement for the section of your choice. 55 * '''INSERT INTO report_version (report, version, tags) VALUES ( @reportID , 1, 'Ticket/Hour Reports');''' 56 * '''INSERT INTO report_version (report, version, tags) VALUES ( @reportID , 1, 'Billing Reports');''' 57 58 === Removing a Report === 59 To remove reports from the Management page, run the following query. 60 Remember to fill in the @reportID of the report you want to insert, and to select the insert statement for the section of your choice. 61 * To remove for this version of the plugin (will be over written in future plugin upgrades) 62 * '''UPDATE report_version SET tags=!'' WHERE report = @reportID ;''' 63 * To remove permanently (wont be over written in future plugin upgrades) 64 * '''UPDATE report_version SET version=9999, tags=!'' WHERE report = @reportID ;''' 65 66 === TAKE NOTE === 67 '''The reports can only be called from the Management Page. They will not work from the Trac View Tickets page. (Due to the custom variables that need values).''' 51 68 52 69 == Future Improvements == timingandestimationplugin/branches/trac0.11/timingandestimationplugin/webui.py
r2298 r2349 22 22 new_reports = [] 23 23 sql = "SELECT id, title FROM report ORDER BY ID" 24 self.reportmap = dbhelper.get_all(self.env.get_db_cnx(), sql)[1]24 reportmap = dbhelper.get_all(self.env.get_db_cnx(), sql)[1] 25 25 26 26 for report_group in all_reports: 27 27 new_group = { "title" : report_group["title"] } 28 reports_list = report_group["reports"] 28 sql = """ 29 SELECT id, title 30 FROM report 31 JOIN report_version on report.id = report_version.report 32 WHERE tags LIKE '%%%s%%' 33 ORDER BY ID""" % report_group["title"] 34 reportmap = dbhelper.get_all(self.env.get_db_cnx(), sql)[1] 29 35 new_reports_list = [] 30 for report in reports_list:31 title = report["title"]36 37 for (r_id, r_name) in reportmap: 32 38 #find the report id for the name 33 try: 34 reportid = [r_id 35 for (r_id, r_name) in self.reportmap 36 if r_name == title][0] 37 38 new_report = {"title" : title, 39 "reportnumber" : reportid, 40 "href" : "%s/%s" % (req.href.report(), reportid)} 41 new_reports_list.extend([ new_report ]) 42 except: 43 pass 39 new_report = {"title" : r_name, 40 "reportnumber" : r_id, 41 "href" : "%s/%s" % (req.href.report(), r_id)} 42 new_reports_list.extend([ new_report ]) 44 43 new_group["reports"] = new_reports_list 45 44 new_reports.extend([new_group])
