Changeset 3785
- Timestamp:
- 06/04/08 08:36:00 (6 months ago)
- Files:
-
- timingandestimationplugin/branches/trac0.10/setup.py (modified) (2 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/api.py (modified) (19 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/dbhelper.py (modified) (15 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/reports.py (modified) (32 diffs)
- timingandestimationplugin/branches/trac0.10/timingandestimationplugin/webui.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
timingandestimationplugin/branches/trac0.10/setup.py
r3520 r3785 8 8 description='Plugin to make Trac support time estimation and tracking', 9 9 keywords='trac plugin estimation timetracking', 10 version='0. 5.6',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.10/timingandestimationplugin/api.py
r3398 r3785 9 9 from trac.env import IEnvironmentSetupParticipant 10 10 from trac.perm import IPermissionRequestor, PermissionSystem 11 from webui import * 11 from webui import * 12 12 from ticket_webui import * 13 13 from reportmanager import CustomReportManager … … 15 15 ## report columns 16 16 ## id|author|title|query|description 17 17 18 18 class TimeTrackingSetupParticipant(Component): 19 19 """ This is the config that must be there for this plugin to work: 20 20 21 21 [ticket-custom] 22 22 totalhours = text … … 31 31 hours.value = 0 32 32 hours.label = Hours to Add 33 33 34 34 estimatedhours = text 35 35 estimatedhours.value = 0 36 36 estimatedhours.label = Estimated Hours? 37 37 38 38 """ 39 39 implements(IEnvironmentSetupParticipant) … … 42 42 db_version = None 43 43 db_installed_version = None 44 44 45 45 """Extension point interface for components that need to participate in the 46 46 creation and upgrading of Trac environments, for example to create … … 48 48 def __init__(self): 49 49 # Setup logging 50 dbhelper.mylog = self.log51 dbhelper.env = self.env52 50 self.db_version_key = 'TimingAndEstimationPlugin_Db_Version' 53 51 self.db_version = 7 … … 72 70 if self.environment_needs_upgrade(None): 73 71 self.upgrade_environment(None) 74 72 75 73 def system_needs_upgrade(self): 76 74 return self.db_installed_version < self.db_version 77 75 78 76 def do_db_upgrade(self): 79 77 # Legacy support hack (supports upgrades from 0.1.6 to 0.1.7) 80 78 if self.db_installed_version == 0: 81 bill_date = dbhelper.db_table_exists( 'bill_date');82 report_version = dbhelper.db_table_exists( 'report_version');79 bill_date = dbhelper.db_table_exists(self, 'bill_date'); 80 report_version = dbhelper.db_table_exists(self, 'report_version'); 83 81 if bill_date and report_version: 84 82 self.db_installed_version = 1 85 83 # End Legacy support hack 86 87 84 85 88 86 if self.db_installed_version < 1: 89 87 print "Creating bill_date table" … … 95 93 ); 96 94 """ 97 dbhelper.execute_non_query( sql)98 95 dbhelper.execute_non_query(self, sql) 96 99 97 print "Creating report_version table" 100 98 sql = """ … … 105 103 ); 106 104 """ 107 dbhelper.execute_non_query(s ql)105 dbhelper.execute_non_query(self, sql) 108 106 109 107 if self.db_installed_version < 4: … … 112 110 ALTER TABLE report_version ADD COLUMN tags varchar(1024) null; 113 111 """ 114 dbhelper.execute_non_query(s ql)112 dbhelper.execute_non_query(self, sql) 115 113 116 114 if self.db_installed_version < 5: … … 121 119 sql = "DELETE FROM report " \ 122 120 "WHERE author=%s AND id IN (SELECT report FROM report_version)" 123 dbhelper.execute_non_query( sql, 'Timing and Estimation Plugin')124 121 dbhelper.execute_non_query(self, sql, 'Timing and Estimation Plugin') 122 125 123 sql = "DROP TABLE report_version" 126 dbhelper.execute_non_query( sql)127 124 dbhelper.execute_non_query(self, sql) 125 128 126 # 6 & 7 are report upgrades 129 127 130 128 # This statement block always goes at the end this method 131 dbhelper.set_system_value(self .db_version_key, self.db_version)129 dbhelper.set_system_value(self, self.db_version_key, self.db_version) 132 130 self.db_installed_version = self.db_version 133 131 134 132 135 133 def do_reports_upgrade(self): … … 150 148 group_title) 151 149 152 150 153 151 def ticket_fields_need_upgrade(self): 154 152 ticket_custom = "ticket-custom" … … 158 156 #self.config.get( ticket_custom, "billable.order") and \ 159 157 #(not self.config.get( ticket_custom, "lastbilldate" )) and \ 160 158 161 159 self.config.get( ticket_custom, "hours" ) and \ 162 160 self.config.get( ticket_custom, "totalhours.order") and \ … … 164 162 self.config.get( ticket_custom, "estimatedhours.order") and \ 165 163 self.config.get( ticket_custom, "estimatedhours")) 166 164 167 165 def do_ticket_field_upgrade(self): 168 166 ticket_custom = "ticket-custom" 169 167 170 168 self.config.set(ticket_custom,"totalhours", "text") 171 169 if not self.config.get( ticket_custom, "totalhours.order") : 172 170 self.config.set(ticket_custom,"totalhours.order", "4") 173 171 self.config.set(ticket_custom,"totalhours.value", "0") 174 self.config.set(ticket_custom,"totalhours.label", "Total Hours") 172 self.config.set(ticket_custom,"totalhours.label", "Total Hours") 175 173 176 174 self.config.set(ticket_custom,"billable", "checkbox") … … 179 177 self.config.set(ticket_custom,"billable.order", "3") 180 178 self.config.set(ticket_custom,"billable.label", "Billable?") 181 179 182 180 self.config.set(ticket_custom,"hours", "text") 183 181 self.config.set(ticket_custom,"hours.value", "0") … … 185 183 self.config.set(ticket_custom,"hours.order", "2") 186 184 self.config.set(ticket_custom,"hours.label", "Add Hours to Ticket") 187 185 188 186 self.config.set(ticket_custom,"estimatedhours", "text") 189 187 self.config.set(ticket_custom,"estimatedhours.value", "0") … … 195 193 196 194 def needs_user_man(self): 197 maxversion = dbhelper.get_scalar( "SELECT MAX(version) FROM wiki WHERE name like %s", 0,195 maxversion = dbhelper.get_scalar(self, "SELECT MAX(version) FROM wiki WHERE name like %s", 0, 198 196 user_manual_wiki_title) 199 197 if (not maxversion) or maxversion < user_manual_version: … … 208 206 VALUES ( %s, %s, %s, 'Timing and Estimation Plugin', '127.0.0.1', %s,'',0) 209 207 """ 210 dbhelper.execute_non_query(s ql,208 dbhelper.execute_non_query(self, sql, 211 209 user_manual_wiki_title, 212 210 user_manual_version, 213 211 when, 214 212 user_manual_content) 215 216 213 214 217 215 def environment_needs_upgrade(self, db): 218 216 """Called when Trac checks whether the environment needs to be upgraded. 219 217 220 218 Should return `True` if this participant needs an upgrade to be 221 219 performed, `False` otherwise. … … 224 222 return (self.system_needs_upgrade()) or \ 225 223 (self.ticket_fields_need_upgrade()) or \ 226 (self.needs_user_man()) 227 224 (self.needs_user_man()) 225 228 226 def upgrade_environment(self, db): 229 227 """Actually perform an environment upgrade. 230 228 231 229 Implementations of this method should not commit any database 232 230 transactions. This is done implicitly after all participants have … … 251 249 252 250 253 254 255 256 251 252 253 254 timingandestimationplugin/branches/trac0.10/timingandestimationplugin/dbhelper.py
r3119 r3785 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.10/timingandestimationplugin/reports.py
r3520 r3785 9 9 "uuid":"b24f08c0-d41f-4c63-93a5-25e18a8513c2", 10 10 "title":"Ticket Work Summary", 11 "version":1 7,11 "version":18, 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 27 t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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, … … 44 44 and billable.name = 'billable' 45 45 WHERE field = 'hours' and 46 t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 46 t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 4,59 "version":15, 60 60 "sql":""" 61 61 62 SELECT 62 SELECT 63 63 milestone as __group__, __style__, ticket, summary, newvalue as Work_added, 64 64 time, _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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 75 t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 92 t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 4,108 "version":15, 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 123 t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 140 t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 3151 th_version =14 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 187 AND billable.value in ($BILLABLE, $UNBILLABLE) 188 189 190 UNION 191 185 186 WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 225 226 WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 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 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 ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 534 AND billable.value in ($BILLABLE, $UNBILLABLE) 535 536 537 UNION 538 538 539 539 SELECT '1' AS __color__, 540 540 t.milestone AS __group__, 541 541 'background-color:#DFE;' as __style__, 542 NULL as ticket, 'Total work' AS summary, 542 NULL as ticket, 'Total work' AS summary, 543 543 NULL as component,NULL as version, NULL as severity, 544 544 t.milestone as __milestone__, 'Time Remaining: ' as status, 545 545 CAST( 546 546 SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0 547 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 547 ELSE CAST( EstimatedHours.value AS DECIMAL ) END) - 548 548 SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 549 549 ELSE CAST( totalhours.value AS DECIMAL ) END) … … 562 562 FROM ticket as t 563 563 JOIN enum as p ON p.name=t.priority AND p.type='priority' 564 565 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 566 AND EstimatedHours.Ticket = t.Id 567 568 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 569 AND totalhours.Ticket = t.Id 570 571 LEFT JOIN ticket_custom as billable ON billable.name='billable' 572 AND billable.Ticket = t.Id 573 574 WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 564 565 LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours' 566 AND EstimatedHours.Ticket = t.Id 567 568 LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours' 569 AND totalhours.Ticket = t.Id 570 571 LEFT JOIN ticket_custom as billable ON billable.name='billable' 572 AND billable.Ticket = t.Id 573 574 WHERE t.status IN ($NEW, $ASSIGNED, $REOPENED, $CLOSED) 575 575 AND billable.value in ($BILLABLE, $UNBILLABLE) 576 576 GROUP BY t.milestone … … 599 599 CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0 600 600 ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work, 60
