Changeset 3784
- Timestamp:
- 06/04/08 08:30:58 (6 months ago)
- Files:
-
- timingandestimationplugin/branches/trac0.11/setup.py (modified) (2 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/api.py (modified) (22 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/dbhelper.py (modified) (15 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/reports.py (modified) (32 diffs)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/statuses.py (modified) (1 diff)
- timingandestimationplugin/branches/trac0.11/timingandestimationplugin/webui.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
timingandestimationplugin/branches/trac0.11/setup.py
r3521 r3784 8 8 description='Plugin to make Trac support time estimation and tracking', 9 9 keywords='trac plugin estimation timetracking', 10 version='0.6. 5',10 version='0.6.6', 11 11 url='http://www.trac-hacks.org/wiki/TimingAndEstimationPlugin', 12 12 license='http://www.opensource.org/licenses/mit-license.php', … … 35 35 ## trac-hacks user: masariello 36 36 ## Helped Get Reports working in postgres 37 ## and started moving toward generic work 37 ## and started moving toward generic work 38 38 ## rather than hours 39 39 timingandestimationplugin/branches/trac0.11/timingandestimationplugin/api.py
r3362 r3784 2 2 import dbhelper 3 3 import time 4 from tande_filters import * 4 from tande_filters import * 5 5 from ticket_daemon import * 6 6 from usermanual import * … … 10 10 from trac.env import IEnvironmentSetupParticipant 11 11 from trac.perm import IPermissionRequestor, PermissionSystem 12 from webui import * 12 from webui import * 13 13 from ticket_webui import * 14 14 from query_webui import * … … 20 20 ## report columns 21 21 ## id|author|title|query|description 22 22 23 23 class TimeTrackingSetupParticipant(Component): 24 24 """ This is the config that must be there for this plugin to work: 25 25 26 26 [ticket-custom] 27 27 totalhours = text … … 36 36 hours.value = 0 37 37 hours.label = Hours to Add 38 38 39 39 estimatedhours = text 40 40 estimatedhours.value = 0 41 41 estimatedhours.label = Estimated Hours? 42 42 43 43 """ 44 44 implements(IEnvironmentSetupParticipant) … … 46 46 db_version = None 47 47 db_installed_version = None 48 48 49 49 """Extension point interface for components that need to participate in the 50 50 creation and upgrading of Trac environments, for example to create … … 52 52 def __init__(self): 53 53 # Setup logging 54 dbhelper.mylog = self.log55 dbhelper.env = self.env56 54 self.statuses_key = 'T&E-statuses' 57 55 self.db_version_key = 'TimingAndEstimationPlugin_Db_Version' 58 56 self.db_version = 6 59 57 # Initialise database schema version tracking. 60 self.db_installed_version = dbhelper.get_system_value( \58 self.db_installed_version = dbhelper.get_system_value(self, \ 61 59 self.db_version_key) or 0 62 60 … … 65 63 if self.environment_needs_upgrade(None): 66 64 self.upgrade_environment(None) 67 65 68 66 69 67 def system_needs_upgrade(self): 70 68 return self.db_installed_version < self.db_version 71 69 72 70 def do_db_upgrade(self): 73 71 # Legacy support hack (supports upgrades from 0.1.6 to 0.1.7) 74 72 if self.db_installed_version == 0: 75 bill_date = dbhelper.db_table_exists( 'bill_date');76 report_version = dbhelper.db_table_exists( 'report_version');73 bill_date = dbhelper.db_table_exists(self, 'bill_date'); 74 report_version = dbhelper.db_table_exists(self, 'report_version'); 77 75 if bill_date and report_version: 78 76 self.db_installed_version = 1 79 77 # End Legacy support hack 80 78 81 79 82 80 if self.db_installed_version < 1: 83 81 print "Creating bill_date table" … … 89 87 ); 90 88 """ 91 dbhelper.execute_non_query( sql)92 93 89 dbhelper.execute_non_query(self, sql) 90 91 94 92 print "Creating report_version table" 95 93 sql = """ … … 100 98 ); 101 99 """ 102 dbhelper.execute_non_query(s ql)100 dbhelper.execute_non_query(self, sql) 103 101 104 102 if self.db_installed_version < 4: … … 107 105 ALTER TABLE report_version ADD COLUMN tags varchar(1024) null; 108 106 """ 109 dbhelper.execute_non_query(s ql)107 dbhelper.execute_non_query(self, sql) 110 108 111 109 if self.db_installed_version < 5: … … 116 114 sql = "DELETE FROM report " \ 117 115 "WHERE author=%s AND id IN (SELECT report FROM report_version)" 118 dbhelper.execute_non_query(s ql, 'Timing and Estimation Plugin')116 dbhelper.execute_non_query(self, sql, 'Timing and Estimation Plugin') 119 117 120 118 sql = "DROP TABLE report_version" 121 dbhelper.execute_non_query(s ql)122 123 #version 6 upgraded reports 124 119 dbhelper.execute_non_query(self, sql) 120 121 #version 6 upgraded reports 122 125 123 # This statement block always goes at the end this method 126 dbhelper.set_system_value(self .db_version_key, self.db_version)124 dbhelper.set_system_value(self, self.db_version_key, self.db_version) 127 125 self.db_installed_version = self.db_version 128 126 129 127 def reports_need_upgrade(self): 130 128 mgr = CustomReportManager(self.env, self.log) … … 151 149 self.log.debug ("T&E needs upgrades for the following reports: %s" % diff ) 152 150 return len(diff) > 0 153 151 154 152 def do_reports_upgrade(self, force=False): 155 153 self.log.debug( "Beginning Reports Upgrade"); 156 154 mgr = CustomReportManager(self.env, self.log) 157 statuses = get_statuses(self .config, self.env)155 statuses = get_statuses(self) 158 156 stat_vars = status_variables(statuses) 159 157 160 158 for report_group in all_reports: 161 159 rlist = report_group["reports"] … … 164 162 title = report["title"] 165 163 new_version = report["version"] 166 164 167 165 sql = report["sql"].replace('#STATUSES#', stat_vars) 168 166 mgr.add_report(report["title"], "Timing and Estimation Plugin", \ … … 175 173 ticket_custom = "ticket-custom" 176 174 return not ( self.config.get( ticket_custom, "totalhours" ) and \ 177 175 178 176 #self.config.get( ticket_custom, "billable" ) and \ 179 177 #self.config.get( ticket_custom, "billable.order") and \ … … 187 185 188 186 self.config.get( ticket_custom, "estimatedhours")) 189 187 190 188 def do_ticket_field_upgrade(self): 191 189 ticket_custom = "ticket-custom" 192 190 193 191 self.config.set(ticket_custom,"totalhours", "text") 194 192 if not self.config.get( ticket_custom, "totalhours.order") : 195 193 self.config.set(ticket_custom,"totalhours.order", "4") 196 194 self.config.set(ticket_custom,"totalhours.value", "0") 197 self.config.set(ticket_custom,"totalhours.label", "Total Hours") 195 self.config.set(ticket_custom,"totalhours.label", "Total Hours") 198 196 199 197 self.config.set(ticket_custom,"billable", "checkbox") … … 202 200 self.config.set(ticket_custom,"billable.order", "3") 203 201 self.config.set(ticket_custom,"billable.label", "Billable?") 204 202 205 203 self.config.set(ticket_custom,"hours", "text") 206 204 self.config.set(ticket_custom,"hours.value", "0") … … 208 206 self.config.set(ticket_custom,"hours.order", "2") 209 207 self.config.set(ticket_custom,"hours.label", "Add Hours to Ticket") 210 208 211 209 self.config.set(ticket_custom,"estimatedhours", "text") 212 210 self.config.set(ticket_custom,"estimatedhours.value", "0") … … 218 216 219 217 def needs_user_man(self): 220 maxversion = dbhelper.get_scalar( "SELECT MAX(version) FROM wiki WHERE name like %s", 0,218 maxversion = dbhelper.get_scalar(self, "SELECT MAX(version) FROM wiki WHERE name like %s", 0, 221 219 user_manual_wiki_title) 222 220 if (not maxversion) or maxversion < user_manual_version: … … 231 229 VALUES ( %s, %s, %s, 'Timing and Estimation Plugin', '127.0.0.1', %s,'',0) 232 230 """ 233 dbhelper.execute_non_query(s ql,231 dbhelper.execute_non_query(self, sql, 234 232 user_manual_wiki_title, 235 233 user_manual_version, 236 234 when, 237 235 user_manual_content) 238 239 236 237 240 238 def environment_needs_upgrade(self, db): 241 239 """Called when Trac checks whether the environment needs to be upgraded. 242 240 243 241 Should return `True` if this participant needs an upgrade to be 244 242 performed, `False` otherwise. … … 255 253 (self.have_statuses_changed()) or \ 256 254 (self.ticket_fields_need_upgrade()) or \ 257 (self.needs_user_man()) 258 255 (self.needs_user_man()) 256 259 257 def upgrade_environment(self, db): 260 258 """Actually perform an environment upgrade. 261 259 262 260 Implementations of this method should not commit any database 263 261 transactions. This is done implicitly after all participants have … … 272 270 p("Upgrading reports") 273 271 self.do_reports_upgrade(force=self.have_statuses_changed()) 274 272 275 273 #make sure we upgrade the statuses string so that we dont need to always rebuild the 276 274 # reports 277 stats = get_statuses(self .config, self.env)275 stats = get_statuses(self) 278 276 val = ','.join(list(stats)) 279 dbhelper.set_system_value(self .statuses_key, val)280 277 dbhelper.set_system_value(self, self.statuses_key, val) 278 281 279 if self.ticket_fields_need_upgrade(): 282 280 p("Upgrading fields") … … 292 290 if we have different ones, throw return true 293 291 """ 294 s = dbhelper.get_system_value(self .statuses_key)292 s = dbhelper.get_system_value(self, self.statuses_key) 295 293 if not s: 296 294 return True 297 sys_stats = get_statuses(self .config, self.env)295 sys_stats = get_statuses(self) 298 296 s = s.split(',') 299 297 sys_stats.symmetric_difference_update(s) timingandestimationplugin/branches/trac0.11/timingandestimationplugin/dbhelper.py
r3119 r3784 1 mylog = None;2 env = None;3 1 4 def get_all( sql, *params):2 def get_all(com, sql, *params): 5 3 """Executes the query and returns the (description, data)""" 6 db = env.get_db_cnx()4 db = com.env.get_db_cnx() 7 5 cur = db.cursor() 8 6 desc = None … … 14 12 db.commit(); 15 13 except Exception, e: 16 mylog.error('There was a problem executing sql:%s \n \14 com.log.error('There was a problem executing sql:%s \n \ 17 15 with parameters:%s\nException:%s'%(sql, params, e)); 18 16 db.rollback(); … … 21 19 except: 22 20 pass 23 21 24 22 return (desc, data) 25 23 26 def execute_non_query( sql, *params):24 def execute_non_query(com, sql, *params): 27 25 """Executes the query on the given project""" 28 db = env.get_db_cnx()26 db = com.env.get_db_cnx() 29 27 cur = db.cursor() 30 28 try: … … 32 30 db.commit() 33 31 except Exception, e: 34 mylog.error('There was a problem executing sql:%s \n \32 com.log.error('There was a problem executing sql:%s \n \ 35 33 with parameters:%s\nException:%s'%(sql, params, e)); 36 34 db.rollback(); … … 39 37 except: 40 38 pass 41 42 def get_first_row( sql,*params):39 40 def get_first_row(com, sql,*params): 43 41 """ Returns the first row of the query results as a tuple of values (or None)""" 44 db = env.get_db_cnx()42 db = com.env.get_db_cnx() 45 43 cur = db.cursor() 46 44 data = None; … … 50 48 db.commit(); 51 49 except Exception, e: 52 mylog.error('There was a problem executing sql:%s \n \50 com.log.error('There was a problem executing sql:%s \n \ 53 51 with parameters:%s\nException:%s'%(sql, params, e)); 54 52 db.rollback() … … 59 57 return data; 60 58 61 def get_scalar( sql, col=0, *params):59 def get_scalar(com, sql, col=0, *params): 62 60 """ Gets a single value (in the specified column) from the result set of the query""" 63 data = get_first_row( sql, *params);61 data = get_first_row(com, sql, *params); 64 62 if data: 65 63 return data[col] … … 67 65 return None; 68 66 69 def execute_in_trans( *args):70 db = env.get_db_cnx()67 def execute_in_trans(com, *args): 68 db = com.env.get_db_cnx() 71 69 cur = db.cursor() 72 70 result = True … … 76 74 db.commit() 77 75 except Exception, e: 78 mylog.error('There was a problem executing sql:%s \n \76 com.log.error('There was a problem executing sql:%s \n \ 79 77 with parameters:%s\nException:%s'%(sql, params, e)); 80 78 db.rollback(); … … 86 84 return result 87 85 88 def db_table_exists( table):89 db = env.get_db_cnx()86 def db_table_exists(com, table): 87 db = com.env.get_db_cnx() 90 88 sql = "SELECT * FROM %s LIMIT 1" % table; 91 89 cur = db.cursor() … … 97 95 has_table = False 98 96 db.rollback() 99 97 100 98 try: 101 99 db.close() … … 104 102 return has_table 105 103 106 def get_column_as_list( sql, col=0, *params):107 data = get_all( sql, *params)[1] or ()104 def get_column_as_list(com, sql, col=0, *params): 105 data = get_all(com, sql, *params)[1] or () 108 106 return [valueList[col] for valueList in data] 109 107 110 def get_system_value( key):111 return get_scalar( "SELECT value FROM system WHERE name=%s", 0, key)108 def get_system_value(com, key): 109 return get_scalar(com, "SELECT value FROM system WHERE name=%s", 0, key) 112 110 113 def set_system_value( key, value):114 if get_system_value( key):115 execute_non_query( "UPDATE system SET value=%s WHERE name=%s", value, key)111 def set_system_value(com, key, value): 112 if get_system_value(com, key): 113 execute_non_query(com, "UPDATE system SET value=%s WHERE name=%s", value, key) 116 114 else: 117 execute_non_query( "INSERT INTO system (value, name) VALUES (%s, %s)",115 execute_non_query(com, "INSERT INTO system (value, name) VALUES (%s, %s)", 118 116 value, key) 119 117 120 118 121 def get_result_set( sql, *params):119 def get_result_set(com, sql, *params): 122 120 """Executes the query and returns a Result Set""" 123 tpl = get_all( sql, *params);121 tpl = get_all(com, sql, *params); 124 122 if tpl and tpl[0] and tpl[1]: 125 123 return ResultSet(tpl) … … 131 129 """ the result of calling getResultSet """ 132 130 def __init__ (self, (columnDescription, rows)): 133 self.columnDescription, self.rows = columnDescription, rows 131 self.columnDescription, self.rows = columnDescription, rows 134 132 self.columnMap = self.get_column_map() 135 133 … … 144 142 i+=1 145 143 return h; 146 144 147 145 def value(self, col, row ): 148 146 """ given a row(list or idx) and a column( name or idx ), retrieve the appropriate value""" … … 165 163 else: 166 164 print ("rs.value Type Failed col:%s row:%s" % (type(col), type(row))) 167 165 168 166 def json_out(self): 169 167 json = "[%s]" % ',\r\n'. join( timingandestimationplugin/branches/trac0.11/timingandestimationplugin/reports.py
r3521 r3784 9 9 "uuid":"b24f08c0-d41f-4c63-93a5-25e18a8513c2", 10 10 "title":"Ticket Work Summary", 11 "version": 19,11 "version":20, 12 12 "sql":""" 13 13 SELECT __ticket__ as __group__, __style__, ticket, … … 22 22 FROM ticket_change 23 23 JOIN ticket t on t.id = ticket_change.ticket 24 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 24 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 25 25 and billable.name = 'billable' 26 26 WHERE field = 'hours' and 27 t.status IN (#STATUSES#) 27 t.status IN (#STATUSES#) 28 28 AND billable.value in ($BILLABLE, $UNBILLABLE) 29 29 AND ticket_change.time >= $STARTDATE 30 30 AND ticket_change.time < $ENDDATE 31 32 UNION 33 31 32 UNION 33 34 34 SELECT 'background-color:#DFE;' as __style__, 35 35 'Total work done on the ticket in the selected time period ' as author, … … 41 41 FROM ticket_change 42 42 JOIN ticket t on t.id = ticket_change.ticket 43 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 43 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 44 44 and billable.name = 'billable' 45 45 WHERE field = 'hours' and 46 t.status IN (#STATUSES#) 46 t.status IN (#STATUSES#) 47 47 AND billable.value in ($BILLABLE, $UNBILLABLE) 48 48 AND ticket_change.time >= $STARTDATE … … 57 57 "uuid":"af13564f-0e36-4a17-96c0-632dc68d8d14", 58 58 "title":"Milestone Work Summary", 59 "version":1 6,59 "version":17, 60 60 "sql":""" 61 61 62 SELECT 62 SELECT 63 63 milestone as __group__, __style__, ticket, summary, newvalue as Work_added, 64 64 time as datetime, _ord … … 70 70 FROM ticket_change 71 71 JOIN ticket t on t.id = ticket_change.ticket 72 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 72 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 73 73 and billable.name = 'billable' 74 74 WHERE field = 'hours' and 75 t.status IN (#STATUSES#) 75 t.status IN (#STATUSES#) 76 76 AND billable.value in ($BILLABLE, $UNBILLABLE) 77 77 AND ticket_change.time >= $STARTDATE 78 78 AND ticket_change.time < $ENDDATE 79 79 GROUP BY t.milestone, t.id, t.summary 80 81 UNION 82 80 81 UNION 82 83 83 SELECT 'background-color:#DFE;' as __style__, NULL as ticket, 84 84 sum( CASE WHEN newvalue = '' OR newvalue IS NULL THEN 0 … … 87 87 FROM ticket_change 88 88 JOIN ticket t on t.id = ticket_change.ticket 89 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 89 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 90 90 and billable.name = 'billable' 91 91 WHERE field = 'hours' and 92 t.status IN (#STATUSES#) 92 t.status IN (#STATUSES#) 93 93 AND billable.value in ($BILLABLE, $UNBILLABLE) 94 94 AND ticket_change.time >= $STARTDATE … … 102 102 """ 103 103 },#END Milestone work summary 104 104 105 105 { 106 106 "uuid":"7bd4b0ce-da6d-4b11-8be3-07e65b540d99", 107 107 "title":"Developer Work Summary", 108 "version":1 6,108 "version":17, 109 109 "sql":""" 110 110 SELECT author as __group__,__style__, ticket, summary, … … 118 118 FROM ticket_change 119 119 JOIN ticket t on t.id = ticket_change.ticket 120 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 120 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 121 121 and billable.name = 'billable' 122 122 WHERE field = 'hours' and 123 t.status IN (#STATUSES#) 123 t.status IN (#STATUSES#) 124 124 AND billable.value in ($BILLABLE, $UNBILLABLE) 125 125 AND ticket_change.time >= $STARTDATE 126 126 AND ticket_change.time < $ENDDATE 127 128 UNION 129 127 128 UNION 129 130 130 SELECT 'background-color:#DFE;' as __style__, author, NULL as ticket, 131 131 Null as summary, … … 135 135 FROM ticket_change 136 136 JOIN ticket t on t.id = ticket_change.ticket 137 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 137 LEFT JOIN ticket_custom as billable on billable.ticket = t.id 138 138 and billable.name = 'billable' 139 139 WHERE field = 'hours' and 140 t.status IN (#STATUSES#) 140 t.status IN (#STATUSES#) 141 141 AND billable.value in ($BILLABLE, $UNBILLABLE) 142 142 AND ticket_change.time >= $STARTDATE … … 145 145 ) as tbl 146 146 ORDER BY author, _ord ASC, time 147 147 148 148 """ 149 149 },#END Hours Per Developer 150 150 ] 151 th_version =1 4151 th_version =15 152 152 ticket_hours_reports = [ 153 153 { … … 166 166 ELSE CAST( EstimatedHours.value AS DECIMAL ) END as Estimated_work, 167 167 CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 168 ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work, 169 CASE WHEN billable.value = 1THEN 'Y' else 'N' END as billable,168 ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work, 169 CASE WHEN billable.value = '1' THEN 'Y' else 'N' END as billable, 170 170 time AS created, changetime AS modified, -- ## Dates are formatted 171 171 description AS _description_, -- ## Uses a full row 172 172 changetime AS _changetime, 173 173 reporter AS _reporter 174 ,0 as _ord 175 174 ,0 as _ord 175 176 176 FROM ticket as t 177 177 JOIN enum as p ON p.name=t.priority AND p.type='priority' 178 178 179 179 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 180 180 AND EstimatedHours.Ticket = t.Id … … 183 183 LEFT JOIN ticket_custom as billable ON billable.name='billable' 184 184 AND billable.Ticket = t.Id 185 186 WHERE t.status IN (#STATUSES#) 187 AND billable.value in ($BILLABLE, $UNBILLABLE) 188 189 190 UNION 191 185 186 WHERE t.status IN (#STATUSES#) 187 AND billable.value in ($BILLABLE, $UNBILLABLE) 188 189 190 UNION 191 192 192 SELECT '1' AS __color__, 193 193 'background-color:#DFE;' as __style__, 194 NULL as ticket, 'Total' AS summary, 194 NULL as ticket, 'Total' AS summary, 195 195 NULL as component,NULL as version, NULL as severity, NULL as milestone, 196 196 'Time Remaining: ' as status, 197 197 CAST( 198 198 SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0 199 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 199 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 200 200 SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 201 201 ELSE CAST( totalhours.value AS DECIMAL ) END) … … 207 207 NULL as billable, 208 208 NULL as created, NULL as modified, -- ## Dates are formatted 209 209 210 210 NULL AS _description_, 211 211 NULL AS _changetime, … … 214 214 FROM ticket as t 215 215 JOIN enum as p ON p.name=t.priority AND p.type='priority' 216 216 217 217 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 218 218 AND EstimatedHours.Ticket = t.Id 219 219 220 220 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 221 221 AND totalhours.Ticket = t.Id 222 222 223 223 LEFT JOIN ticket_custom as billable ON billable.name='billable' 224 224 AND billable.Ticket = t.Id 225 226 WHERE t.status IN (#STATUSES#) 225 226 WHERE t.status IN (#STATUSES#) 227 227 AND billable.value in ($BILLABLE, $UNBILLABLE) 228 228 ) as tbl … … 253 253 CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 254 254 ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work, 255 CASE WHEN billable.value = 1THEN 'Y'255 CASE WHEN billable.value = '1' THEN 'Y' 256 256 else 'N' 257 257 END as billable, … … 260 260 changetime AS _changetime, 261 261 reporter AS _reporter 262 ,0 as _ord 263 264 FROM ticket as t 265 JOIN enum as p ON p.name=t.priority AND p.type='priority' 266 267 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 268 AND EstimatedHours.Ticket = t.Id 269 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 270 AND totalhours.Ticket = t.Id 271 LEFT JOIN ticket_custom as billable ON billable.name='billable' 272 AND billable.Ticket = t.Id 273 274 WHERE t.status IN (#STATUSES#) 275 AND billable.value in ($BILLABLE, $UNBILLABLE) 276 277 278 UNION 262 ,0 as _ord 263 264 FROM ticket as t 265 JOIN enum as p ON p.name=t.priority AND p.type='priority' 266 267 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 268 AND EstimatedHours.Ticket = t.Id 269 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 270 AND totalhours.Ticket = t.Id 271 LEFT JOIN ticket_custom as billable ON billable.name='billable' 272 AND billable.Ticket = t.Id 273 274 WHERE t.status IN (#STATUSES#) 275 AND billable.value in ($BILLABLE, $UNBILLABLE) 276 277 278 UNION 279 279 280 280 SELECT '1' AS __color__, 281 281 'background-color:#DFE;' as __style__, 282 NULL as ticket, 'Total' AS summary, 282 NULL as ticket, 'Total' AS summary, 283 283 NULL as component,NULL as version, NULL as severity, NULL as milestone, 284 284 'Time Remaining: ' as status, 285 285 CAST( 286 286 SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0 287 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 287 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 288 288 SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 289 289 ELSE CAST( totalhours.value AS DECIMAL ) END) … … 302 302 FROM ticket as t 303 303 JOIN enum as p ON p.name=t.priority AND p.type='priority' 304 305 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 306 AND EstimatedHours.Ticket = t.Id 307 308 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 309 AND totalhours.Ticket = t.Id 310 311 LEFT JOIN ticket_custom as billable ON billable.name='billable' 312 AND billable.Ticket = t.Id 313 314 WHERE t.status IN (#STATUSES#) 304 305 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 306 AND EstimatedHours.Ticket = t.Id 307 308 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 309 AND totalhours.Ticket = t.Id 310 311 LEFT JOIN ticket_custom as billable ON billable.name='billable' 312 AND billable.Ticket = t.Id 313 314 WHERE t.status IN (#STATUSES#) 315 315 AND billable.value in ($BILLABLE, $UNBILLABLE) 316 316 ) as tbl … … 318 318 """ 319 319 }, 320 #END Ticket Hours 320 #END Ticket Hours 321 321 322 322 { … … 339 339 CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 340 340 ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work, 341 CASE WHEN billable.value = 1THEN 'Y'341 CASE WHEN billable.value = '1' THEN 'Y' 342 342 else 'N' 343 343 END as billable, … … 346 346 changetime AS _changetime, 347 347 reporter AS _reporter 348 ,0 as _ord 349 350 FROM ticket as t 351 JOIN enum as p ON p.name=t.priority AND p.type='priority' 352 353 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 354 AND EstimatedHours.Ticket = t.Id 355 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 356 AND totalhours.Ticket = t.Id 357 LEFT JOIN ticket_custom as billable ON billable.name='billable' 358 AND billable.Ticket = t.Id 359 360 WHERE t.status IN (#STATUSES#) 361 AND billable.value in ($BILLABLE, $UNBILLABLE) 362 363 364 UNION 348 ,0 as _ord 349 350 FROM ticket as t 351 JOIN enum as p ON p.name=t.priority AND p.type='priority' 352 353 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 354 AND EstimatedHours.Ticket = t.Id 355 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 356 AND totalhours.Ticket = t.Id 357 LEFT JOIN ticket_custom as billable ON billable.name='billable' 358 AND billable.Ticket = t.Id 359 360 WHERE t.status IN (#STATUSES#) 361 AND billable.value in ($BILLABLE, $UNBILLABLE) 362 363 364 UNION 365 365 366 366 SELECT '1' AS __color__, 367 367 t.component AS __group__, 368 368 'background-color:#DFE;' as __style__, 369 NULL as ticket, 'Total work' AS summary, 369 NULL as ticket, 'Total work' AS summary, 370 370 t.component as __component__, NULL as version, NULL as severity, 371 371 NULL as milestone, 'Time Remaining: ' as status, 372 372 CAST( 373 373 SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0 374 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 374 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 375 375 SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 376 376 ELSE CAST( totalhours.value AS DECIMAL ) END) … … 390 390 FROM ticket as t 391 391 JOIN enum as p ON p.name=t.priority AND p.type='priority' 392 393 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 394 AND EstimatedHours.Ticket = t.Id 395 396 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 397 AND totalhours.Ticket = t.Id 398 399 LEFT JOIN ticket_custom as billable ON billable.name='billable' 400 AND billable.Ticket = t.Id 401 402 WHERE t.status IN (#STATUSES#) 392 393 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 394 AND EstimatedHours.Ticket = t.Id 395 396 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 397 AND totalhours.Ticket = t.Id 398 399 LEFT JOIN ticket_custom as billable ON billable.name='billable' 400 AND billable.Ticket = t.Id 401 402 WHERE t.status IN (#STATUSES#) 403 403 AND billable.value in ($BILLABLE, $UNBILLABLE) 404 404 GROUP BY t.component … … 408 408 }, 409 409 # END Ticket Hours GROUPED BY COMPONENT 410 410 411 411 { 412 412 "uuid":"7816f034-a174-4a94-aed6-358fb648b2fc", … … 428 428 CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 429 429 ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work, 430 CASE WHEN billable.value = 1THEN 'Y' else 'N' END as billable,430 CASE WHEN billable.value = '1' THEN 'Y' else 'N' END as billable, 431 431 time AS created, changetime AS modified, -- ## Dates are formatted 432 432 description AS _description_, -- ## Uses a full row 433 433 changetime AS _changetime, 434 434 reporter AS _reporter 435 ,0 as _ord 436 437 FROM ticket as t 438 JOIN enum as p ON p.name=t.priority AND p.type='priority' 439 440 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 441 AND EstimatedHours.Ticket = t.Id 442 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 443 AND totalhours.Ticket = t.Id 444 LEFT JOIN ticket_custom as billable ON billable.name='billable' 445 AND billable.Ticket = t.Id 446 447 WHERE t.status IN (#STATUSES#) 448 AND billable.value in ($BILLABLE, $UNBILLABLE) 449 450 451 UNION 435 ,0 as _ord 436 437 FROM ticket as t 438 JOIN enum as p ON p.name=t.priority AND p.type='priority' 439 440 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 441 AND EstimatedHours.Ticket = t.Id 442 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 443 AND totalhours.Ticket = t.Id 444 LEFT JOIN ticket_custom as billable ON billable.name='billable' 445 AND billable.Ticket = t.Id 446 447 WHERE t.status IN (#STATUSES#) 448 AND billable.value in ($BILLABLE, $UNBILLABLE) 449 450 451 UNION 452 452 453 453 SELECT '1' AS __color__, 454 454 t.component AS __group__, 455 455 'background-color:#DFE;' as __style__, 456 NULL as ticket, 'Total work' AS summary, 456 NULL as ticket, 'Total work' AS summary, 457 457 t.component as __component__, NULL as version, NULL as severity, 458 458 NULL as milestone, 'Time Remaining: ' as status, 459 459 CAST( 460 460 SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0 461 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 461 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 462 462 SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 463 463 ELSE CAST( totalhours.value AS DECIMAL ) END) … … 476 476 FROM ticket as t 477 477 JOIN enum as p ON p.name=t.priority AND p.type='priority' 478 479 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 480 AND EstimatedHours.Ticket = t.Id 481 482 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 483 AND totalhours.Ticket = t.Id 484 485 LEFT JOIN ticket_custom as billable ON billable.name='billable' 486 AND billable.Ticket = t.Id 487 488 WHERE t.status IN (#STATUSES#) 478 479 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 480 AND EstimatedHours.Ticket = t.Id 481 482 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 483 AND totalhours.Ticket = t.Id 484 485 LEFT JOIN ticket_custom as billable ON billable.name='billable' 486 AND billable.Ticket = t.Id 487 488 WHERE t.status IN (#STATUSES#) 489 489 AND billable.value in ($BILLABLE, $UNBILLABLE) 490 490 GROUP BY t.component … … 513 513 CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 514 514 ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work, 515 CASE WHEN billable.value = 1THEN 'Y'515 CASE WHEN billable.value = '1' THEN 'Y' 516 516 else 'N' 517 517 END as billable, … … 519 519 description AS _description_, -- ## Uses a full row 520 520 changetime AS _changetime, 521 reporter AS _reporter, 0 as _ord 522 523 FROM ticket as t 524 JOIN enum as p ON p.name=t.priority AND p.type='priority' 525 526 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 527 AND EstimatedHours.Ticket = t.Id 528 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 529 AND totalhours.Ticket = t.Id 530 LEFT JOIN ticket_custom as billable ON billable.name='billable' 531 AND billable.Ticket = t.Id 532 533 WHERE t.status IN (#STATUSES#) 534 AND billable.value in ($BILLABLE, $UNBILLABLE) 535 536 537 UNION 521 reporter AS _reporter, 0 as _ord 522 523 FROM ticket as t 524 JOIN enum as p ON p.name=t.priority AND p.type='priority' 525 526 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 527 &
