@@ -100,24 +100,32 @@ public function getRecordMetadata(ArchiveProcessor $archiveProcessor): array
100100 return $ records ;
101101 }
102102
103- public function flatRowToUrlHierarchyPath (Row $ flatRow, ArchiveProcessor $ archiveProcessor , Record $ record ): ?array
103+ public function flatRowToUrlHierarchyPath (Row $ flatRow ): ?array
104104 {
105105 return $ this ->flatRowToHierarchyPath ($ flatRow , Action::TYPE_PAGE_URL );
106106 }
107107
108- public function flatRowToTitleHierarchyPath (Row $ flatRow, ArchiveProcessor $ archiveProcessor , Record $ record ): ?array
108+ public function flatRowToTitleHierarchyPath (Row $ flatRow ): ?array
109109 {
110110 return $ this ->flatRowToHierarchyPath ($ flatRow , Action::TYPE_PAGE_TITLE );
111111 }
112112
113113 public function reduceLegacyUrlHierarchyIntoFlatTable (DataTable $ legacyHierarchy , DataTable $ flatTable , ArchiveProcessor $ archiveProcessor , Record $ record ): void
114114 {
115- $ this ->reduceLegacyHierarchyIntoFlatTable ($ legacyHierarchy , $ flatTable , Action::TYPE_PAGE_URL );
115+ ArchivingHelper::mergeHierarchicalActionsTableIntoBestEffortFlatTable (
116+ $ legacyHierarchy ,
117+ $ flatTable ,
118+ Action::TYPE_PAGE_URL
119+ );
116120 }
117121
118122 public function reduceLegacyTitleHierarchyIntoFlatTable (DataTable $ legacyHierarchy , DataTable $ flatTable , ArchiveProcessor $ archiveProcessor , Record $ record ): void
119123 {
120- $ this ->reduceLegacyHierarchyIntoFlatTable ($ legacyHierarchy , $ flatTable , Action::TYPE_PAGE_TITLE );
124+ ArchivingHelper::mergeHierarchicalActionsTableIntoBestEffortFlatTable (
125+ $ legacyHierarchy ,
126+ $ flatTable ,
127+ Action::TYPE_PAGE_TITLE
128+ );
121129 }
122130
123131 protected function aggregate (ArchiveProcessor $ archiveProcessor ): array
@@ -170,15 +178,11 @@ protected function aggregate(ArchiveProcessor $archiveProcessor): array
170178
171179 $ tablesByType [Action::TYPE_PAGE_URL ] = $ this ->buildDayHierarchicalTableFromFlatTable (
172180 $ flatPageTablesByType [Action::TYPE_PAGE_URL ],
173- Archiver::PAGE_URLS_RECORD_NAME ,
174- [$ this , 'flatRowToUrlHierarchyPath ' ],
175- $ archiveProcessor
181+ [$ this , 'flatRowToUrlHierarchyPath ' ]
176182 );
177183 $ tablesByType [Action::TYPE_PAGE_TITLE ] = $ this ->buildDayHierarchicalTableFromFlatTable (
178184 $ flatPageTablesByType [Action::TYPE_PAGE_TITLE ],
179- Archiver::PAGE_TITLES_RECORD_NAME ,
180- [$ this , 'flatRowToTitleHierarchyPath ' ],
181- $ archiveProcessor
185+ [$ this , 'flatRowToTitleHierarchyPath ' ]
182186 );
183187 $ this ->finalizeBuiltFromFlatHierarchyTable (
184188 $ archiveProcessor ,
@@ -284,11 +288,6 @@ private function flatRowToHierarchyPath(Row $flatRow, int $actionType): ?array
284288 return ArchivingHelper::getActionExplodedNames ($ label , $ actionType );
285289 }
286290
287- private function reduceLegacyHierarchyIntoFlatTable (DataTable $ legacyHierarchy , DataTable $ flatTable , int $ actionType ): void
288- {
289- $ this ->appendLegacyHierarchyRowsToFlatTable ($ legacyHierarchy , [], $ flatTable , $ actionType );
290- }
291-
292291 private function removeFlatPathMetadataFromDataTable (DataTable $ dataTable ): void
293292 {
294293 $ summaryRow = $ dataTable ->getRowFromId (DataTable::ID_SUMMARY_ROW );
@@ -325,52 +324,6 @@ private function finalizeBuiltFromFlatHierarchyTable(
325324 ArchivingHelper::deleteInvalidSummedColumnsFromDataTable ($ hierarchicalTable );
326325 }
327326
328- private function appendLegacyHierarchyRowsToFlatTable (DataTable $ sourceTable , array $ path , DataTable $ flatTable , int $ actionType ): void
329- {
330- foreach ($ sourceTable ->getRowsWithoutSummaryRow () as $ row ) {
331- $ label = $ row ->getColumn ('label ' );
332- if (!is_string ($ label ) || $ label === '' ) {
333- continue ;
334- }
335-
336- $ currentPath = $ path ;
337- $ currentPath [] = $ label ;
338-
339- $ subtable = $ row ->getSubtable ();
340- if ($ subtable ) {
341- $ this ->appendLegacyHierarchyRowsToFlatTable ($ subtable , $ currentPath , $ flatTable , $ actionType );
342- continue ;
343- }
344-
345- $ flatLabel = ArchivingHelper::buildBestEffortActionLabelFromPath ($ currentPath , $ actionType );
346- $ flatRow = $ flatTable ->getRowFromLabel ($ flatLabel );
347- if ($ flatRow === false ) {
348- $ flatRow = new Row ([
349- Row::COLUMNS => ['label ' => $ flatLabel ],
350- ]);
351- $ flatRow ->setMetadata (ArchivingHelper::ACTION_FLAT_PATH_METADATA_NAME , $ currentPath );
352- $ flatTable ->addRow ($ flatRow );
353- }
354-
355- $ flatRow ->sumRow (clone $ row , true , Metrics::getColumnsAggregationOperation ());
356- }
357-
358- $ summaryRow = $ sourceTable ->getRowFromId (DataTable::ID_SUMMARY_ROW );
359- if ($ summaryRow === false ) {
360- return ;
361- }
362-
363- $ globalSummary = $ flatTable ->getRowFromId (DataTable::ID_SUMMARY_ROW );
364- if ($ globalSummary === false ) {
365- $ globalSummary = clone $ summaryRow ;
366- $ globalSummary ->setIsSummaryRow ();
367- $ flatTable ->addSummaryRow ($ globalSummary );
368- return ;
369- }
370-
371- $ globalSummary ->sumRow (clone $ summaryRow , true , Metrics::getColumnsAggregationOperation ());
372- }
373-
374327 private function isFlatArchivingEnabled (): bool
375328 {
376329 ArchivingHelper::reloadConfig ();
@@ -392,18 +345,12 @@ private function setHierarchyBuiltFromFlatRecord(
392345
393346 private function buildDayHierarchicalTableFromFlatTable (
394347 DataTable $ flatTable ,
395- string $ hierarchicalRecordName ,
396- callable $ flatToHierarchyPathCallback ,
397- ArchiveProcessor $ archiveProcessor
348+ callable $ flatToHierarchyPathCallback
398349 ): DataTable {
399- $ hierarchicalRecord = Record::make (Record::TYPE_BLOB , $ hierarchicalRecordName );
400-
401350 return $ this ->buildHierarchicalTableFromFlatTable (
402351 $ flatTable ,
403352 Metrics::getColumnsAggregationOperation (),
404- function (Row $ flatRow ) use ($ flatToHierarchyPathCallback , $ archiveProcessor , $ hierarchicalRecord ) {
405- return call_user_func ($ flatToHierarchyPathCallback , $ flatRow , $ archiveProcessor , $ hierarchicalRecord );
406- },
353+ $ flatToHierarchyPathCallback ,
407354 $ this ->getDefaultHierarchyRowColumns ()
408355 );
409356 }
0 commit comments