Using API to report on a Service Level Agreement (SLA). - FogBugz Knowledge Exchange most recent 30 from http://fogbugz.stackexchange.com2013-06-19T18:16:25Zhttp://fogbugz.stackexchange.com/feeds/question/5690http://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://fogbugz.stackexchange.com/questions/5690/using-api-to-report-on-a-service-level-agreement-slaUsing API to report on a Service Level Agreement (SLA).Jonathan2010-11-02T19:12:59Z2013-06-09T02:22:00Z
<p>Our organization has a need to begin producing SLA (http://en.wikipedia.org/wiki/Service_level_agreement) reports for some clients. </p>
<p>The logical starting point for us is 'time to initial response', where the response is a human response, not the FogBugz auto-generated response.</p>
http://fogbugz.stackexchange.com/questions/5690/using-api-to-report-on-a-service-level-agreement-sla/5741#5741Answer by Rich Armstrong for Using API to report on a Service Level Agreement (SLA).Rich Armstrong2010-11-04T16:57:33Z2010-12-01T18:46:51Z<p>Here's the Python script I came up with to go through all cases in the Inbox project for the last 30 days and spit out, for the ones that'd gotten a reply, the time difference between the case open and the first reply.</p>
<pre><code>#!/usr/local/bin/python
import re, string, sys
from fogbugz import FogBugz
from datetime import datetime,timedelta
fogbugz = FogBugz('http://foo.fogbugz.com', "")
api_date = '%Y-%m-%dT%H:%M:%SZ'
min_case = 1
ixbug = 0
while True:
resp = fogbugz.search(q='project:inbox area:support opened:"-30d.." orderby:case case:"%d.."' % (ixbug + 1),cols='ixBug,dtOpened,events',max=100)
case_found = False
for case in resp.findAll('case'):
case_found = True
ixbug = int(case['ixbug'])
for event in case.findAll('event'):
if event.sverb.string == 'Replied':
td = datetime.strptime(event.dt.string,api_date) - datetime.strptime(case.dtopened.string,api_date)
print ",".join(["%s" % ixbug,case.dtopened.string,event.dt.string,'%d' % (td.seconds + td.days * 24 * 3600)])
break
if case_found == False:
break
</code></pre>