]> git.decadent.org.uk Git - dak.git/commitdiff
Merge commit 'lamby/master' into merge
authorJoerg Jaspert <joerg@debian.org>
Mon, 26 Oct 2009 16:39:29 +0000 (17:39 +0100)
committerJoerg Jaspert <joerg@debian.org>
Mon, 26 Oct 2009 16:39:29 +0000 (17:39 +0100)
* commit 'lamby/master':
  Don't repr the object; could be a long (and ends up with eg. "2L")

Signed-off-by: Joerg Jaspert <joerg@debian.org>
1  2 
dak/stats.py

diff --combined dak/stats.py
index e3e9077bcbe6ed991eaf0fb32a77b6b879709ba5,52534c5128be8f2634747d0cd8ec40b3e63bc99d..583178b28a01d89b660dfc15ef67b089b3fd422e
@@@ -129,6 -129,12 +129,6 @@@ def output_format(suite)
          output_suite.append(word[0])
      return "-".join(output_suite)
  
 -# Obvious query with GROUP BY and mapped names                  -> 50 seconds
 -# GROUP BY but ids instead of suite/architecture names          -> 28 seconds
 -# Simple query                                                  -> 14 seconds
 -# Simple query into large dictionary + processing               -> 21 seconds
 -# Simple query into large pre-created dictionary + processing   -> 18 seconds
 -
  def number_of_packages():
      arches = {}
      arch_ids = {}
      # Get the raw data for binaries
      # Simultate 'GROUP by suite, architecture' with a dictionary
      # XXX: Why don't we just get the DB to do this?
 -    for i in session.query(BinAssociation):
 -        suite_id = i.suite_id
 -        arch_id = i.binary.arch_id
 -        d[suite_id][arch_id] = d[suite_id][arch_id] + 1
 +    for i in session.execute("""SELECT suite, architecture, COUNT(suite)
 +                                FROM bin_associations
 +                           LEFT JOIN binaries ON bin = binaries.id
 +                            GROUP BY suite, architecture""").fetchall():
 +        d[ i[0] ][ i[1] ] = i[2]
      # Get the raw data for source
      arch_id = arch_ids["source"]
 -    for i in session.execute('SELECT suite, COUNT(suite) FROM src_associations GROUP BY suite').all():
 +    for i in session.execute('SELECT suite, COUNT(suite) FROM src_associations GROUP BY suite').fetchall():
          (suite_id, count) = i
          d[suite_id][arch_id] = d[suite_id][arch_id] + count
      ## Print the results
          output = output + arch.center(longest_arch)+" |"
          for suite_id in suite_id_list:
              if suite_arches[suite_id].has_key(arch):
-                 count = repr(d[suite_id][arch_id])
+                 count = "%d" % d[suite_id][arch_id]
              else:
                  count = "-"
              output = output + count.rjust(longest_suite)+" |"