From e732d9503767d4644beeb1a03e7e09e0d86749f5 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 27 Oct 2022 06:18:16 -0400 Subject: [PATCH] feat: ``include_bots: true`` will include bot activity. #25 --- README.rst | 11 +++++++---- scriv.d/20221027_061417_nedbat.rst | 8 ++++++++ src/dinghy/digest.py | 5 ++++- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 scriv.d/20221027_061417_nedbat.rst diff --git a/README.rst b/README.rst index c778b81..61d6744 100644 --- a/README.rst +++ b/README.rst @@ -131,11 +131,14 @@ clause sets defaults for the digest options in the rest of the file. Each Items can have additional options: -- No activity is reported for bot users. Some applications act as real users, - but should be ignored anyway. You can list those user names that should be - ignored in the ``ignore_users`` setting. +- By default, no activity is reported for bot users. If you want to include + them, use ``include_bots: true``. -- Items can have an explicit title set with the ``title:`` setting. +- Some applications perform actions using real user accounts, but you'd like to + ignore them anyway. You can list those user names that should be ignored in + the ``ignore_users`` setting. + +- Digests can have an explicit title set with the ``title`` setting. - Options for organization projects include: diff --git a/scriv.d/20221027_061417_nedbat.rst b/scriv.d/20221027_061417_nedbat.rst new file mode 100644 index 0000000..504c826 --- /dev/null +++ b/scriv.d/20221027_061417_nedbat.rst @@ -0,0 +1,8 @@ +Added +..... + +- A new setting ``include_bots: true`` will include pull requests, issues, or + comments created by bot users. The default remains False, to exclude them. + Closes `issue 25`_. + +.. _issue 25: https://github.com/nedbat/dinghy/issues/25 diff --git a/src/dinghy/digest.py b/src/dinghy/digest.py index dd54712..5ffb6b6 100644 --- a/src/dinghy/digest.py +++ b/src/dinghy/digest.py @@ -47,6 +47,9 @@ class Digester: def __init__(self, since, options): self.since = since.strftime("%Y-%m-%dT%H:%M:%S") self.ignore_users = options.get("ignore_users", []) + self.user_types = {"User"} + if options.get("include_bots", False): + self.user_types.add("Bot") self.api_root = options.get("api_root") self.github = "github.com" self.gql = None @@ -250,7 +253,7 @@ def _node_is_interesting(self, node): """ return ( node["updatedAt"] > self.since - and node["author"]["__typename"] == "User" + and node["author"]["__typename"] in self.user_types and node["author"]["login"] not in self.ignore_users )