Configuration for the maximum number of post engagement entries
This commit is contained in:
parent
ae33a6bce1
commit
5e1c292927
|
@ -58,7 +58,7 @@ class Engagement
|
||||||
'title', 'content-warning', 'body', 'author-contact-type', 'author-nick', 'author-addr', 'owner-contact-type', 'owner-nick', 'owner-addr'],
|
'title', 'content-warning', 'body', 'author-contact-type', 'author-nick', 'author-addr', 'owner-contact-type', 'owner-nick', 'owner-addr'],
|
||||||
['uri-id' => $item['parent-uri-id']]);
|
['uri-id' => $item['parent-uri-id']]);
|
||||||
|
|
||||||
if ($parent['created'] < DateTimeFormat::utc('now - ' . DI::config()->get('channel', 'engagement_hours') . ' hour')) {
|
if ($parent['created'] < self::getCreationDateLimit(false)) {
|
||||||
Logger::debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]);
|
Logger::debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,27 @@ class Engagement
|
||||||
*/
|
*/
|
||||||
public static function expire()
|
public static function expire()
|
||||||
{
|
{
|
||||||
DBA::delete('post-engagement', ["`created` < ?", DateTimeFormat::utc('now - ' . DI::config()->get('channel', 'engagement_hours') . ' hour')]);
|
$limit = self::getCreationDateLimit(true);
|
||||||
Logger::notice('Cleared expired engagements', ['rows' => DBA::affectedRows()]);
|
if (empty($limit)) {
|
||||||
|
Logger::notice('Expiration limit not reached');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DBA::delete('post-engagement', ["`created` < ?", $limit]);
|
||||||
|
Logger::notice('Cleared expired engagements', ['limit' => $limit, 'rows' => DBA::affectedRows()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getCreationDateLimit(bool $forDeletion): string
|
||||||
|
{
|
||||||
|
$posts = DI::config()->get('channel', 'engagement_post_limit');
|
||||||
|
if (!empty($posts)) {
|
||||||
|
$limit = DBA::selectToArray('post-engagement', ['created'], [], ['limit' => [$posts, 1], 'order' => ['created' => true]]);
|
||||||
|
if (!empty($limit)) {
|
||||||
|
return $limit[0]['created'];
|
||||||
|
} elseif ($forDeletion) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DateTimeFormat::utc('now - ' . DI::config()->get('channel', 'engagement_hours') . ' hour');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -798,9 +798,13 @@ return [
|
||||||
],
|
],
|
||||||
'channel' => [
|
'channel' => [
|
||||||
// engagement_hours (Integer)
|
// engagement_hours (Integer)
|
||||||
// Number of hours posts are held in the engagement table
|
// Maximum age of incoming posts for the engagement table, when the engagement post limit is 0 or hasn't been reached yet.
|
||||||
'engagement_hours' => 24,
|
'engagement_hours' => 24,
|
||||||
|
|
||||||
|
// engagement_post_limit (Integer)
|
||||||
|
// NUmber of posts that are held in the engagement table
|
||||||
|
'engagement_post_limit' => 20000,
|
||||||
|
|
||||||
// interaction_score_days (Integer)
|
// interaction_score_days (Integer)
|
||||||
// Number of days that are used to calculate the interaction score.
|
// Number of days that are used to calculate the interaction score.
|
||||||
'interaction_score_days' => 30,
|
'interaction_score_days' => 30,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user