mirror of
https://github.com/friendica/friendica
synced 2025-05-14 00:24:10 +02:00
Calculate the interaction score
This commit is contained in:
parent
350999fcca
commit
35995633ae
8 changed files with 150 additions and 10 deletions
|
@ -104,6 +104,9 @@ class Cron
|
|||
// Clear cache entries
|
||||
Worker::add(Worker::PRIORITY_LOW, 'ClearCache');
|
||||
|
||||
// Update interaction scores
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdateScores');
|
||||
|
||||
DI::keyValue()->set('last_cron_hourly', time());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class UpdateAllSuggestions
|
|||
{
|
||||
public static function execute()
|
||||
{
|
||||
$users = DBA::select('user', ['uid'], ["`last-activity` > ?", DateTimeFormat::utc('now - 3 days', 'Y-m-d')]);
|
||||
$users = DBA::select('user', ['uid'], ["`last-activity` > ? AND `uid` > ?", DateTimeFormat::utc('now - 3 days', 'Y-m-d'), 0]);
|
||||
while ($user = DBA::fetch($users)) {
|
||||
Contact\Relation::updateCachedSuggestions($user['uid']);
|
||||
}
|
||||
|
|
46
src/Worker/UpdateScores.php
Normal file
46
src/Worker/UpdateScores.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2023, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact\Relation;
|
||||
|
||||
/**
|
||||
* Update the interaction scores
|
||||
*/
|
||||
class UpdateScores
|
||||
{
|
||||
public static function execute($param = '', $hook_function = '')
|
||||
{
|
||||
Logger::notice('Start score update');
|
||||
|
||||
$users = DBA::select('user', ['uid'], ["NOT `account_expired` AND NOT `account_removed` AND `uid` > ?", 0]);
|
||||
while ($user = DBA::fetch($users)) {
|
||||
Relation::calculateInteractionScore($user['uid']);
|
||||
}
|
||||
DBA::close($users);
|
||||
|
||||
Logger::notice('Score update done');
|
||||
return;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue