From patchwork Thu Nov 29 21:13:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 13296 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 098AD23FCC for ; Thu, 29 Nov 2012 21:13:21 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5F11DA18EF4 for ; Thu, 29 Nov 2012 21:13:20 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so8248241iag.11 for ; Thu, 29 Nov 2012 13:13:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=V8cgZ8Y85g93TCpSGp/BHWWDuKwKUsV7jtHZzaHPQCc=; b=ZGhcWMrOM7zBs0dNc5Wzi4E8ug+i3KR2w9e7FnzRqS0OaVr2AzZFQ4ThpDmMRYeimB kfWEbyoQ8A9cZSP7ZxwlvTL6g9mDNw+UgR9selS9z4HPRXMVLd31Zwjx8aa4CSULtTa4 Mg300xq2/4LdYgGCjHGqPcZwfvc9U3M+wjbwjwCcNnioKJOYRwIkP9leV/7E/iq1d2l+ Q2RDtyBoVrF/mda64jss/z2U/eaxz+2uCEBx7fB8SPuu/SQ5U+FAYKJnQddNgBRspkPj rlkRyzjWuEojis6eoUFOoPc/EAKx+R/dymvgf3Rpi0yWsGr0zew9ThWWrRlIEA/U2zkZ QQ6A== Received: by 10.50.187.197 with SMTP id fu5mr23980204igc.70.1354223599700; Thu, 29 Nov 2012 13:13:19 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp928158igt; Thu, 29 Nov 2012 13:13:18 -0800 (PST) Received: by 10.180.83.168 with SMTP id r8mr35424874wiy.2.1354223598046; Thu, 29 Nov 2012 13:13:18 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id c2si1800000wej.60.2012.11.29.13.13.17 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Nov 2012 13:13:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TeBQ5-0008A1-Au for ; Thu, 29 Nov 2012 21:13:17 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 47DCFE016E for ; Thu, 29 Nov 2012 21:13:17 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dashboard X-Launchpad-Branch: ~linaro-validation/lava-dashboard/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 367 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dashboard/trunk] Rev 367: * fix subscriptions to filters that do not specify any tests Message-Id: <20121129211317.26039.938.launchpad@ackee.canonical.com> Date: Thu, 29 Nov 2012 21:13:17 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16319"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 2d4234ad7ba26f35199dd3cff1cb65ab746df0c3 X-Gm-Message-State: ALoCoQlYlF9Td46pXgsyrsnV9jIML1rnQb+bCxuXY2E1fxz52pY52VibUddIxqlfs7GSrhU679mX Merge authors: Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 367 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Fri 2012-11-30 10:11:53 +1300 message: * fix subscriptions to filters that do not specify any tests * increase logging around sending subscription emails modified: dashboard_app/models.py --- lp:lava-dashboard https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk You are subscribed to branch lp:lava-dashboard. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk/+edit-subscription === modified file 'dashboard_app/models.py' --- dashboard_app/models.py 2012-11-08 23:10:05 +0000 +++ dashboard_app/models.py 2012-11-27 21:54:28 +0000 @@ -1872,7 +1872,7 @@ @classmethod def matches_against_bundle(self, bundle): bundle_filters = bundle.bundle_stream.testrunfilter_set.all() - attribute_filters = list(bundle_filters.extra( + attribute_filters = bundle_filters.extra( where=[ """(select min((select count(*) from dashboard_app_testrunfilterattribute @@ -1884,8 +1884,9 @@ where app_label = 'dashboard_app' and model='testrun') and object_id = dashboard_app_testrun.id))) from dashboard_app_testrun where dashboard_app_testrun.bundle_id = %s) = 0""" % bundle.id], - )) - no_test_filters = []#list(attribute_filters.annotate(models.Count('tests')).filter(tests__count=0)) + ) + no_test_filters = list(attribute_filters.annotate(models.Count('tests')).filter(tests__count=0)) + attribute_filters = list(attribute_filters) no_test_case_filters = list( TestRunFilter.objects.filter( id__in=TestRunFilterTest.objects.filter( @@ -2002,24 +2003,29 @@ def send_bundle_notifications(sender, bundle, **kwargs): - recipients = TestRunFilterSubscription.recipients_for_bundle(bundle) - domain = '???' try: - site = Site.objects.get_current() - except (Site.DoesNotExist, ImproperlyConfigured): - pass - else: - domain = site.domain - url_prefix = 'http://%s' % domain - for user, matches in recipients.items(): - data = {'bundle': bundle, 'user': user, 'matches': matches, 'url_prefix': url_prefix} - mail = render_to_string( - 'dashboard_app/filter_subscription_mail.txt', - data) - filter_names = ', '.join(match.filter.name for match in matches) - send_mail( - "LAVA result notification: " + filter_names, mail, - settings.SERVER_EMAIL, [user.email]) + recipients = TestRunFilterSubscription.recipients_for_bundle(bundle) + domain = '???' + try: + site = Site.objects.get_current() + except (Site.DoesNotExist, ImproperlyConfigured): + pass + else: + domain = site.domain + url_prefix = 'http://%s' % domain + for user, matches in recipients.items(): + logging.info("sending bundle notification to %s", user) + data = {'bundle': bundle, 'user': user, 'matches': matches, 'url_prefix': url_prefix} + mail = render_to_string( + 'dashboard_app/filter_subscription_mail.txt', + data) + filter_names = ', '.join(match.filter.name for match in matches) + send_mail( + "LAVA result notification: " + filter_names, mail, + settings.SERVER_EMAIL, [user.email]) + except: + logging.exception("send_bundle_notifications failed") + raise bundle_was_deserialized.connect(send_bundle_notifications)