88 * window is 365 days; admin override via
99 * `launchpad.analytics_retention_days` is clamped to `[30, 3650]`.
1010 *
11+ * Extended by the tile usage-analytics capability (REQ-TANLT-005) to
12+ * also purge `oc_launchpad_tile_clicks` rows older than the SAME
13+ * cutoff in the same run — no second purge job is introduced, per the
14+ * "reuse, don't reinvent" contract for that capability.
15+ *
1116 * Logging is intentionally aggregate-only: row count + cutoff date
1217 * — never any user-attributable identifiers (REQ-ANLT-009 scenario
1318 * "Purge logs execution"). The job is registered via
3035namespace OCA \LaunchPad \BackgroundJob ;
3136
3237use OCA \LaunchPad \Db \DashboardViewMapper ;
38+ use OCA \LaunchPad \Db \TileClickMapper ;
3339use OCA \LaunchPad \Service \AnalyticsService ;
3440use OCP \AppFramework \Utility \ITimeFactory ;
3541use OCP \BackgroundJob \TimedJob ;
@@ -56,12 +62,18 @@ class PurgeViewsJob extends TimedJob
5662 * context).
5763 * @param DashboardViewMapper $viewMapper Aggregate-row
5864 * mapper.
65+ * @param TileClickMapper $tileClickMapper Tile-click
66+ * aggregate-row
67+ * mapper — reuses
68+ * the same cutoff
69+ * date (REQ-TANLT-005).
5970 * @param LoggerInterface $logger PSR logger.
6071 */
6172 public function __construct (
6273 ITimeFactory $ time ,
6374 private readonly AnalyticsService $ analyticsService ,
6475 private readonly DashboardViewMapper $ viewMapper ,
76+ private readonly TileClickMapper $ tileClickMapper ,
6577 private readonly LoggerInterface $ logger ,
6678 ) {
6779 parent ::__construct (time: $ time );
@@ -70,25 +82,31 @@ public function __construct(
7082
7183 /**
7284 * Run the job — delete every aggregate row strictly older than
73- * the cutoff date.
85+ * the cutoff date, in BOTH the dashboard-views table and the
86+ * tile-clicks table (REQ-TANLT-005 — same cutoff, same run, no
87+ * second job).
7488 *
7589 * @param mixed $argument Required by the base class; unused.
7690 *
7791 * @return void
7892 *
7993 * @spec openspec/specs/dashboard-view-analytics/spec.md
94+ * @spec openspec/specs/dashboard-view-analytics/spec.md
8095 */
8196 protected function run ($ argument ): void
8297 {
83- $ cutoff = $ this ->analyticsService ->getPurgeCutoffDate ();
84- $ deleted = $ this ->viewMapper ->deleteOlderThan (beforeDate: $ cutoff );
98+ $ cutoff = $ this ->analyticsService ->getPurgeCutoffDate ();
99+ $ deletedViews = $ this ->viewMapper ->deleteOlderThan (beforeDate: $ cutoff );
100+ $ deletedClicks = $ this ->tileClickMapper ->deleteOlderThan (beforeDate: $ cutoff );
85101
86102 $ this ->logger ->info (
87- message: 'launchpad analytics purge: deleted ' .$ deleted .' rows older than ' .$ cutoff ,
103+ message: 'launchpad analytics purge: deleted ' .$ deletedViews .' view rows and '
104+ .$ deletedClicks .' tile-click rows older than ' .$ cutoff ,
88105 context: [
89- 'rows ' => $ deleted ,
90- 'cutoff ' => $ cutoff ,
91- 'retention ' => $ this ->analyticsService ->getRetentionDays (),
106+ 'viewRows ' => $ deletedViews ,
107+ 'tileRows ' => $ deletedClicks ,
108+ 'cutoff ' => $ cutoff ,
109+ 'retention ' => $ this ->analyticsService ->getRetentionDays (),
92110 ]
93111 );
94112 }//end run()
0 commit comments