Merge lp:~mwhudson/lava-kernel-ci-views/show-gitweb-url into lp:lava-kernel-ci-views

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 103
Proposed branch: lp:~mwhudson/lava-kernel-ci-views/show-gitweb-url
Merge into: lp:lava-kernel-ci-views
Diff against target: 179 lines (+48/-10)
2 files modified
lava_kernel_ci_views_app/templates/lava_kernel_ci_views_app/index.html (+7/-0)
lava_kernel_ci_views_app/views.py (+41/-10)
To merge this branch: bzr merge lp:~mwhudson/lava-kernel-ci-views/show-gitweb-url
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+88301@code.launchpad.net

Description of the change

Hi,

This branch adds gitweb links to the kernel ci view. It looks like this: http://people.linaro.org/~mwh/with_gitweb_links.png

Cheers,
mwh

To post a comment you must log in.
107. By Michael Hudson-Doyle

add some comments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_kernel_ci_views_app/templates/lava_kernel_ci_views_app/index.html'
2--- lava_kernel_ci_views_app/templates/lava_kernel_ci_views_app/index.html 2011-10-17 04:32:52 +0000
3+++ lava_kernel_ci_views_app/templates/lava_kernel_ci_views_app/index.html 2012-01-13 03:04:23 +0000
4@@ -106,7 +106,14 @@
5 <div class="item commit">
6 <div class="item-inner commit"
7 title="{{ commit.log_info }}">
8+ {% if commit.commit_url %}
9+ <a href="{{ commit.commit_url }}">{{ commit.describe }}</a>
10+ {% else %}
11 {{ commit.describe }}
12+ {% endif %}
13+ {% if commit.shortlog_url %}
14+ &nbsp<a href="{{ commit.shortlog_url }}">shortlog</a>
15+ {% endif %}
16 </div>
17 </div>
18 </li>
19
20=== modified file 'lava_kernel_ci_views_app/views.py'
21--- lava_kernel_ci_views_app/views.py 2011-10-17 04:32:52 +0000
22+++ lava_kernel_ci_views_app/views.py 2012-01-13 03:04:23 +0000
23@@ -46,6 +46,7 @@
24 softwaresource.branch_revision as git_commit_id,
25 coalesce(namedattribute_git_describe.value, softwaresource.branch_revision) as git_describe,
26 coalesce(namedattribute_git_log_info.value, softwaresource.branch_revision) as git_log_info,
27+ namedattribute_gitweb_url.value as gitweb_url,
28 softwaresource.commit_timestamp as commit_timestamp,
29 testrun.analyzer_assigned_date as build_date,
30 namedattribute_kernelconfig.value as config,
31@@ -83,6 +84,13 @@
32 and namedattribute_git_log_info.content_type_id = (
33 select django_content_type.id from django_content_type
34 where app_label = 'dashboard_app' and model='testrun')
35+ )
36+left outer join dashboard_app_namedattribute as namedattribute_gitweb_url
37+ on (namedattribute_gitweb_url.object_id = testrun.id
38+ and namedattribute_gitweb_url.name = 'kernel.gitweb_url'
39+ and namedattribute_gitweb_url.content_type_id = (
40+ select django_content_type.id from django_content_type
41+ where app_label = 'dashboard_app' and model='testrun')
42 ),
43 dashboard_app_softwaresource as softwaresource,
44 dashboard_app_testrun_sources as tr_ss_link
45@@ -202,12 +210,13 @@
46
47
48 class Commit(object):
49- def __init__(self, sha1, commit_timestamp, describe, log_info, tree):
50+ def __init__(self, sha1, commit_timestamp, describe, log_info, gitweb_url, tree):
51 self.sha1 = sha1
52 self.commit_timestamp = commit_timestamp
53 self.describe = describe
54 self._builds = []
55 self.log_info = log_info
56+ self.gitweb_url = gitweb_url
57 self.tree = tree
58 def add_build(self, config, result, sha1):
59 build = Build(config, result, sha1, self)
60@@ -237,6 +246,18 @@
61 prev = self.prev.sha1
62 else:
63 prev = None
64+ commit_url = shortlog_url = None
65+ if self.gitweb_url:
66+ if 'github' in self.gitweb_url:
67+ base_url = self.gitweb_url
68+ if base_url.endswith('.git'):
69+ base_url = base_url[:-len('.git')]
70+ commit_url = base_url + '/commit/' + self.sha1
71+ else:
72+ commit_url = self.gitweb_url + ';a=commit;h=' + self.sha1
73+ if self.prev:
74+ shortlog_url = '%s;a=shortlog;h=%s;hp=%s' % (
75+ self.gitweb_url, self.sha1, self.prev.sha1)
76 return {
77 'sha1': self.sha1,
78 'describe': self.describe,
79@@ -244,6 +265,8 @@
80 'test_count': sum(len(build['tests']) for build in builds),
81 'prev': prev,
82 'log_info': self.log_info,
83+ 'commit_url': commit_url,
84+ 'shortlog_url': shortlog_url,
85 }
86
87
88@@ -253,13 +276,13 @@
89 self._commits = {}
90 self.day = day
91 self.index = index
92- def get_commit(self, sha1, commit_timestamp, describe, log_info):
93+ def get_commit(self, sha1, commit_timestamp, describe, log_info, gitweb_url):
94 if sha1 in self._commits:
95 # XXX if self._commits[sha1].commit_timestamp != commit_timestamp ...
96 return self._commits[sha1]
97 else:
98 commit_obj = self._commits[sha1] = Commit(
99- sha1, commit_timestamp, describe, log_info, self)
100+ sha1, commit_timestamp, describe, log_info, gitweb_url, self)
101 return commit_obj
102 @property
103 def commits(self):
104@@ -305,7 +328,7 @@
105 'trees': trees,
106 'build_count': sum(tree['build_count'] for tree in trees),
107 'test_count': sum(tree['test_count'] for tree in trees),
108- 'tree_count': len(trees),
109+ 'tree_count': len([tree for tree in trees if tree['build_count'] > 0]),
110 }
111
112
113@@ -314,7 +337,12 @@
114 self.start = start
115 self.finish = finish
116 self._days = {}
117- d = start
118+ # We create a Day object for every day we're interested in, plus one
119+ # day older so that we can find the previous build for the last row of
120+ # builds displayed. This isn't quite enough, because the previous
121+ # build might have been more than one day before the last one
122+ # displayed, but for now it's a reasonable hack.
123+ d = start - DAY_DELTA
124 while d < finish:
125 self._days[d] = Day(d, self)
126 d += DAY_DELTA
127@@ -335,9 +363,10 @@
128 self._tree2index[git_url] = len(self._tree2index)
129 tree = day.get_tree(git_url, self._tree2index[git_url])
130 self.all_trees.add(tree)
131+ print repr(build_results.gitweb_url)
132 commit = tree.get_commit(
133 build_results.git_commit_id, build_results.commit_timestamp,
134- build_results.git_describe, build_results.git_log_info)
135+ build_results.git_describe, build_results.git_log_info, build_results.gitweb_url)
136 config = build_results.config
137 if config.endswith('_defconfig'):
138 config = config[:-len('_defconfig')]
139@@ -395,7 +424,7 @@
140 def evaluate(self):
141 connection = DataView.get_connection()
142 with contextlib.closing(connection.cursor()) as cursor:
143- cursor.execute(index_sql, (self.start, self.finish))
144+ cursor.execute(index_sql, (self.start - DAY_DELTA, self.finish))
145
146 for build_result in fetchnamed(cursor):
147 self.add_build(build_result)
148@@ -425,6 +454,8 @@
149 day_objs = self._days.values()
150 day_objs.sort(key=key)
151 day_objs.reverse()
152+ # Remove the extra day (see __init__ for the comment about this).
153+ del day_objs[-1]
154 trees = []
155 for url, index in sorted(self._tree2index.items()):
156 trees.append({
157@@ -449,11 +480,11 @@
158 form.is_valid()
159 start = form.cleaned_data['start']
160 if start is None:
161- start = datetime.date.today() - WEEK_DELTA
162+ start = datetime.date.today() - WEEK_DELTA + DAY_DELTA
163
164 end = form.cleaned_data['end']
165 if end is None:
166- end = datetime.date.today()
167+ end = datetime.date.today() + DAY_DELTA
168
169 day_collection = DayCollection(start, end)
170
171@@ -466,7 +497,7 @@
172
173 data = day_collection.json_ready()
174 newer_results_link = None
175- if end <= datetime.date.today():
176+ if end <= datetime.date.today() + DAY_DELTA:
177 newer_start = end
178 newer_end = max(
179 newer_start + WEEK_DELTA, datetime.date.today())

Subscribers

People subscribed via source and target branches

to all changes: