File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99use Icinga \Module \Icingadb \ProvidedHook \Reporting \ServiceSlaReport ;
1010use Icinga \Module \Icingadb \ProvidedHook \Reporting \SlaReport ;
1111use Icinga \Module \Pdfexport \PrintableHtmlDocument ;
12- use Icinga \Module \Reporting \Model ;
1312use Icinga \Module \Reporting \Web \Widget \Template ;
13+ use Icinga \Util \Json ;
1414use ipl \Html \HtmlDocument ;
1515
1616use function ipl \I18n \t ;
@@ -38,6 +38,9 @@ class Report
3838 /** @var Template */
3939 protected $ template ;
4040
41+ /** @var ?string */
42+ protected ?string $ templateName = null ;
43+
4144 /**
4245 * Create report from the given model
4346 *
@@ -57,6 +60,7 @@ public static function fromModel(Model\Report $reportModel): self
5760
5861 $ template = $ reportModel ->template ->first ();
5962 if ($ template !== null ) {
63+ $ report ->templateName = $ template ->name ;
6064 $ report ->template = Template::fromModel ($ template );
6165 }
6266
@@ -121,6 +125,27 @@ public function getReportlets()
121125 return $ this ->reportlets ;
122126 }
123127
128+ /**
129+ * Get a checksum for this report
130+ *
131+ * @return string
132+ */
133+ public function getChecksum (): string
134+ {
135+ return md5 (
136+ $ this ->getName ()
137+ . $ this ->getTimeframe ()->getName ()
138+ . $ this ->templateName
139+ . Json::encode (array_map (
140+ function (Reportlet $ reportlet ) {
141+ return $ reportlet ->getConfig ();
142+ },
143+ $ this ->getReportlets ()
144+ )),
145+ true
146+ );
147+ }
148+
124149 /**
125150 * @return Schedule
126151 */
Original file line number Diff line number Diff line change @@ -123,7 +123,10 @@ public function setReport(Report $report): self
123123 public function getChecksum (): string
124124 {
125125 return md5 (
126- $ this ->getName () . $ this ->getReport ()->getName () . $ this ->getAction () . Json::encode ($ this ->getConfig ()),
126+ $ this ->getName ()
127+ . $ this ->getAction ()
128+ . Json::encode ($ this ->getConfig ())
129+ . $ this ->getReport ()->getChecksum (),
127130 true
128131 );
129132 }
You can’t perform that action at this time.
0 commit comments