]> git.mxchange.org Git - friendica.git/commitdiff
Use the owner, not the author
authorMichael <heluecht@pirati.ca>
Sat, 2 Sep 2023 14:19:52 +0000 (14:19 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 2 Sep 2023 14:19:52 +0000 (14:19 +0000)
database.sql
doc/database/db_post-engagement.md
src/Model/Post/Engagement.php
src/Module/Conversation/Channel.php
static/dbstructure.config.php

index 6bad8340a6d2ee12d50ae94fba2b3b5843316be4..d5bc05faa66cc69f3111863b927b2127a06a221c 100644 (file)
@@ -1305,16 +1305,16 @@ CREATE TABLE IF NOT EXISTS `post-delivery-data` (
 --
 CREATE TABLE IF NOT EXISTS `post-engagement` (
        `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
-       `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
+       `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
        `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
        `created` datetime COMMENT '',
        `comments` mediumint unsigned COMMENT 'Number of comments',
        `activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
         PRIMARY KEY(`uri-id`),
-        INDEX `author-id` (`author-id`),
+        INDEX `owner-id` (`owner-id`),
         INDEX `created` (`created`),
        FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
-       FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
+       FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
 
 --
index e49881502c4d461d96e293dce1719fa577a2371f..8c4a2ae0066fbc9e2f30d63d872ed216fb1259c7 100644 (file)
@@ -6,23 +6,23 @@ Engagement data per post
 Fields
 ------
 
-| Field        | Description                                                     | Type               | Null | Key | Default | Extra |
-| ------------ | --------------------------------------------------------------- | ------------------ | ---- | --- | ------- | ----- |
-| uri-id       | Id of the item-uri table entry that contains the item uri       | int unsigned       | NO   | PRI | NULL    |       |
-| author-id    | Link to the contact table with uid=0 of the author of this item | int unsigned       | NO   |     | 0       |       |
-| contact-type | Person, organisation, news, community, relay                    | tinyint            | NO   |     | 0       |       |
-| created      |                                                                 | datetime           | YES  |     | NULL    |       |
-| comments     | Number of comments                                              | mediumint unsigned | YES  |     | NULL    |       |
-| activities   | Number of activities (like, dislike, ...)                       | mediumint unsigned | YES  |     | NULL    |       |
+| Field        | Description                                               | Type               | Null | Key | Default | Extra |
+| ------------ | --------------------------------------------------------- | ------------------ | ---- | --- | ------- | ----- |
+| uri-id       | Id of the item-uri table entry that contains the item uri | int unsigned       | NO   | PRI | NULL    |       |
+| owner-id     | Item owner                                                | int unsigned       | NO   |     | 0       |       |
+| contact-type | Person, organisation, news, community, relay              | tinyint            | NO   |     | 0       |       |
+| created      |                                                           | datetime           | YES  |     | NULL    |       |
+| comments     | Number of comments                                        | mediumint unsigned | YES  |     | NULL    |       |
+| activities   | Number of activities (like, dislike, ...)                 | mediumint unsigned | YES  |     | NULL    |       |
 
 Indexes
 ------------
 
-| Name      | Fields    |
-| --------- | --------- |
-| PRIMARY   | uri-id    |
-| author-id | author-id |
-| created   | created   |
+| Name     | Fields   |
+| -------- | -------- |
+| PRIMARY  | uri-id   |
+| owner-id | owner-id |
+| created  | created  |
 
 Foreign Keys
 ------------
@@ -30,6 +30,6 @@ Foreign Keys
 | Field | Target Table | Target Field |
 |-------|--------------|--------------|
 | uri-id | [item-uri](help/database/db_item-uri) | id |
-| author-id | [contact](help/database/db_contact) | id |
+| owner-id | [contact](help/database/db_contact) | id |
 
 Return to [database documentation](help/database)
index 040ba2f944769a30545b3700df31c9706692bd92..81ba6250233dfd7166d124777eb1473ea3e08dd3 100644 (file)
@@ -64,7 +64,7 @@ class Engagement
                        return;
                }
 
-               $parent = Post::selectFirst(['created', 'author-id', 'uid', 'private', 'contact-contact-type'], ['uri-id' => $item['parent-uri-id']]);
+               $parent = Post::selectFirst(['created', 'owner-id', 'uid', 'private', 'contact-contact-type'], ['uri-id' => $item['parent-uri-id']]);
                if ($parent['private'] != Item::PUBLIC) {
                        Logger::debug('Non public posts are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $parent['uid'], 'private' => $parent['private']]);
                        return;
@@ -77,7 +77,7 @@ class Engagement
 
                $engagement = [
                        'uri-id'       => $item['parent-uri-id'],
-                       'author-id'    => $parent['author-id'],
+                       'owner-id'     => $parent['owner-id'],
                        'contact-type' => $parent['contact-contact-type'],
                        'created'      => $parent['created'],
                        'comments'     => DBA::count('post', ['parent-uri-id' => $item['parent-uri-id'], 'gravity' => Item::GRAVITY_COMMENT]),
index 42ca508be52787d019d6c70495504d008fe82f7b..60488a2d4c8104dc921afb2f085f51c66641e656 100644 (file)
@@ -245,13 +245,13 @@ class Channel extends BaseModule
                } elseif (self::$content == self::FORYOU) {
                        $cid = Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
 
-                       $condition = ["(`author-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR
-                               ((`comments` >= ?  OR `activities` >= ?) AND `author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?))) OR
-                               ( `author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))",
+                       $condition = ["(`owner-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR
+                               ((`comments` >= ? OR `activities` >= ?) AND `owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?))) OR
+                               ( `owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))",
                                $cid, self::getMedianThreadScore($cid, 4), self::getMedianComments(4), self::getMedianActivities(4), DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING,
                                DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING];
                } elseif (self::$content == self::FOLLOWERS) {
-                       $condition = ["`author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", DI::userSession()->getLocalUserId(), Contact::FOLLOWER];
+                       $condition = ["`owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", DI::userSession()->getLocalUserId(), Contact::FOLLOWER];
                }
 
                if ((self::$content != self::WHATSHOT) && !is_null(self::$accountType)) {
index 8912e4982d29b3e4efd14bcd62c9d33222540992..3403a746929823f34367073524656a3ddc06aef8 100644 (file)
@@ -1327,7 +1327,7 @@ return [
                "comment" => "Engagement data per post",
                "fields" => [
                        "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1",  "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
-                       "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
+                       "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Item owner"],
                        "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Person, organisation, news, community, relay"],
                        "created" => ["type" => "datetime", "comment" => ""],
                        "comments" => ["type" => "mediumint unsigned", "comment" => "Number of comments"],
@@ -1335,7 +1335,7 @@ return [
                ],
                "indexes" => [
                        "PRIMARY" => ["uri-id"],
-                       "author-id" => ["author-id"],
+                       "owner-id" => ["owner-id"],
                        "created" => ["created"],
                ]
        ],