mirror of
https://github.com/friendica/friendica
synced 2024-11-09 17:02:54 +00:00
Use the owner, not the author
This commit is contained in:
parent
ca32134830
commit
fdaff43039
5 changed files with 25 additions and 25 deletions
|
@ -1305,16 +1305,16 @@ CREATE TABLE IF NOT EXISTS `post-delivery-data` (
|
||||||
--
|
--
|
||||||
CREATE TABLE IF NOT EXISTS `post-engagement` (
|
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',
|
`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',
|
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
|
||||||
`created` datetime COMMENT '',
|
`created` datetime COMMENT '',
|
||||||
`comments` mediumint unsigned COMMENT 'Number of comments',
|
`comments` mediumint unsigned COMMENT 'Number of comments',
|
||||||
`activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
|
`activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
|
||||||
PRIMARY KEY(`uri-id`),
|
PRIMARY KEY(`uri-id`),
|
||||||
INDEX `author-id` (`author-id`),
|
INDEX `owner-id` (`owner-id`),
|
||||||
INDEX `created` (`created`),
|
INDEX `created` (`created`),
|
||||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
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';
|
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
|
@ -6,23 +6,23 @@ Engagement data per post
|
||||||
Fields
|
Fields
|
||||||
------
|
------
|
||||||
|
|
||||||
| Field | Description | Type | Null | Key | Default | Extra |
|
| 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 | |
|
| 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 | |
|
| owner-id | Item owner | int unsigned | NO | | 0 | |
|
||||||
| contact-type | Person, organisation, news, community, relay | tinyint | NO | | 0 | |
|
| contact-type | Person, organisation, news, community, relay | tinyint | NO | | 0 | |
|
||||||
| created | | datetime | YES | | NULL | |
|
| created | | datetime | YES | | NULL | |
|
||||||
| comments | Number of comments | mediumint unsigned | YES | | NULL | |
|
| comments | Number of comments | mediumint unsigned | YES | | NULL | |
|
||||||
| activities | Number of activities (like, dislike, ...) | mediumint unsigned | YES | | NULL | |
|
| activities | Number of activities (like, dislike, ...) | mediumint unsigned | YES | | NULL | |
|
||||||
|
|
||||||
Indexes
|
Indexes
|
||||||
------------
|
------------
|
||||||
|
|
||||||
| Name | Fields |
|
| Name | Fields |
|
||||||
| --------- | --------- |
|
| -------- | -------- |
|
||||||
| PRIMARY | uri-id |
|
| PRIMARY | uri-id |
|
||||||
| author-id | author-id |
|
| owner-id | owner-id |
|
||||||
| created | created |
|
| created | created |
|
||||||
|
|
||||||
Foreign Keys
|
Foreign Keys
|
||||||
------------
|
------------
|
||||||
|
@ -30,6 +30,6 @@ Foreign Keys
|
||||||
| Field | Target Table | Target Field |
|
| Field | Target Table | Target Field |
|
||||||
|-------|--------------|--------------|
|
|-------|--------------|--------------|
|
||||||
| uri-id | [item-uri](help/database/db_item-uri) | id |
|
| 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)
|
Return to [database documentation](help/database)
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Engagement
|
||||||
return;
|
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) {
|
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']]);
|
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;
|
return;
|
||||||
|
@ -77,7 +77,7 @@ class Engagement
|
||||||
|
|
||||||
$engagement = [
|
$engagement = [
|
||||||
'uri-id' => $item['parent-uri-id'],
|
'uri-id' => $item['parent-uri-id'],
|
||||||
'author-id' => $parent['author-id'],
|
'owner-id' => $parent['owner-id'],
|
||||||
'contact-type' => $parent['contact-contact-type'],
|
'contact-type' => $parent['contact-contact-type'],
|
||||||
'created' => $parent['created'],
|
'created' => $parent['created'],
|
||||||
'comments' => DBA::count('post', ['parent-uri-id' => $item['parent-uri-id'], 'gravity' => Item::GRAVITY_COMMENT]),
|
'comments' => DBA::count('post', ['parent-uri-id' => $item['parent-uri-id'], 'gravity' => Item::GRAVITY_COMMENT]),
|
||||||
|
|
|
@ -245,13 +245,13 @@ class Channel extends BaseModule
|
||||||
} elseif (self::$content == self::FORYOU) {
|
} elseif (self::$content == self::FORYOU) {
|
||||||
$cid = Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
|
$cid = Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
|
||||||
|
|
||||||
$condition = ["(`author-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR
|
$condition = ["(`owner-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
|
((`comments` >= ? OR `activities` >= ?) AND `owner-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`)))",
|
( `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,
|
$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];
|
DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING];
|
||||||
} elseif (self::$content == self::FOLLOWERS) {
|
} 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)) {
|
if ((self::$content != self::WHATSHOT) && !is_null(self::$accountType)) {
|
||||||
|
|
|
@ -1327,7 +1327,7 @@ return [
|
||||||
"comment" => "Engagement data per post",
|
"comment" => "Engagement data per post",
|
||||||
"fields" => [
|
"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"],
|
"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"],
|
"contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Person, organisation, news, community, relay"],
|
||||||
"created" => ["type" => "datetime", "comment" => ""],
|
"created" => ["type" => "datetime", "comment" => ""],
|
||||||
"comments" => ["type" => "mediumint unsigned", "comment" => "Number of comments"],
|
"comments" => ["type" => "mediumint unsigned", "comment" => "Number of comments"],
|
||||||
|
@ -1335,7 +1335,7 @@ return [
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["uri-id"],
|
"PRIMARY" => ["uri-id"],
|
||||||
"author-id" => ["author-id"],
|
"owner-id" => ["owner-id"],
|
||||||
"created" => ["created"],
|
"created" => ["created"],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue