From patchwork Tue Mar 29 18:57:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1610795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=OpD43ibF; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KSf2n1MZBz9sCq for ; Wed, 30 Mar 2022 05:57:52 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KSf2m36rDz2yJ9 for ; Wed, 30 Mar 2022 05:57:52 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=OpD43ibF; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=that.guru (client-ip=136.175.108.186; helo=mail-108-mta186.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=OpD43ibF; dkim-atps=neutral Received: from mail-108-mta186.mxroute.com (mail-108-mta186.mxroute.com [136.175.108.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KSf2d3Pt4z2x9c for ; Wed, 30 Mar 2022 05:57:44 +1100 (AEDT) Received: from filter006.mxroute.com ([140.82.40.27] 140.82.40.27.vultrusercontent.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta186.mxroute.com (ZoneMTA) with ESMTPSA id 17fd70a6d7f000fe85.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Tue, 29 Mar 2022 18:57:39 +0000 X-Zone-Loop: 7e35291e6ca7c81aa8702866b077ae56829073c4b6a4 X-Originating-IP: [140.82.40.27] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To: From:Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=DqwUnuueRNjsx3kbiJI/TOiBlTERswsEEh6pMejVv1o=; b=O pD43ibFFYeUReGvs6jEqKIbAoxyHuz8Dor7H17GANl2+ncLGmUvU/wyloLa9a/+kkNhfVkJwWyfHZ UbWz2TM5JSfdVZyusO2UaRK0iP53jbgcpQbRo7te7umxQ3ExhNwNWZjLaZH8ircMWv5ntB6G4umFx gV93TwsASSU9asTmz0bUDQxv7zXdl1BwVgeL/ydjUG6niBINcTtq7qAdP1O/dqBP3M/BQTSjRTE2a EFk/xpTyjVuNEuFgFRrVaPj9Q58fXo0jzpyNlX5DWitueS/fMuEKHZ6NxQz0ivSgc6r2sba7Icu8t uDX4H8kyXQ2zJ5Pi+S/K7vvjKT0+CQpuA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 1/2] docs: Don't version events Date: Tue, 29 Mar 2022 19:57:31 +0100 Message-Id: <20220329185732.401187-1-stephen@that.guru> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" We don't actually version the types of events we emit. Doing so would be possible, but this ship has already sailed (with API version 1.2). We also remove some unnecessary line breaks. Signed-off-by: Stephen Finucane --- docs/api/schemas/latest/patchwork.yaml | 21 +++++++------ docs/api/schemas/patchwork.j2 | 29 +++++++----------- docs/api/schemas/v1.0/patchwork.yaml | 41 ++++++++++++++++++++------ docs/api/schemas/v1.1/patchwork.yaml | 41 ++++++++++++++++++++------ docs/api/schemas/v1.2/patchwork.yaml | 21 +++++++------ docs/api/schemas/v1.3/patchwork.yaml | 21 +++++++------ 6 files changed, 104 insertions(+), 70 deletions(-) diff --git docs/api/schemas/latest/patchwork.yaml docs/api/schemas/latest/patchwork.yaml index 2a98c179..43edfb04 100644 --- docs/api/schemas/latest/patchwork.yaml +++ docs/api/schemas/latest/patchwork.yaml @@ -402,7 +402,11 @@ paths: type: string - in: query name: category - description: An event category to filter events by. + description: > + An event category to filter events by. These categories are subject + to change depending on the version of Patchwork deployed and are + not subject to the versionining constraints present across the rest + of the API. schema: title: '' type: string @@ -460,18 +464,13 @@ paths: mapping: cover-created: '#/components/schemas/EventCoverCreated' patch-created: '#/components/schemas/EventPatchCreated' - patch-completed: > - '#/components/schemas/EventPatchCompleted' - patch-state-changed: > - '#/components/schemas/EventPatchStateChanged' - patch-relation-changed: > - '#/components/schemas/EventPatchRelationChanged' - patch-delegated: > - '#/components/schemas/EventPatchDelegated' + patch-completed: '#/components/schemas/EventPatchCompleted' + patch-state-changed: '#/components/schemas/EventPatchStateChanged' + patch-relation-changed: '#/components/schemas/EventPatchRelationChanged' + patch-delegated: '#/components/schemas/EventPatchDelegated' check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' - series-completed: > - '#/components/schemas/EventSeriesCompleted' + series-completed: '#/components/schemas/EventSeriesCompleted' tags: - events /api/patches/: diff --git docs/api/schemas/patchwork.j2 docs/api/schemas/patchwork.j2 index 02aa9f72..df72c1ac 100644 --- docs/api/schemas/patchwork.j2 +++ docs/api/schemas/patchwork.j2 @@ -413,7 +413,11 @@ paths: type: string - in: query name: category - description: An event category to filter events by. + description: > + An event category to filter events by. These categories are subject + to change depending on the version of Patchwork deployed and are + not subject to the versionining constraints present across the rest + of the API. schema: title: '' type: string @@ -422,9 +426,7 @@ paths: - patch-created - patch-completed - patch-state-changed -{% if version >= (1, 2) %} - patch-relation-changed -{% endif %} - patch-delegated - check-created - series-created @@ -463,9 +465,7 @@ paths: - $ref: '#/components/schemas/EventPatchCreated' - $ref: '#/components/schemas/EventPatchCompleted' - $ref: '#/components/schemas/EventPatchStateChanged' -{% if version >= (1, 2) %} - $ref: '#/components/schemas/EventPatchRelationChanged' -{% endif %} - $ref: '#/components/schemas/EventPatchDelegated' - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' @@ -475,20 +475,13 @@ paths: mapping: cover-created: '#/components/schemas/EventCoverCreated' patch-created: '#/components/schemas/EventPatchCreated' - patch-completed: > - '#/components/schemas/EventPatchCompleted' - patch-state-changed: > - '#/components/schemas/EventPatchStateChanged' -{% if version >= (1, 2) %} - patch-relation-changed: > - '#/components/schemas/EventPatchRelationChanged' -{% endif %} - patch-delegated: > - '#/components/schemas/EventPatchDelegated' + patch-completed: '#/components/schemas/EventPatchCompleted' + patch-state-changed: '#/components/schemas/EventPatchStateChanged' + patch-relation-changed: '#/components/schemas/EventPatchRelationChanged' + patch-delegated: '#/components/schemas/EventPatchDelegated' check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' - series-completed: > - '#/components/schemas/EventSeriesCompleted' + series-completed: '#/components/schemas/EventSeriesCompleted' tags: - events /api/{{ version_url }}patches/: @@ -1922,7 +1915,6 @@ components: current_state: title: Current state type: string -{% if version >= (1, 2) %} EventPatchRelationChanged: allOf: - $ref: '#/components/schemas/EventBase' @@ -1943,7 +1935,6 @@ components: title: Current relation type: string nullable: true -{% endif %} EventPatchDelegated: allOf: - $ref: '#/components/schemas/EventBase' diff --git docs/api/schemas/v1.0/patchwork.yaml docs/api/schemas/v1.0/patchwork.yaml index 23e8930a..e2f1362f 100644 --- docs/api/schemas/v1.0/patchwork.yaml +++ docs/api/schemas/v1.0/patchwork.yaml @@ -228,7 +228,11 @@ paths: type: string - in: query name: category - description: An event category to filter events by. + description: > + An event category to filter events by. These categories are subject + to change depending on the version of Patchwork deployed and are + not subject to the versionining constraints present across the rest + of the API. schema: title: '' type: string @@ -237,6 +241,7 @@ paths: - patch-created - patch-completed - patch-state-changed + - patch-relation-changed - patch-delegated - check-created - series-created @@ -275,6 +280,7 @@ paths: - $ref: '#/components/schemas/EventPatchCreated' - $ref: '#/components/schemas/EventPatchCompleted' - $ref: '#/components/schemas/EventPatchStateChanged' + - $ref: '#/components/schemas/EventPatchRelationChanged' - $ref: '#/components/schemas/EventPatchDelegated' - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' @@ -284,16 +290,13 @@ paths: mapping: cover-created: '#/components/schemas/EventCoverCreated' patch-created: '#/components/schemas/EventPatchCreated' - patch-completed: > - '#/components/schemas/EventPatchCompleted' - patch-state-changed: > - '#/components/schemas/EventPatchStateChanged' - patch-delegated: > - '#/components/schemas/EventPatchDelegated' + patch-completed: '#/components/schemas/EventPatchCompleted' + patch-state-changed: '#/components/schemas/EventPatchStateChanged' + patch-relation-changed: '#/components/schemas/EventPatchRelationChanged' + patch-delegated: '#/components/schemas/EventPatchDelegated' check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' - series-completed: > - '#/components/schemas/EventSeriesCompleted' + series-completed: '#/components/schemas/EventSeriesCompleted' tags: - events /api/1.0/patches/: @@ -1485,6 +1488,26 @@ components: current_state: title: Current state type: string + EventPatchRelationChanged: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-relation-changed + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + previous_relation: + title: Previous relation + type: string + nullable: true + current_relation: + title: Current relation + type: string + nullable: true EventPatchDelegated: allOf: - $ref: '#/components/schemas/EventBase' diff --git docs/api/schemas/v1.1/patchwork.yaml docs/api/schemas/v1.1/patchwork.yaml index 3b75c548..cdf8ef29 100644 --- docs/api/schemas/v1.1/patchwork.yaml +++ docs/api/schemas/v1.1/patchwork.yaml @@ -228,7 +228,11 @@ paths: type: string - in: query name: category - description: An event category to filter events by. + description: > + An event category to filter events by. These categories are subject + to change depending on the version of Patchwork deployed and are + not subject to the versionining constraints present across the rest + of the API. schema: title: '' type: string @@ -237,6 +241,7 @@ paths: - patch-created - patch-completed - patch-state-changed + - patch-relation-changed - patch-delegated - check-created - series-created @@ -275,6 +280,7 @@ paths: - $ref: '#/components/schemas/EventPatchCreated' - $ref: '#/components/schemas/EventPatchCompleted' - $ref: '#/components/schemas/EventPatchStateChanged' + - $ref: '#/components/schemas/EventPatchRelationChanged' - $ref: '#/components/schemas/EventPatchDelegated' - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' @@ -284,16 +290,13 @@ paths: mapping: cover-created: '#/components/schemas/EventCoverCreated' patch-created: '#/components/schemas/EventPatchCreated' - patch-completed: > - '#/components/schemas/EventPatchCompleted' - patch-state-changed: > - '#/components/schemas/EventPatchStateChanged' - patch-delegated: > - '#/components/schemas/EventPatchDelegated' + patch-completed: '#/components/schemas/EventPatchCompleted' + patch-state-changed: '#/components/schemas/EventPatchStateChanged' + patch-relation-changed: '#/components/schemas/EventPatchRelationChanged' + patch-delegated: '#/components/schemas/EventPatchDelegated' check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' - series-completed: > - '#/components/schemas/EventSeriesCompleted' + series-completed: '#/components/schemas/EventSeriesCompleted' tags: - events /api/1.1/patches/: @@ -1510,6 +1513,26 @@ components: current_state: title: Current state type: string + EventPatchRelationChanged: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-relation-changed + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + previous_relation: + title: Previous relation + type: string + nullable: true + current_relation: + title: Current relation + type: string + nullable: true EventPatchDelegated: allOf: - $ref: '#/components/schemas/EventBase' diff --git docs/api/schemas/v1.2/patchwork.yaml docs/api/schemas/v1.2/patchwork.yaml index 17d948a2..2a37d81b 100644 --- docs/api/schemas/v1.2/patchwork.yaml +++ docs/api/schemas/v1.2/patchwork.yaml @@ -336,7 +336,11 @@ paths: type: string - in: query name: category - description: An event category to filter events by. + description: > + An event category to filter events by. These categories are subject + to change depending on the version of Patchwork deployed and are + not subject to the versionining constraints present across the rest + of the API. schema: title: '' type: string @@ -394,18 +398,13 @@ paths: mapping: cover-created: '#/components/schemas/EventCoverCreated' patch-created: '#/components/schemas/EventPatchCreated' - patch-completed: > - '#/components/schemas/EventPatchCompleted' - patch-state-changed: > - '#/components/schemas/EventPatchStateChanged' - patch-relation-changed: > - '#/components/schemas/EventPatchRelationChanged' - patch-delegated: > - '#/components/schemas/EventPatchDelegated' + patch-completed: '#/components/schemas/EventPatchCompleted' + patch-state-changed: '#/components/schemas/EventPatchStateChanged' + patch-relation-changed: '#/components/schemas/EventPatchRelationChanged' + patch-delegated: '#/components/schemas/EventPatchDelegated' check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' - series-completed: > - '#/components/schemas/EventSeriesCompleted' + series-completed: '#/components/schemas/EventSeriesCompleted' tags: - events /api/1.2/patches/: diff --git docs/api/schemas/v1.3/patchwork.yaml docs/api/schemas/v1.3/patchwork.yaml index 0a9046a5..88c4e355 100644 --- docs/api/schemas/v1.3/patchwork.yaml +++ docs/api/schemas/v1.3/patchwork.yaml @@ -402,7 +402,11 @@ paths: type: string - in: query name: category - description: An event category to filter events by. + description: > + An event category to filter events by. These categories are subject + to change depending on the version of Patchwork deployed and are + not subject to the versionining constraints present across the rest + of the API. schema: title: '' type: string @@ -460,18 +464,13 @@ paths: mapping: cover-created: '#/components/schemas/EventCoverCreated' patch-created: '#/components/schemas/EventPatchCreated' - patch-completed: > - '#/components/schemas/EventPatchCompleted' - patch-state-changed: > - '#/components/schemas/EventPatchStateChanged' - patch-relation-changed: > - '#/components/schemas/EventPatchRelationChanged' - patch-delegated: > - '#/components/schemas/EventPatchDelegated' + patch-completed: '#/components/schemas/EventPatchCompleted' + patch-state-changed: '#/components/schemas/EventPatchStateChanged' + patch-relation-changed: '#/components/schemas/EventPatchRelationChanged' + patch-delegated: '#/components/schemas/EventPatchDelegated' check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' - series-completed: > - '#/components/schemas/EventSeriesCompleted' + series-completed: '#/components/schemas/EventSeriesCompleted' tags: - events /api/1.3/patches/: From patchwork Tue Mar 29 18:57:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1610796 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=QeFqMuA+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KSf2t74mFz9sCq for ; Wed, 30 Mar 2022 05:57:58 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KSf2t67wNz2xvS for ; Wed, 30 Mar 2022 05:57:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=QeFqMuA+; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=that.guru (client-ip=136.175.108.67; helo=mail-108-mta67.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=QeFqMuA+; dkim-atps=neutral Received: from mail-108-mta67.mxroute.com (mail-108-mta67.mxroute.com [136.175.108.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KSf2g6c13z2x9c for ; Wed, 30 Mar 2022 05:57:47 +1100 (AEDT) Received: from filter006.mxroute.com ([140.82.40.27] 140.82.40.27.vultrusercontent.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta67.mxroute.com (ZoneMTA) with ESMTPSA id 17fd70a7492000fe85.002 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Tue, 29 Mar 2022 18:57:41 +0000 X-Zone-Loop: c22d86c63206885c5528db6c93835885f359510c95ee X-Originating-IP: [140.82.40.27] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=x; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LxkHbJPt/aTCe7aSOFNW5aM0Nj2z3whjcpF8+s5E40M=; b=QeFqMuA+AClsfpTkdTsYQO/Aqn +rF/vZCCVaSX4i3wYT9+zylMbLmhxPG1wjgmhkJOt4bwG9arvXTB/DJxaXPNnu3x06KR7jrYSkObq 5RYFYRIFp/JpfXJfjiNhhZONsbA0DK6NEdTsA946yvty7XHHjn3ZcY91clsrhCr4LmP2b+vht/fgf afRRyQKB1K7F3+qGF+CoWWu3BSbwazi5nxdyfrR46GoE9ocSdXPP1luhScP13KGKxRhhIxtLCvODC kix4g+JNEGzVupmGnOxW1+peVMfC9+sIL6seC5sRwsnTlr2z13OxpO3X+c97wh0vPhmG1CobQQBDm aPXufUxQ==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 2/2] REST: Add 'patch-comment-created', 'cover-comment-created' events Date: Tue, 29 Mar 2022 19:57:32 +0100 Message-Id: <20220329185732.401187-2-stephen@that.guru> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220329185732.401187-1-stephen@that.guru> References: <20220329185732.401187-1-stephen@that.guru> MIME-Version: 1.0 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: DJ Delorie , DJ Delorie Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" From: DJ Delorie This patch stitches in "comment created" events for patches and cover letter into the event queue. Signed-off-by: DJ Delorie Signed-off-by: Stephen Finucane Closes: #424 [stephenfin: Extend to cover letters also. Fix some formatting issues. Add a release note] --- docs/api/schemas/latest/patchwork.yaml | 71 +++++++++++++++ docs/api/schemas/patchwork.j2 | 77 +++++++++++++++++ docs/api/schemas/v1.0/patchwork.yaml | 59 +++++++++++++ docs/api/schemas/v1.1/patchwork.yaml | 64 ++++++++++++++ docs/api/schemas/v1.2/patchwork.yaml | 69 +++++++++++++++ docs/api/schemas/v1.3/patchwork.yaml | 71 +++++++++++++++ patchwork/api/embedded.py | 36 ++++++++ patchwork/api/event.py | 86 +++++++++++++++---- .../migrations/0046_patch_comment_events.py | 56 ++++++++++++ patchwork/models.py | 16 ++++ patchwork/signals.py | 30 +++++++ patchwork/tests/test_signals.py | 36 +++++++- .../comment-events-2bc9b754cad1fb32.yaml | 6 ++ 13 files changed, 657 insertions(+), 20 deletions(-) create mode 100644 patchwork/migrations/0046_patch_comment_events.py create mode 100644 releasenotes/notes/comment-events-2bc9b754cad1fb32.yaml diff --git docs/api/schemas/latest/patchwork.yaml docs/api/schemas/latest/patchwork.yaml index 43edfb04..06be99d3 100644 --- docs/api/schemas/latest/patchwork.yaml +++ docs/api/schemas/latest/patchwork.yaml @@ -420,6 +420,8 @@ paths: - check-created - series-created - series-completed + - cover-comment-created + - patch-comment-created - in: query name: series description: An ID of a series to filter events by. @@ -459,6 +461,8 @@ paths: - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' - $ref: '#/components/schemas/EventSeriesCompleted' + - $ref: '#/components/schemas/EventCoverCommentCreated' + - $ref: '#/components/schemas/EventPatchCommentCreated' discriminator: propertyName: category mapping: @@ -471,6 +475,8 @@ paths: check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' series-completed: '#/components/schemas/EventSeriesCompleted' + cover-comment-created: '#/components/schemas/EventCoverCommentCreated' + patch-comment-created: '#/components/schemas/EventPatchCommentCreated' tags: - events /api/patches/: @@ -1919,6 +1925,34 @@ components: properties: series: $ref: '#/components/schemas/SeriesEmbedded' + EventCoverCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - cover-comment-created + payload: + properties: + cover: + $ref: '#/components/schemas/CoverEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' + EventPatchCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-comment-created + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' PatchList: required: - state @@ -2394,6 +2428,43 @@ components: maxLength: 255 minLength: 1 readOnly: true + CommentEmbedded: + type: object + properties: + id: + title: ID + type: integer + readOnly: true + url: + title: URL + type: string + format: uri + readOnly: true + web_url: + title: Web URL + type: string + format: uri + readOnly: true + msgid: + title: Message ID + type: string + readOnly: true + minLength: 1 + list_archive_url: + title: List archive URL + type: string + readOnly: true + nullable: true + date: + title: Date + type: string + format: iso8601 + readOnly: true + name: + title: Name + type: string + readOnly: true + minLength: 1 CoverEmbedded: type: object properties: diff --git docs/api/schemas/patchwork.j2 docs/api/schemas/patchwork.j2 index df72c1ac..f8c6d214 100644 --- docs/api/schemas/patchwork.j2 +++ docs/api/schemas/patchwork.j2 @@ -431,6 +431,10 @@ paths: - check-created - series-created - series-completed +{% if version >= (1, 3) %} + - cover-comment-created + - patch-comment-created +{% endif %} - in: query name: series description: An ID of a series to filter events by. @@ -470,6 +474,8 @@ paths: - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' - $ref: '#/components/schemas/EventSeriesCompleted' + - $ref: '#/components/schemas/EventCoverCommentCreated' + - $ref: '#/components/schemas/EventPatchCommentCreated' discriminator: propertyName: category mapping: @@ -482,6 +488,8 @@ paths: check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' series-completed: '#/components/schemas/EventSeriesCompleted' + cover-comment-created: '#/components/schemas/EventCoverCommentCreated' + patch-comment-created: '#/components/schemas/EventPatchCommentCreated' tags: - events /api/{{ version_url }}patches/: @@ -1989,6 +1997,34 @@ components: properties: series: $ref: '#/components/schemas/SeriesEmbedded' + EventCoverCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - cover-comment-created + payload: + properties: + cover: + $ref: '#/components/schemas/CoverEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' + EventPatchCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-comment-created + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' PatchList: required: - state @@ -2482,6 +2518,47 @@ components: maxLength: 255 minLength: 1 readOnly: true + CommentEmbedded: + type: object + properties: + id: + title: ID + type: integer + readOnly: true + url: + title: URL + type: string + format: uri + readOnly: true +{% if version >= (1, 1) %} + web_url: + title: Web URL + type: string + format: uri + readOnly: true +{% endif %} + msgid: + title: Message ID + type: string + readOnly: true + minLength: 1 +{% if version >= (1, 2) %} + list_archive_url: + title: List archive URL + type: string + readOnly: true + nullable: true +{% endif %} + date: + title: Date + type: string + format: iso8601 + readOnly: true + name: + title: Name + type: string + readOnly: true + minLength: 1 CoverEmbedded: type: object properties: diff --git docs/api/schemas/v1.0/patchwork.yaml docs/api/schemas/v1.0/patchwork.yaml index e2f1362f..53571b60 100644 --- docs/api/schemas/v1.0/patchwork.yaml +++ docs/api/schemas/v1.0/patchwork.yaml @@ -285,6 +285,8 @@ paths: - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' - $ref: '#/components/schemas/EventSeriesCompleted' + - $ref: '#/components/schemas/EventCoverCommentCreated' + - $ref: '#/components/schemas/EventPatchCommentCreated' discriminator: propertyName: category mapping: @@ -297,6 +299,8 @@ paths: check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' series-completed: '#/components/schemas/EventSeriesCompleted' + cover-comment-created: '#/components/schemas/EventCoverCommentCreated' + patch-comment-created: '#/components/schemas/EventPatchCommentCreated' tags: - events /api/1.0/patches/: @@ -1562,6 +1566,34 @@ components: properties: series: $ref: '#/components/schemas/SeriesEmbedded' + EventCoverCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - cover-comment-created + payload: + properties: + cover: + $ref: '#/components/schemas/CoverEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' + EventPatchCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-comment-created + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' PatchList: required: - state @@ -1951,6 +1983,33 @@ components: maxLength: 255 minLength: 1 readOnly: true + CommentEmbedded: + type: object + properties: + id: + title: ID + type: integer + readOnly: true + url: + title: URL + type: string + format: uri + readOnly: true + msgid: + title: Message ID + type: string + readOnly: true + minLength: 1 + date: + title: Date + type: string + format: iso8601 + readOnly: true + name: + title: Name + type: string + readOnly: true + minLength: 1 CoverEmbedded: type: object properties: diff --git docs/api/schemas/v1.1/patchwork.yaml docs/api/schemas/v1.1/patchwork.yaml index cdf8ef29..f83b5e01 100644 --- docs/api/schemas/v1.1/patchwork.yaml +++ docs/api/schemas/v1.1/patchwork.yaml @@ -285,6 +285,8 @@ paths: - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' - $ref: '#/components/schemas/EventSeriesCompleted' + - $ref: '#/components/schemas/EventCoverCommentCreated' + - $ref: '#/components/schemas/EventPatchCommentCreated' discriminator: propertyName: category mapping: @@ -297,6 +299,8 @@ paths: check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' series-completed: '#/components/schemas/EventSeriesCompleted' + cover-comment-created: '#/components/schemas/EventCoverCommentCreated' + patch-comment-created: '#/components/schemas/EventPatchCommentCreated' tags: - events /api/1.1/patches/: @@ -1587,6 +1591,34 @@ components: properties: series: $ref: '#/components/schemas/SeriesEmbedded' + EventCoverCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - cover-comment-created + payload: + properties: + cover: + $ref: '#/components/schemas/CoverEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' + EventPatchCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-comment-created + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' PatchList: required: - state @@ -2002,6 +2034,38 @@ components: maxLength: 255 minLength: 1 readOnly: true + CommentEmbedded: + type: object + properties: + id: + title: ID + type: integer + readOnly: true + url: + title: URL + type: string + format: uri + readOnly: true + web_url: + title: Web URL + type: string + format: uri + readOnly: true + msgid: + title: Message ID + type: string + readOnly: true + minLength: 1 + date: + title: Date + type: string + format: iso8601 + readOnly: true + name: + title: Name + type: string + readOnly: true + minLength: 1 CoverEmbedded: type: object properties: diff --git docs/api/schemas/v1.2/patchwork.yaml docs/api/schemas/v1.2/patchwork.yaml index 2a37d81b..e8cee0e5 100644 --- docs/api/schemas/v1.2/patchwork.yaml +++ docs/api/schemas/v1.2/patchwork.yaml @@ -393,6 +393,8 @@ paths: - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' - $ref: '#/components/schemas/EventSeriesCompleted' + - $ref: '#/components/schemas/EventCoverCommentCreated' + - $ref: '#/components/schemas/EventPatchCommentCreated' discriminator: propertyName: category mapping: @@ -405,6 +407,8 @@ paths: check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' series-completed: '#/components/schemas/EventSeriesCompleted' + cover-comment-created: '#/components/schemas/EventCoverCommentCreated' + patch-comment-created: '#/components/schemas/EventPatchCommentCreated' tags: - events /api/1.2/patches/: @@ -1770,6 +1774,34 @@ components: properties: series: $ref: '#/components/schemas/SeriesEmbedded' + EventCoverCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - cover-comment-created + payload: + properties: + cover: + $ref: '#/components/schemas/CoverEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' + EventPatchCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-comment-created + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' PatchList: required: - state @@ -2245,6 +2277,43 @@ components: maxLength: 255 minLength: 1 readOnly: true + CommentEmbedded: + type: object + properties: + id: + title: ID + type: integer + readOnly: true + url: + title: URL + type: string + format: uri + readOnly: true + web_url: + title: Web URL + type: string + format: uri + readOnly: true + msgid: + title: Message ID + type: string + readOnly: true + minLength: 1 + list_archive_url: + title: List archive URL + type: string + readOnly: true + nullable: true + date: + title: Date + type: string + format: iso8601 + readOnly: true + name: + title: Name + type: string + readOnly: true + minLength: 1 CoverEmbedded: type: object properties: diff --git docs/api/schemas/v1.3/patchwork.yaml docs/api/schemas/v1.3/patchwork.yaml index 88c4e355..8b3b1154 100644 --- docs/api/schemas/v1.3/patchwork.yaml +++ docs/api/schemas/v1.3/patchwork.yaml @@ -420,6 +420,8 @@ paths: - check-created - series-created - series-completed + - cover-comment-created + - patch-comment-created - in: query name: series description: An ID of a series to filter events by. @@ -459,6 +461,8 @@ paths: - $ref: '#/components/schemas/EventCheckCreated' - $ref: '#/components/schemas/EventSeriesCreated' - $ref: '#/components/schemas/EventSeriesCompleted' + - $ref: '#/components/schemas/EventCoverCommentCreated' + - $ref: '#/components/schemas/EventPatchCommentCreated' discriminator: propertyName: category mapping: @@ -471,6 +475,8 @@ paths: check-created: '#/components/schemas/EventCheckCreated' series-created: '#/components/schemas/EventSeriesCreated' series-completed: '#/components/schemas/EventSeriesCompleted' + cover-comment-created: '#/components/schemas/EventCoverCommentCreated' + patch-comment-created: '#/components/schemas/EventPatchCommentCreated' tags: - events /api/1.3/patches/: @@ -1919,6 +1925,34 @@ components: properties: series: $ref: '#/components/schemas/SeriesEmbedded' + EventCoverCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - cover-comment-created + payload: + properties: + cover: + $ref: '#/components/schemas/CoverEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' + EventPatchCommentCreated: + allOf: + - $ref: '#/components/schemas/EventBase' + - type: object + properties: + category: + enum: + - patch-comment-created + payload: + properties: + patch: + $ref: '#/components/schemas/PatchEmbedded' + comment: + $ref: '#/components/schemas/CommentEmbedded' PatchList: required: - state @@ -2394,6 +2428,43 @@ components: maxLength: 255 minLength: 1 readOnly: true + CommentEmbedded: + type: object + properties: + id: + title: ID + type: integer + readOnly: true + url: + title: URL + type: string + format: uri + readOnly: true + web_url: + title: Web URL + type: string + format: uri + readOnly: true + msgid: + title: Message ID + type: string + readOnly: true + minLength: 1 + list_archive_url: + title: List archive URL + type: string + readOnly: true + nullable: true + date: + title: Date + type: string + format: iso8601 + readOnly: true + name: + title: Name + type: string + readOnly: true + minLength: 1 CoverEmbedded: type: object properties: diff --git patchwork/api/embedded.py patchwork/api/embedded.py index 78316979..4ba80f4a 100644 --- patchwork/api/embedded.py +++ patchwork/api/embedded.py @@ -120,6 +120,24 @@ class CoverSerializer(SerializedRelatedField): } +class CoverCommentSerializer(SerializedRelatedField): + + class _Serializer(MboxMixin, WebURLMixin, BaseHyperlinkedModelSerializer): + + class Meta: + model = models.CoverComment + fields = ('id', 'url', 'web_url', 'msgid', 'list_archive_url', + 'date', 'name') + read_only_fields = fields + versioned_fields = { + '1.1': ('web_url', 'mbox', ), + '1.2': ('list_archive_url',), + } + extra_kwargs = { + 'url': {'view_name': 'api-cover-comment-detail'}, + } + + class PatchSerializer(SerializedRelatedField): class _Serializer(MboxMixin, WebURLMixin, BaseHyperlinkedModelSerializer): @@ -138,6 +156,24 @@ class PatchSerializer(SerializedRelatedField): } +class PatchCommentSerializer(SerializedRelatedField): + + class _Serializer(MboxMixin, WebURLMixin, BaseHyperlinkedModelSerializer): + + class Meta: + model = models.PatchComment + fields = ('id', 'url', 'web_url', 'msgid', 'list_archive_url', + 'date', 'name') + read_only_fields = fields + versioned_fields = { + '1.1': ('web_url', 'mbox', ), + '1.2': ('list_archive_url',), + } + extra_kwargs = { + 'url': {'view_name': 'api-patch-comment-detail'}, + } + + class PersonSerializer(SerializedRelatedField): class _Serializer(BaseHyperlinkedModelSerializer): diff --git patchwork/api/event.py patchwork/api/event.py index 71f95937..c1b09ab9 100644 --- patchwork/api/event.py +++ patchwork/api/event.py @@ -12,7 +12,9 @@ from rest_framework.serializers import SlugRelatedField from patchwork.api.embedded import CheckSerializer from patchwork.api.embedded import CoverSerializer +from patchwork.api.embedded import CoverCommentSerializer from patchwork.api.embedded import PatchSerializer +from patchwork.api.embedded import PatchCommentSerializer from patchwork.api.embedded import ProjectSerializer from patchwork.api.embedded import SeriesSerializer from patchwork.api.embedded import UserSerializer @@ -35,20 +37,41 @@ class EventSerializer(ModelSerializer): created_check = CheckSerializer() previous_relation = SerializerMethodField() current_relation = SerializerMethodField() + cover_comment = CoverCommentSerializer() + patch_comment = PatchCommentSerializer() + # Mapping of event type to fields to include in the response _category_map = { Event.CATEGORY_COVER_CREATED: ['cover'], Event.CATEGORY_PATCH_CREATED: ['patch'], Event.CATEGORY_PATCH_COMPLETED: ['patch', 'series'], - Event.CATEGORY_PATCH_STATE_CHANGED: ['patch', 'previous_state', - 'current_state'], - Event.CATEGORY_PATCH_DELEGATED: ['patch', 'previous_delegate', - 'current_delegate'], - Event.CATEGORY_PATCH_RELATION_CHANGED: ['patch', 'previous_relation', - 'current_relation'], + Event.CATEGORY_PATCH_STATE_CHANGED: [ + 'patch', + 'previous_state', + 'current_state', + ], + Event.CATEGORY_PATCH_DELEGATED: [ + 'patch', + 'previous_delegate', + 'current_delegate', + ], + Event.CATEGORY_PATCH_RELATION_CHANGED: [ + 'patch', + 'previous_relation', + 'current_relation', + ], Event.CATEGORY_CHECK_CREATED: ['patch', 'created_check'], Event.CATEGORY_SERIES_CREATED: ['series'], Event.CATEGORY_SERIES_COMPLETED: ['series'], + Event.CATEGORY_COVER_COMMENT_CREATED: ['cover', 'cover_comment'], + Event.CATEGORY_PATCH_COMMENT_CREATED: ['patch', 'patch_comment'], + } + + # Mapping of database column names to REST API representations + _field_name_map = { + 'created_check': 'check', + 'cover_comment': 'comment', + 'patch_comment': 'comment', } def get_previous_relation(self, instance): @@ -61,13 +84,19 @@ class EventSerializer(ModelSerializer): data = super(EventSerializer, self).to_representation(instance) payload = OrderedDict() kept_fields = self._category_map[instance.category] + [ - 'id', 'category', 'project', 'date', 'actor'] + 'id', + 'category', + 'project', + 'date', + 'actor', + ] for field in [x for x in data]: if field not in kept_fields: del data[field] elif field in self._category_map[instance.category]: - field_name = 'check' if field == 'created_check' else field + # remap fields if necessary + field_name = self._field_name_map.get(field, field) payload[field_name] = data.pop(field) data['payload'] = payload @@ -77,14 +106,27 @@ class EventSerializer(ModelSerializer): class Meta: model = Event fields = ( - 'id', 'category', 'project', 'date', 'actor', 'patch', - 'series', 'cover', 'previous_state', 'current_state', - 'previous_delegate', 'current_delegate', 'created_check', - 'previous_relation', 'current_relation', + 'id', + 'category', + 'project', + 'date', + 'actor', + 'patch', + 'series', + 'cover', + 'previous_state', + 'current_state', + 'previous_delegate', + 'current_delegate', + 'created_check', + 'previous_relation', + 'current_relation', + 'cover_comment', + 'patch_comment', ) read_only_fields = fields versioned_fields = { - '1.2': ('actor', ), + '1.2': ('actor',), } @@ -98,8 +140,16 @@ class EventList(ListAPIView): ordering = '-date' def get_queryset(self): - return Event.objects.all()\ - .prefetch_related('project', 'patch__project', 'series__project', - 'cover', 'previous_state', 'current_state', - 'previous_delegate', 'current_delegate', - 'created_check') + return Event.objects.all().prefetch_related( + 'project', + 'patch__project', + 'series__project', + 'cover', + 'previous_state', + 'current_state', + 'previous_delegate', + 'current_delegate', + 'created_check', + 'cover_comment', + 'patch_comment', + ) diff --git patchwork/migrations/0046_patch_comment_events.py patchwork/migrations/0046_patch_comment_events.py new file mode 100644 index 00000000..db198bd4 --- /dev/null +++ patchwork/migrations/0046_patch_comment_events.py @@ -0,0 +1,56 @@ +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('patchwork', '0045_addressed_fields'), + ] + + operations = [ + migrations.AddField( + model_name='event', + name='cover_comment', + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name='+', + to='patchwork.covercomment', + ), + ), + migrations.AddField( + model_name='event', + name='patch_comment', + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name='+', + to='patchwork.patchcomment', + ), + ), + migrations.AlterField( + model_name='event', + name='category', + field=models.CharField( + choices=[ + ('cover-created', 'Cover Letter Created'), + ('patch-created', 'Patch Created'), + ('patch-completed', 'Patch Completed'), + ('patch-state-changed', 'Patch State Changed'), + ('patch-delegated', 'Patch Delegate Changed'), + ('patch-relation-changed', 'Patch Relation Changed'), + ('check-created', 'Check Created'), + ('series-created', 'Series Created'), + ('series-completed', 'Series Completed'), + ('cover-comment-created', 'Cover Comment Created'), + ('patch-comment-created', 'Patch Comment Created'), + ], + db_index=True, + help_text='The category of the event.', + max_length=25, + ), + ), + ] diff --git patchwork/models.py patchwork/models.py index 6304b34d..e4a910ed 100644 --- patchwork/models.py +++ patchwork/models.py @@ -1028,6 +1028,8 @@ class Event(models.Model): CATEGORY_CHECK_CREATED = 'check-created' CATEGORY_SERIES_CREATED = 'series-created' CATEGORY_SERIES_COMPLETED = 'series-completed' + CATEGORY_COVER_COMMENT_CREATED = 'cover-comment-created' + CATEGORY_PATCH_COMMENT_CREATED = 'patch-comment-created' CATEGORY_CHOICES = ( (CATEGORY_COVER_CREATED, 'Cover Letter Created'), (CATEGORY_PATCH_CREATED, 'Patch Created'), @@ -1038,6 +1040,8 @@ class Event(models.Model): (CATEGORY_CHECK_CREATED, 'Check Created'), (CATEGORY_SERIES_CREATED, 'Series Created'), (CATEGORY_SERIES_COMPLETED, 'Series Completed'), + (CATEGORY_COVER_COMMENT_CREATED, 'Cover Comment Created'), + (CATEGORY_PATCH_COMMENT_CREATED, 'Patch Comment Created'), ) # parents @@ -1113,6 +1117,18 @@ class Event(models.Model): Check, related_name='+', null=True, blank=True, on_delete=models.CASCADE) + # fields for 'cover-comment-created' events + + cover_comment = models.ForeignKey( + CoverComment, related_name='+', null=True, blank=True, + on_delete=models.CASCADE) + + # fields for 'patch-comment-created' events + + patch_comment = models.ForeignKey( + PatchComment, related_name='+', null=True, blank=True, + on_delete=models.CASCADE) + # TODO(stephenfin): Validate that the correct fields are being set by way # of a 'clean' method diff --git patchwork/signals.py patchwork/signals.py index dc08129c..d1aac8cf 100644 --- patchwork/signals.py +++ patchwork/signals.py @@ -11,9 +11,11 @@ from django.dispatch import receiver from patchwork.models import Check from patchwork.models import Cover +from patchwork.models import CoverComment from patchwork.models import Event from patchwork.models import Patch from patchwork.models import PatchChangeNotification +from patchwork.models import PatchComment from patchwork.models import Series @@ -267,3 +269,31 @@ def create_series_completed_event(sender, instance, raw, **kwargs): # the instance yet so we duplicate that logic here but with an offset if (instance.series.received_total + 1) >= instance.series.total: create_event(instance.series) + + +@receiver(post_save, sender=CoverComment) +def create_cover_comment_created_event(sender, instance, raw, **kwargs): + + def create_event(comment): + return Event.objects.create( + category=Event.CATEGORY_COVER_COMMENT_CREATED, + project=comment.cover.project, + cover=comment.cover, + cover_comment=comment, + ) + + create_event(instance) + + +@receiver(post_save, sender=PatchComment) +def create_patch_comment_created_event(sender, instance, raw, **kwargs): + + def create_event(comment): + return Event.objects.create( + category=Event.CATEGORY_PATCH_COMMENT_CREATED, + project=comment.patch.project, + patch=comment.patch, + patch_comment=comment, + ) + + create_event(instance) diff --git patchwork/tests/test_signals.py patchwork/tests/test_signals.py index 090b6dc0..5d5d8e3b 100644 --- patchwork/tests/test_signals.py +++ patchwork/tests/test_signals.py @@ -8,8 +8,12 @@ from django.test import TestCase from patchwork.models import Event from patchwork.tests import utils -BASE_FIELDS = ['previous_state', 'current_state', 'previous_delegate', - 'current_delegate'] +BASE_FIELDS = [ + 'previous_state', + 'current_state', + 'previous_delegate', + 'current_delegate', +] def _get_events(**filters): @@ -277,3 +281,31 @@ class SeriesChangedTest(_BaseTestCase): events = _get_events(series=series) self.assertIn(Event.CATEGORY_SERIES_COMPLETED, [x.category for x in events]) + + +class CoverCommentCreatedTest(_BaseTestCase): + + def test_cover_comment_created(self): + """Validate 'cover-comment-created' events.""" + comment = utils.create_cover_comment() + events = _get_events(cover_comment=comment) + self.assertEqual(events.count(), 1) + self.assertEqual( + events[0].category, Event.CATEGORY_COVER_COMMENT_CREATED, + ) + self.assertEqual(events[0].project, comment.cover.project) + self.assertEventFields(events[0]) + + +class PatchCommentCreatedTest(_BaseTestCase): + + def test_patch_comment_created(self): + """Validate 'patch-comment-created' events.""" + comment = utils.create_patch_comment() + events = _get_events(patch_comment=comment) + self.assertEqual(events.count(), 1) + self.assertEqual( + events[0].category, Event.CATEGORY_PATCH_COMMENT_CREATED, + ) + self.assertEqual(events[0].project, comment.patch.project) + self.assertEventFields(events[0]) diff --git releasenotes/notes/comment-events-2bc9b754cad1fb32.yaml releasenotes/notes/comment-events-2bc9b754cad1fb32.yaml new file mode 100644 index 00000000..a0895d44 --- /dev/null +++ releasenotes/notes/comment-events-2bc9b754cad1fb32.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Two new event types have been added: ``cover-comment-created`` and + ``patch-comment-created``. As their names would suggest, these track the + creation of new cover letter and patch comments respectively.