Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
Restructure build emails
Browse files Browse the repository at this point in the history
Summary:
With this diff, changes emails are structured as follows:

Builds summary.

for each build in build_collection:
  for each job in build:
    Failing tests.
    Relevant logs.

Test Plan: Unit tests, render builds exported from prod. locally, test emails in real email clients.

Reviewers: cf, cramer, vishal

Reviewed By: vishal

Subscribers: jukka, dfb-reviews, ar, alexallain, changesbot, reviews-dfbgrowth

Differential Revision: https://tails.corp.dropbox.com/D80946
  • Loading branch information
kajic committed Feb 25, 2015
1 parent 010993b commit 5f9a84e
Show file tree
Hide file tree
Showing 14 changed files with 866 additions and 618 deletions.
4 changes: 2 additions & 2 deletions changes/api/build_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_failure_reasons(build):
]


def _get_patch_parent_last_build(build):
def get_patch_parent_last_build(build):
if build.source.patch:
parent_revision_builds = list(Build.query.filter(
Build.project == build.project,
Expand Down Expand Up @@ -228,7 +228,7 @@ def get(self, build_id):
'tests': self.serialize(test_failures, extended_serializers),
},
'testChanges': self.serialize(changed_tests, extended_serializers),
'parentRevisionBuild': self.serialize(_get_patch_parent_last_build(build)),
'parentRevisionBuild': self.serialize(get_patch_parent_last_build(build)),
})

return self.respond(context)
Expand Down
8 changes: 5 additions & 3 deletions changes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def create_app(_read_config=True, **config):

app.config['EVENT_LISTENERS'] = (
('changes.listeners.mail.job_finished_handler', 'job.finished'),
('changes.listeners.mail.build_finished_handler', 'build.finished'),
('changes.listeners.green_build.build_finished_handler', 'build.finished'),
('changes.listeners.hipchat.build_finished_handler', 'build.finished'),
('changes.listeners.build_revision.revision_created_handler', 'revision.created'),
Expand Down Expand Up @@ -282,9 +283,10 @@ def configure_debug_toolbar(app):

def configure_templates(app):
from changes.utils.times import duration
from changes.utils.text import nl2br
from changes.utils.text import break_long_lines, nl2br

app.jinja_env.filters['duration'] = duration
app.jinja_env.filters['break_long_lines'] = break_long_lines
app.jinja_env.filters['nl2br'] = nl2br


Expand Down Expand Up @@ -472,12 +474,12 @@ def configure_web_routes(app):

def configure_debug_routes(app):
from changes.debug.reports.build import BuildReportMailView
from changes.debug.mail.job_result import JobResultMailView
from changes.debug.mail.build_result import BuildResultMailView

app.add_url_rule(
'/debug/mail/report/build/', view_func=BuildReportMailView.as_view('debug-build-report'))
app.add_url_rule(
'/debug/mail/result/job/<job_id>/', view_func=JobResultMailView.as_view('debug-build-result'))
'/debug/mail/result/build/<build_id>/', view_func=BuildResultMailView.as_view('debug-build-result'))


def configure_jobs(app):
Expand Down
24 changes: 24 additions & 0 deletions changes/debug/mail/build_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from flask import render_template
from flask.views import MethodView

from changes.models.build import Build
from changes.listeners.mail import MailNotificationHandler


class BuildResultMailView(MethodView):
def get(self, build_id):
build = Build.query.get(build_id)
assert build, 'There is no build for {}'.format(build_id)

builds = list(
Build.query.filter(Build.collection_id == build.collection_id))
notification_handler = MailNotificationHandler()
context = notification_handler.get_collection_context(builds)
msg = notification_handler.get_msg(context)
return render_template(
'debug/email.html',
recipients=msg.recipients,
subject=msg.subject,
text_content=msg.body,
html_content=msg.html,
)
26 changes: 0 additions & 26 deletions changes/debug/mail/job_result.py

This file was deleted.

0 comments on commit 5f9a84e

Please sign in to comment.