Using API to report on a Service Level Agreement (SLA). - FogBugz Knowledge Exchange most recent 30 from http://fogbugz.stackexchange.com 2013-06-19T18:16:25Z http://fogbugz.stackexchange.com/feeds/question/5690 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://fogbugz.stackexchange.com/questions/5690/using-api-to-report-on-a-service-level-agreement-sla Using API to report on a Service Level Agreement (SLA). Jonathan 2010-11-02T19:12:59Z 2013-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#5741 Answer by Rich Armstrong for Using API to report on a Service Level Agreement (SLA). Rich Armstrong 2010-11-04T16:57:33Z 2010-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>