streams/Code/Lib/Statistics.php

63 lines
1.9 KiB
PHP
Raw Normal View History

2022-01-25 05:49:48 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Lib;
2022-01-25 05:49:48 +00:00
2022-02-16 04:08:28 +00:00
use Code\Lib\Config;
2022-01-25 05:49:48 +00:00
class Statistics {
2022-03-05 07:01:35 +00:00
public static function get_channels_all()
2022-01-25 05:49:48 +00:00
{
$r = q(
"select count(channel_id) as channels_total from channel left join account on account_id = channel_account_id
where account_flags = 0 "
);
$total = ($r) ? intval($r[0]['channels_total']) : 0;
Config::Set('system', 'channels_total_stat', $total);
return $total;
}
2022-03-05 07:01:35 +00:00
public static function get_channels_6mo()
2022-01-25 05:49:48 +00:00
{
$r = q(
"select channel_id from channel left join account on account_id = channel_account_id
where account_flags = 0 and channel_active > %s - INTERVAL %s",
db_utcnow(),
db_quoteinterval('6 MONTH')
);
$total = ($r) ? count($r) : 0;
Config::Set('system', 'channels_active_halfyear_stat', $total);
return $total;
}
2022-03-05 07:01:35 +00:00
public static function get_channels_1mo()
2022-01-25 05:49:48 +00:00
{
$r = q(
"select channel_id from channel left join account on account_id = channel_account_id
where account_flags = 0 and channel_active > %s - INTERVAL %s",
db_utcnow(),
db_quoteinterval('1 MONTH')
);
$total = ($r) ? count($r) : 0;
Config::Set('system', 'channels_active_monthly_stat', $total);
2022-01-25 21:26:05 +00:00
return $total;
2022-01-25 05:49:48 +00:00
}
2022-03-05 07:01:35 +00:00
public static function get_posts()
2022-01-25 05:49:48 +00:00
{
$posts = q("SELECT COUNT(*) AS local_posts FROM item WHERE item_wall = 1 and id = parent");
$total = ($posts) ? intval($posts[0]['local_posts']) : 0;
Config::Set('system', 'local_posts_stat', $total);
return $total;
}
2022-03-05 07:01:35 +00:00
public static function get_comments()
2022-01-25 05:49:48 +00:00
{
$posts = q("SELECT COUNT(*) AS local_posts FROM item WHERE item_wall = 1 and id != parent");
$total = ($posts) ? intval($posts[0]['local_posts']) : 0;
Config::Set('system', 'local_comments_stat', $total);
return $total;
}
}