/[collab-qa]/udd/udd/history_daily_gatherer.py
ViewVC logotype

Contents of /udd/udd/history_daily_gatherer.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1637 - (show annotations) (download) (as text)
Wed Dec 9 20:26:14 2009 UTC (3 years, 5 months ago) by lucas
File MIME type: text/x-python
File size: 2129 byte(s)
store historical data about sources into history.sources_count
1 #!/usr/bin/env python
2
3 """
4 This script imports some historical data on a daily basis into UDD
5 """
6
7 from aux import quote
8 from gatherer import gatherer
9 import re
10
11 def get_gatherer(connection, config, source):
12 return history_daily_gatherer(connection, config, source)
13
14 class history_daily_gatherer(gatherer):
15
16 def __init__(self, connection, config, source):
17 gatherer.__init__(self, connection, config, source)
18 self.assert_my_config()
19
20 def run(self):
21 #start harassing the DB, preparing the final inserts and making place
22 #for the new data:
23 cur = self.cursor()
24 cur2 = self.cursor()
25
26 # source format
27 data = {}
28 cur.execute("""SELECT format, COUNT(DISTINCT source) AS cnt FROM sources
29 WHERE distribution='debian' and release='sid' GROUP BY format""")
30 rows = {}
31 for r in cur.fetchall():
32 rows[r[0]] = r[1]
33 data['format_3native'] = rows['3.0 (native)']
34 data['format_3quilt'] = rows['3.0 (quilt)']
35 cur.execute("""SELECT vcs_type, COUNT(DISTINCT source) AS cnt FROM sources
36 WHERE distribution='debian' and release='sid' GROUP BY vcs_type""")
37 rows = {}
38 for r in cur.fetchall():
39 rows[r[0]] = r[1]
40 data['vcstype_arch'] = rows.get('Arch',0)
41 data['vcstype_bzr'] = rows.get('Bzr',0)
42 data['vcstype_cvs'] = rows.get('Cvs',0)
43 data['vcstype_darcs'] = rows.get('Darcs',0)
44 data['vcstype_git'] = rows.get('Git',0)
45 data['vcstype_hg'] = rows.get('Hg',0)
46 data['vcstype_mtn'] = rows.get('Mtn',0)
47 data['vcstype_svn'] = rows.get('Svn',0)
48
49 cur2.execute("""INSERT INTO history.sources_count (ts,
50 format_3native, format_3quilt,
51 vcstype_arch, vcstype_bzr, vcstype_cvs, vcstype_darcs, vcstype_git, vcstype_hg, vcstype_mtn, vcstype_svn
52 ) VALUES (NOW(),
53 %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
54 (data['format_3native'], data['format_3quilt'],
55 data['vcstype_arch'], data['vcstype_bzr'], data['vcstype_cvs'], data['vcstype_darcs'], data['vcstype_git'], data['vcstype_hg'], data['vcstype_mtn'], data['vcstype_svn']))
56
57 if __name__ == '__main__':
58 main()
59
60 # vim:set et tabstop=2:

  ViewVC Help
Powered by ViewVC 1.1.5