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
=== modified file 'lava_kernel_ci_views_app/templates/lava_kernel_ci_views_app/index.html'
--- lava_kernel_ci_views_app/templates/lava_kernel_ci_views_app/index.html 2011-10-17 04:32:52 +0000
+++ lava_kernel_ci_views_app/templates/lava_kernel_ci_views_app/index.html 2012-01-13 03:04:23 +0000
@@ -106,7 +106,14 @@
106 <div class="item commit">106 <div class="item commit">
107 <div class="item-inner commit"107 <div class="item-inner commit"
108 title="{{ commit.log_info }}">108 title="{{ commit.log_info }}">
109 {% if commit.commit_url %}
110 <a href="{{ commit.commit_url }}">{{ commit.describe }}</a>
111 {% else %}
109 {{ commit.describe }}112 {{ commit.describe }}
113 {% endif %}
114 {% if commit.shortlog_url %}
115 &nbsp<a href="{{ commit.shortlog_url }}">shortlog</a>
116 {% endif %}
110 </div>117 </div>
111 </div>118 </div>
112 </li>119 </li>
113120
=== modified file 'lava_kernel_ci_views_app/views.py'
--- lava_kernel_ci_views_app/views.py 2011-10-17 04:32:52 +0000
+++ lava_kernel_ci_views_app/views.py 2012-01-13 03:04:23 +0000
@@ -46,6 +46,7 @@
46 softwaresource.branch_revision as git_commit_id,46 softwaresource.branch_revision as git_commit_id,
47 coalesce(namedattribute_git_describe.value, softwaresource.branch_revision) as git_describe,47 coalesce(namedattribute_git_describe.value, softwaresource.branch_revision) as git_describe,
48 coalesce(namedattribute_git_log_info.value, softwaresource.branch_revision) as git_log_info,48 coalesce(namedattribute_git_log_info.value, softwaresource.branch_revision) as git_log_info,
49 namedattribute_gitweb_url.value as gitweb_url,
49 softwaresource.commit_timestamp as commit_timestamp,50 softwaresource.commit_timestamp as commit_timestamp,
50 testrun.analyzer_assigned_date as build_date,51 testrun.analyzer_assigned_date as build_date,
51 namedattribute_kernelconfig.value as config,52 namedattribute_kernelconfig.value as config,
@@ -83,6 +84,13 @@
83 and namedattribute_git_log_info.content_type_id = (84 and namedattribute_git_log_info.content_type_id = (
84 select django_content_type.id from django_content_type85 select django_content_type.id from django_content_type
85 where app_label = 'dashboard_app' and model='testrun')86 where app_label = 'dashboard_app' and model='testrun')
87 )
88left outer join dashboard_app_namedattribute as namedattribute_gitweb_url
89 on (namedattribute_gitweb_url.object_id = testrun.id
90 and namedattribute_gitweb_url.name = 'kernel.gitweb_url'
91 and namedattribute_gitweb_url.content_type_id = (
92 select django_content_type.id from django_content_type
93 where app_label = 'dashboard_app' and model='testrun')
86 ),94 ),
87 dashboard_app_softwaresource as softwaresource,95 dashboard_app_softwaresource as softwaresource,
88 dashboard_app_testrun_sources as tr_ss_link96 dashboard_app_testrun_sources as tr_ss_link
@@ -202,12 +210,13 @@
202210
203211
204class Commit(object):212class Commit(object):
205 def __init__(self, sha1, commit_timestamp, describe, log_info, tree):213 def __init__(self, sha1, commit_timestamp, describe, log_info, gitweb_url, tree):
206 self.sha1 = sha1214 self.sha1 = sha1
207 self.commit_timestamp = commit_timestamp215 self.commit_timestamp = commit_timestamp
208 self.describe = describe216 self.describe = describe
209 self._builds = []217 self._builds = []
210 self.log_info = log_info218 self.log_info = log_info
219 self.gitweb_url = gitweb_url
211 self.tree = tree220 self.tree = tree
212 def add_build(self, config, result, sha1):221 def add_build(self, config, result, sha1):
213 build = Build(config, result, sha1, self)222 build = Build(config, result, sha1, self)
@@ -237,6 +246,18 @@
237 prev = self.prev.sha1246 prev = self.prev.sha1
238 else:247 else:
239 prev = None248 prev = None
249 commit_url = shortlog_url = None
250 if self.gitweb_url:
251 if 'github' in self.gitweb_url:
252 base_url = self.gitweb_url
253 if base_url.endswith('.git'):
254 base_url = base_url[:-len('.git')]
255 commit_url = base_url + '/commit/' + self.sha1
256 else:
257 commit_url = self.gitweb_url + ';a=commit;h=' + self.sha1
258 if self.prev:
259 shortlog_url = '%s;a=shortlog;h=%s;hp=%s' % (
260 self.gitweb_url, self.sha1, self.prev.sha1)
240 return {261 return {
241 'sha1': self.sha1,262 'sha1': self.sha1,
242 'describe': self.describe,263 'describe': self.describe,
@@ -244,6 +265,8 @@
244 'test_count': sum(len(build['tests']) for build in builds),265 'test_count': sum(len(build['tests']) for build in builds),
245 'prev': prev,266 'prev': prev,
246 'log_info': self.log_info,267 'log_info': self.log_info,
268 'commit_url': commit_url,
269 'shortlog_url': shortlog_url,
247 }270 }
248271
249272
@@ -253,13 +276,13 @@
253 self._commits = {}276 self._commits = {}
254 self.day = day277 self.day = day
255 self.index = index278 self.index = index
256 def get_commit(self, sha1, commit_timestamp, describe, log_info):279 def get_commit(self, sha1, commit_timestamp, describe, log_info, gitweb_url):
257 if sha1 in self._commits:280 if sha1 in self._commits:
258 # XXX if self._commits[sha1].commit_timestamp != commit_timestamp ...281 # XXX if self._commits[sha1].commit_timestamp != commit_timestamp ...
259 return self._commits[sha1]282 return self._commits[sha1]
260 else:283 else:
261 commit_obj = self._commits[sha1] = Commit(284 commit_obj = self._commits[sha1] = Commit(
262 sha1, commit_timestamp, describe, log_info, self)285 sha1, commit_timestamp, describe, log_info, gitweb_url, self)
263 return commit_obj286 return commit_obj
264 @property287 @property
265 def commits(self):288 def commits(self):
@@ -305,7 +328,7 @@
305 'trees': trees,328 'trees': trees,
306 'build_count': sum(tree['build_count'] for tree in trees),329 'build_count': sum(tree['build_count'] for tree in trees),
307 'test_count': sum(tree['test_count'] for tree in trees),330 'test_count': sum(tree['test_count'] for tree in trees),
308 'tree_count': len(trees),331 'tree_count': len([tree for tree in trees if tree['build_count'] > 0]),
309 }332 }
310333
311334
@@ -314,7 +337,12 @@
314 self.start = start337 self.start = start
315 self.finish = finish338 self.finish = finish
316 self._days = {}339 self._days = {}
317 d = start340 # We create a Day object for every day we're interested in, plus one
341 # day older so that we can find the previous build for the last row of
342 # builds displayed. This isn't quite enough, because the previous
343 # build might have been more than one day before the last one
344 # displayed, but for now it's a reasonable hack.
345 d = start - DAY_DELTA
318 while d < finish:346 while d < finish:
319 self._days[d] = Day(d, self)347 self._days[d] = Day(d, self)
320 d += DAY_DELTA348 d += DAY_DELTA
@@ -335,9 +363,10 @@
335 self._tree2index[git_url] = len(self._tree2index)363 self._tree2index[git_url] = len(self._tree2index)
336 tree = day.get_tree(git_url, self._tree2index[git_url])364 tree = day.get_tree(git_url, self._tree2index[git_url])
337 self.all_trees.add(tree)365 self.all_trees.add(tree)
366 print repr(build_results.gitweb_url)
338 commit = tree.get_commit(367 commit = tree.get_commit(
339 build_results.git_commit_id, build_results.commit_timestamp,368 build_results.git_commit_id, build_results.commit_timestamp,
340 build_results.git_describe, build_results.git_log_info)369 build_results.git_describe, build_results.git_log_info, build_results.gitweb_url)
341 config = build_results.config370 config = build_results.config
342 if config.endswith('_defconfig'):371 if config.endswith('_defconfig'):
343 config = config[:-len('_defconfig')]372 config = config[:-len('_defconfig')]
@@ -395,7 +424,7 @@
395 def evaluate(self):424 def evaluate(self):
396 connection = DataView.get_connection()425 connection = DataView.get_connection()
397 with contextlib.closing(connection.cursor()) as cursor:426 with contextlib.closing(connection.cursor()) as cursor:
398 cursor.execute(index_sql, (self.start, self.finish))427 cursor.execute(index_sql, (self.start - DAY_DELTA, self.finish))
399428
400 for build_result in fetchnamed(cursor):429 for build_result in fetchnamed(cursor):
401 self.add_build(build_result)430 self.add_build(build_result)
@@ -425,6 +454,8 @@
425 day_objs = self._days.values()454 day_objs = self._days.values()
426 day_objs.sort(key=key)455 day_objs.sort(key=key)
427 day_objs.reverse()456 day_objs.reverse()
457 # Remove the extra day (see __init__ for the comment about this).
458 del day_objs[-1]
428 trees = []459 trees = []
429 for url, index in sorted(self._tree2index.items()):460 for url, index in sorted(self._tree2index.items()):
430 trees.append({461 trees.append({
@@ -449,11 +480,11 @@
449 form.is_valid()480 form.is_valid()
450 start = form.cleaned_data['start']481 start = form.cleaned_data['start']
451 if start is None:482 if start is None:
452 start = datetime.date.today() - WEEK_DELTA483 start = datetime.date.today() - WEEK_DELTA + DAY_DELTA
453484
454 end = form.cleaned_data['end']485 end = form.cleaned_data['end']
455 if end is None:486 if end is None:
456 end = datetime.date.today()487 end = datetime.date.today() + DAY_DELTA
457488
458 day_collection = DayCollection(start, end)489 day_collection = DayCollection(start, end)
459490
@@ -466,7 +497,7 @@
466497
467 data = day_collection.json_ready()498 data = day_collection.json_ready()
468 newer_results_link = None499 newer_results_link = None
469 if end <= datetime.date.today():500 if end <= datetime.date.today() + DAY_DELTA:
470 newer_start = end501 newer_start = end
471 newer_end = max(502 newer_end = max(
472 newer_start + WEEK_DELTA, datetime.date.today())503 newer_start + WEEK_DELTA, datetime.date.today())

Subscribers

People subscribed via source and target branches

to all changes: