urlwatch icon indicating copy to clipboard operation
urlwatch copied to clipboard

Send individual mail for each changed URL

Open bokkabonga opened this issue 4 years ago • 2 comments

Hey everyone,

we have been using urlwatch for a really long time now nad are monitoring around 30 websites. Recently we changed our Ticketsystem to Zammad. Before this we had a self written reporter for our old redmine system which created an individual ticket for each changed website.

For Zammad we moved from this old, self developed reporter to simply using the email report. However this reporter creates one email for all changes he detects at the same time. I could not find a way so far to make him send one email for each changed website.

Is there a way to influence this behaviour?

bokkabonga avatar Mar 09 '22 08:03 bokkabonga

I couldn't find anything that would allow you to do that in the docs.

Iterating over the list of jobs one by one with something like for i in {1..30}; do urlwatch $i; done would achieve what you want at the loss of parallelism. The subset feature is documented here. The current list of jobs including indexes can be printed with --list.

neutric avatar Mar 09 '22 23:03 neutric

One way to do this by modifying the code (the "duration" in every report will be the same, which is the overall duration of ALL URLs, so it might be a bit misleading, but probably works for your use case):

diff --git a/lib/urlwatch/handler.py b/lib/urlwatch/handler.py
index bcb23fe..57cde61 100644
--- a/lib/urlwatch/handler.py
+++ b/lib/urlwatch/handler.py
@@ -214,7 +214,8 @@ class Report(object):
         end = datetime.datetime.now()
         duration = (end - self.start)
 
-        ReporterBase.submit_all(self, self.job_states, duration)
+        for job_state in self.job_states:
+            ReporterBase.submit_all(self, [job_state], duration)
 
     def finish_one(self, name):
         end = datetime.datetime.now()

If you confirm this works for your use case, it probably can be made a configuration option.

thp avatar Mar 14 '22 11:03 thp

This has been implemented in 2.26 with the "separate" configuration:

New separate configuration option for reporters to split reports into one-per-job (contributed by Ryne Everett)

thp avatar Feb 12 '24 18:02 thp