Esempio n. 1
0
 def render(cls, request=None):
     green = int(request.GET.get('green', cls.green))
     yellow = int(request.GET.get('yellow', cls.yellow))
     cursor = connections[request.database].cursor()
     GridReport.getBuckets(request)
     query = '''
   select case when count(*) = 0 then 0 else 100 - sum(late) * 100.0 / count(*) end
   from (
     select
       demand, max(case when plandate > due then 1 else 0 end) late
     from out_demand
     where due < '%s'
     group by demand
   ) demands
   ''' % request.report_enddate
     cursor.execute(query)
     val = cursor.fetchone()[0]
     result = [
         '<div style="text-align: center"><span id="otd"></span></div>',
         '<span id="otd_label" style="display:none">%s</span>' %
         force_text(_("On time delivery")),
         '<span id="otd_value" style="display:none">%s</span>' % val,
         '<span id="otd_green" style="display:none">%s</span>' % green,
         '<span id="otd_yellow" style="display:none">%s</span>' % yellow
     ]
     return HttpResponse('\n'.join(result))
Esempio n. 2
0
 def render(cls, request=None):
   limit = int(request.GET.get('limit', cls.limit))
   medium = int(request.GET.get('medium', cls.medium))
   high = int(request.GET.get('high', cls.high))
   result = [
     '<svg class="chart" id="resLoad" style="width:100%%; height: %spx;"></svg>' % (limit * 25 + 30),
     '<table style="display:none">'
     ]
   cursor = connections[request.database].cursor()
   GridReport.getBuckets(request)
   query = '''select
                 theresource,
                 ( coalesce(sum(out_resourceplan.load),0) + coalesce(sum(out_resourceplan.setup),0) )
                  * 100.0 / coalesce(sum(out_resourceplan.available)+0.000001,1) as avg_util,
                 coalesce(sum(out_resourceplan.load),0) + coalesce(sum(out_resourceplan.setup),0),
                 coalesce(sum(out_resourceplan.free),0)
               from out_resourceplan
               where out_resourceplan.startdate >= '%s'
                 and out_resourceplan.startdate < '%s'
               group by theresource
               order by 2 desc
             ''' % (request.report_startdate, request.report_enddate)
   cursor.execute(query)
   for res in cursor.fetchall():
     limit -= 1
     if limit < 0:
       break
     result.append('<tr><td><a href="%s/resource/%s/">%s</a></td><td class="util">%.2f</td></tr>' % (
       request.prefix, urlquote(res[0]), res[0], res[1]
       ))
   result.append('</table>')
   result.append('<span id="resload_medium" style="display:none">%s</span>' % medium)
   result.append('<span id="resload_high" style="display:none">%s</span>' % high)
   return HttpResponse('\n'.join(result))
Esempio n. 3
0
 def render(cls, request=None):
   green = int(request.GET.get('green', cls.green))
   yellow = int(request.GET.get('yellow', cls.yellow))
   cursor = connections[request.database].cursor()
   GridReport.getBuckets(request)
   query = '''
     select case when count(*) = 0 then 0 else 100 - sum(late) * 100.0 / count(*) end
     from (
       select
         demand, max(case when plandate > due then 1 else 0 end) late
       from out_demand
       where due < '%s'
       group by demand
     ) demands
     ''' % request.report_enddate
   cursor.execute(query)
   val = cursor.fetchone()[0]
   result = [
     '<div style="text-align: center"><span id="otd"></span></div>',
     '<span id="otd_label" style="display:none">%s</span>' % force_text(_("On time delivery")),
     '<span id="otd_value" style="display:none">%s</span>' % val,
     '<span id="otd_green" style="display:none">%s</span>' % green,
     '<span id="otd_yellow" style="display:none">%s</span>' % yellow
     ]
   return HttpResponse('\n'.join(result))
Esempio n. 4
0
 def render(cls, request=None):
     limit = int(request.GET.get('limit', cls.limit))
     result = [
         '<div id="resLoad" style="width:100%%; height: %spx;"></div>' %
         (limit * 25 + 30), '<table style="display:none">'
     ]
     cursor = connections[request.database].cursor()
     GridReport.getBuckets(request)
     query = '''select
               theresource,
               ( coalesce(sum(out_resourceplan.load),0) + coalesce(sum(out_resourceplan.setup),0) )
                * 100.0 / coalesce(sum(out_resourceplan.available)+0.000001,1) as avg_util,
               coalesce(sum(out_resourceplan.load),0) + coalesce(sum(out_resourceplan.setup),0),
               coalesce(sum(out_resourceplan.free),0)
             from out_resourceplan
             where out_resourceplan.startdate >= '%s'
               and out_resourceplan.startdate < '%s'
             group by theresource
             order by 2 desc
           ''' % (request.report_startdate, request.report_enddate)
     cursor.execute(query)
     for res in cursor.fetchall():
         limit -= 1
         if limit < 0: break
         result.append(
             '<tr><td class="name"><span class="underline"><a href="%s/resource/%s/">%s</a></span></td><td class="util">%.2f</td></tr>'
             % (request.prefix, quote(res[0]), res[0], res[1]))
     result.append('</table>')
     return HttpResponse('\n'.join(result))