Moved stats into a single db_query call.
This commit is contained in:
parent
35d7150965
commit
aec69ff19c
2 changed files with 30 additions and 32 deletions
|
@ -12,41 +12,39 @@ if (config_get_default(false, 'Site', 'embed_linked_data')) {
|
|||
|
||||
$news = news_posts_get(0, 5, null, true);
|
||||
|
||||
$stats = [
|
||||
'users' => db_query('
|
||||
SELECT
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_deleted` IS NULL
|
||||
) as `all`,
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_active` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||
) as `online`,
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_active` >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
|
||||
) as `active`
|
||||
')->fetch(PDO::FETCH_ASSOC),
|
||||
'comments' => (int)db_query('
|
||||
$stats = db_fetch(db_query('
|
||||
SELECT
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_deleted` IS NULL
|
||||
) AS `count_users_all`,
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_active` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||
) AS `count_users_online`,
|
||||
(
|
||||
SELECT COUNT(`user_id`)
|
||||
FROM `msz_users`
|
||||
WHERE `user_active` >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
|
||||
) AS `count_users_active`,
|
||||
(
|
||||
SELECT COUNT(`comment_id`)
|
||||
FROM `msz_comments_posts`
|
||||
WHERE `comment_deleted` IS NULL
|
||||
')->fetchColumn(),
|
||||
'forum_topics' => (int)db_query('
|
||||
) AS `count_comments`,
|
||||
(
|
||||
SELECT COUNT(`topic_id`)
|
||||
FROM `msz_forum_topics`
|
||||
WHERE `topic_deleted` IS NULL
|
||||
')->fetchColumn(),
|
||||
'forum_posts' => (int)db_query('
|
||||
) AS `count_forum_topics`,
|
||||
(
|
||||
SELECT COUNT(`post_id`)
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `post_deleted` IS NULL
|
||||
')->fetchColumn(),
|
||||
];
|
||||
) AS `count_forum_posts`
|
||||
'));
|
||||
|
||||
$changelog = db_query('
|
||||
SELECT
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<i class="fas fa-users fa-fw"></i> Users
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.users.all|number_format }}
|
||||
{{ statistics.count_users_all|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
|||
<i class="fas fa-comment-dots fa-fw"></i> Comments
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.comments|number_format }}
|
||||
{{ statistics.count_comments|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
|||
<i class="fas fa-user-check fa-fw"></i> Online
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.users.online|number_format }}
|
||||
{{ statistics.count_users_online|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
|||
<i class="fas fa-user-clock fa-fw"></i> Active (24 hr)
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.users.active|number_format }}
|
||||
{{ statistics.count_users_active|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
|||
<i class="fas fa-list fa-fw"></i> Topics
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.forum_topics|number_format }}
|
||||
{{ statistics.count_forum_topics|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
|||
<i class="fas fa-comments fa-fw"></i> Posts
|
||||
</div>
|
||||
<div class="index__statistic__value">
|
||||
{{ statistics.forum_posts|number_format }}
|
||||
{{ statistics.count_forum_posts|number_format }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue