File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ class ConfigHelper
95
95
'algoliasearch_advanced/advanced/backend_rendering_allowed_user_agents ' ;
96
96
const NON_CASTABLE_ATTRIBUTES = 'algoliasearch_advanced/advanced/non_castable_attributes ' ;
97
97
const MAX_RECORD_SIZE_LIMIT = 'algoliasearch_advanced/advanced/max_record_size_limit ' ;
98
+ const ARCHIVE_LOG_CLEAR_LIMIT = 'algoliasearch_advanced/advanced/archive_clear_limit ' ;
98
99
99
100
const SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock ' ;
100
101
@@ -1112,6 +1113,15 @@ public function getMaxRecordSizeLimit($storeId = null)
1112
1113
return $ this ->maxRecordSize ;
1113
1114
}
1114
1115
1116
+ public function getArchiveLogClearLimit ($ storeId = null )
1117
+ {
1118
+ return (int ) $ this ->configInterface ->getValue (
1119
+ self ::ARCHIVE_LOG_CLEAR_LIMIT ,
1120
+ ScopeInterface::SCOPE_STORE ,
1121
+ $ storeId
1122
+ );
1123
+ }
1124
+
1115
1125
public function getCatalogSearchEngine ($ storeId = null )
1116
1126
{
1117
1127
return $ this ->configInterface ->getValue (self ::CATALOG_SEARCH_ENGINE , ScopeInterface::SCOPE_STORE , $ storeId );
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class Queue
19
19
{
20
20
const FULL_REINDEX_TO_REALTIME_JOBS_RATIO = 0.33 ;
21
21
const UNLOCK_STACKED_JOBS_AFTER_MINUTES = 15 ;
22
+ const CLEAR_ARCHIVE_LOGS_AFTER_DAYS = 30 ;
22
23
23
24
const SUCCESS_LOG = 'algoliasearch_queue_log.txt ' ;
24
25
const ERROR_LOG = 'algoliasearch_queue_errors.log ' ;
@@ -157,6 +158,7 @@ public function runCron($nbJobs = null, $force = false)
157
158
}
158
159
159
160
$ this ->clearOldLogRecords ();
161
+ $ this ->clearOldArchiveRecords ();
160
162
$ this ->unlockStackedJobs ();
161
163
162
164
$ this ->logRecord = [
@@ -588,6 +590,20 @@ private function clearOldLogRecords()
588
590
}
589
591
}
590
592
593
+ private function clearOldArchiveRecords ()
594
+ {
595
+ $ archiveLogClearLimit = $ this ->configHelper ->getArchiveLogClearLimit ();
596
+ // Adding a fallback in case this configuration was not set in a consistent way
597
+ if ($ archiveLogClearLimit < 1 ) {
598
+ $ archiveLogClearLimit = self ::CLEAR_ARCHIVE_LOGS_AFTER_DAYS ;
599
+ }
600
+
601
+ $ this ->db ->delete (
602
+ $ this ->archiveTable ,
603
+ 'created_at < (NOW() - INTERVAL ' . $ archiveLogClearLimit . ' DAY) '
604
+ );
605
+ }
606
+
591
607
private function unlockStackedJobs ()
592
608
{
593
609
$ this ->db ->update ($ this ->table , [
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
98
98
'algoliasearch_advanced/advanced/prevent_backend_rendering ' => '0 ' ,
99
99
'algoliasearch_advanced/advanced/prevent_backend_rendering_display_mode ' => 'all ' ,
100
100
'algoliasearch_advanced/advanced/backend_rendering_allowed_user_agents ' => "Googlebot \nBingbot " ,
101
+ 'algoliasearch_advanced/advanced/archive_clear_limit ' => '30 ' ,
101
102
];
102
103
103
104
private $ defaultArrayConfigData = [
Original file line number Diff line number Diff line change 877
877
]]>
878
878
</comment >
879
879
</field >
880
+ <field id =" archive_clear_limit" translate =" label comment" type =" text" sortOrder =" 95" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
881
+ <label >Archive log clean limit</label >
882
+ <comment >
883
+ <![CDATA[
884
+ (In days - default value is 30) Sets the limit when the oldest records should be cleared from the archive logs (algoliasearch_queue_archive).
885
+ ]]>
886
+ </comment >
887
+ </field >
880
888
</group >
881
889
</section >
882
890
<section id =" algoliasearch_extra_settings" translate =" label" type =" text" sortOrder =" 90" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
You can’t perform that action at this time.
0 commit comments