Exemplo n.º 1
0
def _GenerateComputersSummaryCache(cursor=None, summary=None):
    query = models.Computer.AllActive().with_cursor(cursor)

    computers = query.fetch(summary_module.DEFAULT_COMPUTER_FETCH_LIMIT)
    if computers:
        summary = summary_module.GetComputerSummary(computers,
                                                    initial_summary=summary)
        deferred.defer(_GenerateComputersSummaryCache, query.cursor(), summary)
        return
    models.ReportsCache.SetStatsSummary(
        summary_module.PrepareComputerSummaryForTemplate(summary))
Exemplo n.º 2
0
 def testGetComputerSummary(self):
     computers = models.Computer.all().filter('active =', True).fetch(500)
     s = summary.PrepareComputerSummaryForTemplate(
         summary.GetComputerSummary(computers))
     self.assertEqual(2, dict(s['sites_histogram'])['MTV'])
     self.assertEqual(2, dict(s['os_versions'])['10.11'])
     self.assertEqual(1, dict(s['client_versions'])['2.3.3'])
     self.assertEqual(1, s['tracks']['stable'][1])
     self.assertEqual(2, s['conns_on_corp'])
     self.assertEqual(2, s['active'][1])
     self.assertEqual(3, s['active'][14])
     self.assertAlmostEqual(98.0582, s['conns_off_corp_percent'], 3)