]> git.mxchange.org Git - friendica.git/commitdiff
Simplify "last-activity" handling
authorMichael <heluecht@pirati.ca>
Sun, 4 Dec 2022 07:17:26 +0000 (07:17 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 4 Dec 2022 07:17:26 +0000 (07:17 +0000)
database.sql
src/Module/NoScrape.php
src/Worker/PollContacts.php
static/dbview.config.php
update.php

index 830eff99142dcfa6b6a539f3d00ae858c6b544d9..bbe1e655729e0dc6f431689d97871cd4fb16da0c 100644 (file)
@@ -2693,7 +2693,7 @@ CREATE VIEW `owner-view` AS SELECT
        `user`.`language` AS `language`,
        `user`.`register_date` AS `register_date`,
        `user`.`login_date` AS `login_date`,
-       IF (`user`.`last-activity` IS NULL, DATE(`user`.`login_date`), `user`.`last-activity`) AS `last-activity`,
+       `user`.`last-activity` AS `last-activity`,
        `user`.`default-location` AS `default-location`,
        `user`.`allow_location` AS `allow_location`,
        `user`.`theme` AS `theme`,
index bf57ec7765c83ed2825f9e58c3bb860636245e90..718c95c107cc4de8b438a5c0cc2684313e73eb31 100644 (file)
@@ -94,18 +94,9 @@ class NoScrape extends BaseModule
                }
 
                // We display the last activity (post or login), reduced to year and week number
-               $last_active = 0;
-               $condition   = ['uid' => $owner['uid'], 'self' => true];
-               $contact     = DBA::selectFirst('contact', ['last-item'], $condition);
-               if (DBA::isResult($contact)) {
-                       $last_active = strtotime($contact['last-item']);
-               }
-
-               $user = User::getOwnerDataById($owner['uid']);
-               if (DBA::isResult($user)) {
-                       if ($last_active < strtotime($user['last-activity'])) {
-                               $last_active = strtotime($user['last-activity']);
-                       }
+               $last_active = strtotime($owner['last-item']);
+               if ($last_active < strtotime($owner['last-activity'])) {
+                       $last_active = strtotime($owner['last-activity']);
                }
                $json_info['last-activity'] = date('o-W', $last_active);
 
index 9aea20e5df95bda974c17597b047059f5ba87c44..eb092fe2cd5e42adea071d72c0f1351fcc637d24 100644 (file)
@@ -45,7 +45,7 @@ class PollContacts
 
                if (!empty($abandon_days)) {
                        $condition = DBA::mergeConditions($condition,
-                               ["`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')]);
+                               ["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE NOT `account_expired` AND NOT `account_removed` AND `last-activity` > ?)", 0, DateTimeFormat::utc('now - ' . $abandon_days . ' days')]);
                } else  {
                        $condition = DBA::mergeConditions($condition,
                                ["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE NOT `account_expired` AND NOT `account_removed`)", 0]);
index 09566a7fd00af406c47a74024774f3eaee9e27d9..66f3de3b63f556ee2e3f81a5064b156c70d1ca22 100644 (file)
                        "language" => ["user", "language"],
                        "register_date" => ["user", "register_date"],
                        "login_date" => ["user", "login_date"],
-                       "last-activity" => "IF (`user`.`last-activity` IS NULL, DATE(`user`.`login_date`), `user`.`last-activity`)",
+                       "last-activity" => ["user", "last-activity"],
                        "default-location" => ["user", "default-location"],
                        "allow_location" => ["user", "allow_location"],
                        "theme" => ["user", "theme"],
index 2ee753ead2125e384175de24d9ffa096d9dadecd..176747057199e26fff2da3d5f41eed1124e19b24 100644 (file)
@@ -1126,4 +1126,10 @@ function update_1491()
 {
        DBA::update('contact', ['remote_self' => Contact::MIRROR_OWN_POST], ['remote_self' => Contact::MIRROR_FORWARDED]);
        return Update::SUCCESS;
+}
+
+function update_1497()
+{
+       DBA::e("UPDATE `user` SET `last-activity` = DATE(`login_date`) WHERE `last-activity` IS NULL");
+       return Update::SUCCESS;
 }
\ No newline at end of file