Issue 10518: "last-activity" instead of "login_date"
This commit is contained in:
parent
22e2578b23
commit
1d8c9276f3
13 changed files with 23 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2022.12-dev (Giant Rhubarb)
|
-- Friendica 2022.12-dev (Giant Rhubarb)
|
||||||
-- DB_UPDATE_VERSION 1496
|
-- DB_UPDATE_VERSION 1497
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -2693,6 +2693,7 @@ CREATE VIEW `owner-view` AS SELECT
|
||||||
`user`.`language` AS `language`,
|
`user`.`language` AS `language`,
|
||||||
`user`.`register_date` AS `register_date`,
|
`user`.`register_date` AS `register_date`,
|
||||||
`user`.`login_date` AS `login_date`,
|
`user`.`login_date` AS `login_date`,
|
||||||
|
IF (`user`.`last-activity` IS NULL, DATE(`user`.`login_date`), `user`.`last-activity`) AS `last-activity`,
|
||||||
`user`.`default-location` AS `default-location`,
|
`user`.`default-location` AS `default-location`,
|
||||||
`user`.`allow_location` AS `allow_location`,
|
`user`.`allow_location` AS `allow_location`,
|
||||||
`user`.`theme` AS `theme`,
|
`user`.`theme` AS `theme`,
|
||||||
|
|
|
@ -370,7 +370,7 @@ HELP;
|
||||||
$contact['url'],
|
$contact['url'],
|
||||||
$contact['email'],
|
$contact['email'],
|
||||||
Temporal::getRelativeDate($contact['created']),
|
Temporal::getRelativeDate($contact['created']),
|
||||||
Temporal::getRelativeDate($contact['login_date']),
|
Temporal::getRelativeDate($contact['last-activity']),
|
||||||
Temporal::getRelativeDate($contact['last-item']),
|
Temporal::getRelativeDate($contact['last-item']),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ HELP;
|
||||||
'nickname',
|
'nickname',
|
||||||
'email',
|
'email',
|
||||||
'register_date',
|
'register_date',
|
||||||
'login_date',
|
'last-activity',
|
||||||
'verified',
|
'verified',
|
||||||
'blocked',
|
'blocked',
|
||||||
];
|
];
|
||||||
|
|
|
@ -682,6 +682,8 @@ class User
|
||||||
|
|
||||||
if ($user['last-activity'] != $current_day) {
|
if ($user['last-activity'] != $current_day) {
|
||||||
User::update(['last-activity' => $current_day], $uid);
|
User::update(['last-activity' => $current_day], $uid);
|
||||||
|
// Set the last actitivy for all identities of the user
|
||||||
|
DBA::update('user', ['last-activity' => $current_day], ['parent-uid' => $uid, 'account_removed' => false]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1729,8 +1731,8 @@ class User
|
||||||
'active_users_weekly' => 0,
|
'active_users_weekly' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
$userStmt = DBA::select('owner-view', ['uid', 'login_date', 'last-item'],
|
$userStmt = DBA::select('owner-view', ['uid', 'last-activity', 'last-item'],
|
||||||
["`verified` AND `login_date` > ? AND NOT `blocked`
|
["`verified` AND `last-activity` > ? AND NOT `blocked`
|
||||||
AND NOT `account_removed` AND NOT `account_expired`",
|
AND NOT `account_removed` AND NOT `account_expired`",
|
||||||
DBA::NULL_DATETIME]);
|
DBA::NULL_DATETIME]);
|
||||||
if (!DBA::isResult($userStmt)) {
|
if (!DBA::isResult($userStmt)) {
|
||||||
|
@ -1744,17 +1746,17 @@ class User
|
||||||
while ($user = DBA::fetch($userStmt)) {
|
while ($user = DBA::fetch($userStmt)) {
|
||||||
$statistics['total_users']++;
|
$statistics['total_users']++;
|
||||||
|
|
||||||
if ((strtotime($user['login_date']) > $halfyear) || (strtotime($user['last-item']) > $halfyear)
|
if ((strtotime($user['last-activity']) > $halfyear) || (strtotime($user['last-item']) > $halfyear)
|
||||||
) {
|
) {
|
||||||
$statistics['active_users_halfyear']++;
|
$statistics['active_users_halfyear']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strtotime($user['login_date']) > $month) || (strtotime($user['last-item']) > $month)
|
if ((strtotime($user['last-activity']) > $month) || (strtotime($user['last-item']) > $month)
|
||||||
) {
|
) {
|
||||||
$statistics['active_users_monthly']++;
|
$statistics['active_users_monthly']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strtotime($user['login_date']) > $week) || (strtotime($user['last-item']) > $week)
|
if ((strtotime($user['last-activity']) > $week) || (strtotime($user['last-item']) > $week)
|
||||||
) {
|
) {
|
||||||
$statistics['active_users_weekly']++;
|
$statistics['active_users_weekly']++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ abstract class BaseUsers extends BaseModeration
|
||||||
$user['account_type'] = ($user['page_flags_raw'] == 0) ? $account_types[$user['account-type']] : '';
|
$user['account_type'] = ($user['page_flags_raw'] == 0) ? $account_types[$user['account-type']] : '';
|
||||||
|
|
||||||
$user['register_date'] = Temporal::getRelativeDate($user['register_date']);
|
$user['register_date'] = Temporal::getRelativeDate($user['register_date']);
|
||||||
$user['login_date'] = Temporal::getRelativeDate($user['login_date']);
|
$user['login_date'] = Temporal::getRelativeDate($user['last-activity']);
|
||||||
$user['lastitem_date'] = Temporal::getRelativeDate($user['last-item']);
|
$user['lastitem_date'] = Temporal::getRelativeDate($user['last-item']);
|
||||||
$user['is_admin'] = in_array($user['email'], $adminlist);
|
$user['is_admin'] = in_array($user['email'], $adminlist);
|
||||||
$user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != $this->session->getLocalUserId();
|
$user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != $this->session->getLocalUserId();
|
||||||
|
|
|
@ -100,7 +100,7 @@ class Active extends BaseUsers
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'register_date',
|
'register_date',
|
||||||
'login_date',
|
'last-activity',
|
||||||
'last-item',
|
'last-item',
|
||||||
'page-flags',
|
'page-flags',
|
||||||
];
|
];
|
||||||
|
|
|
@ -100,7 +100,7 @@ class Blocked extends BaseUsers
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'register_date',
|
'register_date',
|
||||||
'login_date',
|
'last-activity',
|
||||||
'last-item',
|
'last-item',
|
||||||
'page-flags',
|
'page-flags',
|
||||||
];
|
];
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Deleted extends BaseUsers
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'register_date',
|
'register_date',
|
||||||
'login_date',
|
'last-activity',
|
||||||
'last-item',
|
'last-item',
|
||||||
'page-flags',
|
'page-flags',
|
||||||
];
|
];
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Index extends BaseUsers
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'register_date',
|
'register_date',
|
||||||
'login_date',
|
'last-activity',
|
||||||
'last-item',
|
'last-item',
|
||||||
'page-flags',
|
'page-flags',
|
||||||
];
|
];
|
||||||
|
|
|
@ -101,11 +101,10 @@ class NoScrape extends BaseModule
|
||||||
$last_active = strtotime($contact['last-item']);
|
$last_active = strtotime($contact['last-item']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ['uid' => $owner['uid']];
|
$user = User::getOwnerDataById($owner['uid']);
|
||||||
$user = DBA::selectFirst('user', ['login_date'], $condition);
|
|
||||||
if (DBA::isResult($user)) {
|
if (DBA::isResult($user)) {
|
||||||
if ($last_active < strtotime($user['login_date'])) {
|
if ($last_active < strtotime($user['last-activity'])) {
|
||||||
$last_active = strtotime($user['login_date']);
|
$last_active = strtotime($user['last-activity']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$json_info['last-activity'] = date('o-W', $last_active);
|
$json_info['last-activity'] = date('o-W', $last_active);
|
||||||
|
|
|
@ -356,7 +356,7 @@ class Authentication
|
||||||
$this->dba->update('user', ['last-activity' => DateTimeFormat::utcNow('Y-m-d'), 'login_date' => DateTimeFormat::utcNow()], ['uid' => $user_record['uid']]);
|
$this->dba->update('user', ['last-activity' => DateTimeFormat::utcNow('Y-m-d'), 'login_date' => DateTimeFormat::utcNow()], ['uid' => $user_record['uid']]);
|
||||||
|
|
||||||
// Set the login date for all identities of the user
|
// Set the login date for all identities of the user
|
||||||
$this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()],
|
$this->dba->update('user', ['last-activity' => DateTimeFormat::utcNow('Y-m-d'), 'login_date' => DateTimeFormat::utcNow()],
|
||||||
['parent-uid' => $user_record['uid'], 'account_removed' => false]);
|
['parent-uid' => $user_record['uid'], 'account_removed' => false]);
|
||||||
|
|
||||||
// Regularly update suggestions
|
// Regularly update suggestions
|
||||||
|
|
|
@ -45,7 +45,7 @@ class PollContacts
|
||||||
|
|
||||||
if (!empty($abandon_days)) {
|
if (!empty($abandon_days)) {
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE NOT `account_expired` AND NOT `account_removed` AND `login_date` > ?)", 0, DateTimeFormat::utc('now - ' . $abandon_days . ' days')]);
|
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `owner-view` WHERE NOT `account_expired` AND NOT `account_removed` AND `last-activity` > ?)", 0, DateTimeFormat::utc('now - ' . $abandon_days . ' days')]);
|
||||||
} else {
|
} else {
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE NOT `account_expired` AND NOT `account_removed`)", 0]);
|
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE NOT `account_expired` AND NOT `account_removed`)", 0]);
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1496);
|
define('DB_UPDATE_VERSION', 1497);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -889,6 +889,7 @@
|
||||||
"language" => ["user", "language"],
|
"language" => ["user", "language"],
|
||||||
"register_date" => ["user", "register_date"],
|
"register_date" => ["user", "register_date"],
|
||||||
"login_date" => ["user", "login_date"],
|
"login_date" => ["user", "login_date"],
|
||||||
|
"last-activity" => "IF (`user`.`last-activity` IS NULL, DATE(`user`.`login_date`), `user`.`last-activity`)",
|
||||||
"default-location" => ["user", "default-location"],
|
"default-location" => ["user", "default-location"],
|
||||||
"allow_location" => ["user", "allow_location"],
|
"allow_location" => ["user", "allow_location"],
|
||||||
"theme" => ["user", "theme"],
|
"theme" => ["user", "theme"],
|
||||||
|
|
Loading…
Reference in a new issue