INDEX `post-user-id` (`post-user-id`),
INDEX `commented` (`commented`),
INDEX `uid_received` (`uid`,`received`),
+ INDEX `uid_wall_received` (`uid`,`wall`,`received`),
INDEX `uid_pinned` (`uid`,`pinned`),
INDEX `uid_commented` (`uid`,`commented`),
INDEX `uid_starred` (`uid`,`starred`),
Indexes
------------
-| Name | Fields |
-| ------------- | -------------- |
-| PRIMARY | uid, uri-id |
-| uri-id | uri-id |
-| owner-id | owner-id |
-| author-id | author-id |
-| causer-id | causer-id |
-| uid | uid |
-| contact-id | contact-id |
-| psid | psid |
-| post-user-id | post-user-id |
-| commented | commented |
-| uid_received | uid, received |
-| uid_pinned | uid, pinned |
-| uid_commented | uid, commented |
-| uid_starred | uid, starred |
-| uid_mention | uid, mention |
+| Name | Fields |
+| ----------------- | ------------------- |
+| PRIMARY | uid, uri-id |
+| uri-id | uri-id |
+| owner-id | owner-id |
+| author-id | author-id |
+| causer-id | causer-id |
+| uid | uid |
+| contact-id | contact-id |
+| psid | psid |
+| post-user-id | post-user-id |
+| commented | commented |
+| uid_received | uid, received |
+| uid_wall_received | uid, wall, received |
+| uid_pinned | uid, pinned |
+| uid_commented | uid, commented |
+| uid_starred | uid, starred |
+| uid_mention | uid, mention |
Foreign Keys
------------
return DBA::count('post-user-view', $condition, $params);
}
+ /**
+ * Counts the post-thread-user-view records satisfying the provided condition
+ *
+ * @param array $condition array of fields for condition
+ * @param array $params Array of several parameters
+ *
+ * @return int
+ *
+ * Example:
+ * $condition = ["uid" => 1, "network" => 'dspr'];
+ * or:
+ * $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
+ *
+ * $count = Post::count($condition);
+ * @throws \Exception
+ */
+ public static function countThread(array $condition = [], array $params = [])
+ {
+ return DBA::count('post-thread-user-view', $condition, $params);
+ }
+
/**
* Counts the post-view records satisfying the provided condition
*
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
- $posts_day = Post::count($condition);
+ $posts_day = Post::countThread($condition);
if ($posts_day > $throttle_day) {
Logger::info('Daily posting limit reached', ['uid' => $uid, 'posts' => $posts_day, 'limit' => $throttle_day]);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
- $posts_week = Post::count($condition);
+ $posts_week = Post::countThread($condition);
if ($posts_week > $throttle_week) {
Logger::info('Weekly posting limit reached', ['uid' => $uid, 'posts' => $posts_week, 'limit' => $throttle_week]);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
- $posts_month = Post::count($condition);
+ $posts_month = Post::countThread($condition);
if ($posts_month > $throttle_month) {
Logger::info('Monthly posting limit reached', ['uid' => $uid, 'posts' => $posts_month, 'limit' => $throttle_month]);
"post-user-id" => ["post-user-id"],
"commented" => ["commented"],
"uid_received" => ["uid", "received"],
+ "uid_wall_received" => ["uid", "wall", "received"],
"uid_pinned" => ["uid", "pinned"],
"uid_commented" => ["uid", "commented"],
"uid_starred" => ["uid", "starred"],