Skip to content

Commit

Permalink
Add "Videos optimized" to /stats command
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasss93 committed Jul 16, 2024
1 parent dfafdd7 commit 0b4688c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 6 deletions.
33 changes: 33 additions & 0 deletions app/Models/Statistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ public static function getStatsForBot(): array
->where('action', 'sticker.optimized')
->count();

// videos optimized
$videosOptimizedYesterday = self::query()
->where('action', 'video.optimized')
->whereBetween('collected_at', [$date->subDay()->startOfDay(), $date->subDay()->endOfDay()])
->count();
$videosOptimizedToday = self::query()
->where('action', 'video.optimized')
->whereBetween('collected_at', [$date->startOfDay(), $date->endOfDay()])
->count();
$videosOptimizedWeek = self::query()
->where('action', 'video.optimized')
->whereBetween('collected_at', [$date->startOfWeek(), $date->endOfWeek()])
->count();
$videosOptimizedMonth = self::query()
->where('action', 'video.optimized')
->whereBetween('collected_at', [$date->startOfMonth(), $date->endOfMonth()])
->count();
$videosOptimizedYear = self::query()
->where('action', 'video.optimized')
->whereBetween('collected_at', [$date->startOfYear(), $date->endOfYear()])
->count();
$videosOptimizedTotal = self::query()
->where('action', 'video.optimized')
->count();

//active users
$activeUsersYesterday = self::query()
->distinct()
Expand Down Expand Up @@ -131,6 +156,14 @@ public static function getStatsForBot(): array
'year' => number_format($stickersOptimizedYear, thousands_separator: '˙'),
'total' => number_format($stickersOptimizedTotal, thousands_separator: '˙'),
],
'videos_optimized' => [
'yesterday' => number_format($videosOptimizedYesterday, thousands_separator: '˙'),
'today' => number_format($videosOptimizedToday, thousands_separator: '˙'),
'week' => number_format($videosOptimizedWeek, thousands_separator: '˙'),
'month' => number_format($videosOptimizedMonth, thousands_separator: '˙'),
'year' => number_format($videosOptimizedYear, thousands_separator: '˙'),
'total' => number_format($videosOptimizedTotal, thousands_separator: '˙'),
],
'active_users' => [
'yesterday' => number_format($activeUsersYesterday, thousands_separator: '˙'),
'today' => number_format($activeUsersToday, thousands_separator: '˙'),
Expand Down
6 changes: 4 additions & 2 deletions app/Telegram/Commands/StatsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function updateStatsMessage(Nutgram $bot, string $value)
protected function getMessage(array $data, string $value): string
{
$title = match ($value) {
'stickers_optimized' => __('stats.category.optimized'),
'stickers_optimized' => __('stats.category.optimized.stickers'),
'videos_optimized' => __('stats.category.optimized.videos'),
'active_users' => __('stats.category.active_users'),
'users' => __('stats.category.new_users'),
};
Expand All @@ -80,7 +81,8 @@ protected function getKeyboard(): InlineKeyboardMarkup
{
return InlineKeyboardMarkup::make()
->addRow(
InlineKeyboardButton::make(__('stats.category.optimized'), callback_data: 'stats:stickers_optimized'),
InlineKeyboardButton::make(__('stats.category.optimized.stickers'), callback_data: 'stats:stickers_optimized'),
InlineKeyboardButton::make(__('stats.category.optimized.videos'), callback_data: 'stats:videos_optimized'),
)->addRow(
InlineKeyboardButton::make(__('stats.category.active_users'), callback_data: 'stats:active_users'),
InlineKeyboardButton::make(__('stats.category.new_users'), callback_data: 'stats:users'),
Expand Down
5 changes: 4 additions & 1 deletion lang/en/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

'title' => '📊 Statistics',
'category' => [
'optimized' => '🖼 Stickers optimized',
'optimized' => [
'stickers' => '🖼 Stickers optimized',
'videos' => '🎬 Videos optimized',
],
'new_users' => '👥 Users',
'active_users' => '✳️ Active users',
],
Expand Down
5 changes: 4 additions & 1 deletion lang/it/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

'title' => '📊 Statistiche',
'category' => [
'optimized' => '🖼 Sticker ottimizzati',
'optimized' => [
'stickers' => '🖼 Sticker ottimizzati',
'videos' => '🎬 Video ottimizzati',
],
'new_users' => '👥 Utenti',
'active_users' => '✳️ Utenti attivi',
],
Expand Down
3 changes: 2 additions & 1 deletion lang/localization.csv
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ donate,terms,Terms and conditions for donation payments,Termini e condizioni per
donate,thanks,Thank you for your donation!,Grazie per la tua donazione!,Dziękujemy za wsparcie!
donate,with,Donate with :service,Dona con :service,Wesprzyj za pomocą :service
stats,title,📊 Statistics,📊 Statistiche,📊 Statystyki
stats,category.optimized,🖼 Stickers optimized,🖼 Sticker ottimizzati,🖼 Naklejki zoptymalizowane
stats,category.optimized.stickers,🖼 Stickers optimized,🖼 Sticker ottimizzati,🖼 Naklejki zoptymalizowane
stats,category.optimized.videos,🎬 Videos optimized,🎬 Video ottimizzati,🎬 Zoptymalizowane naklejki
stats,category.new_users,👥 Users,👥 Utenti,👥 Wszyscy
stats,category.active_users,✳️ Active users,✳️ Utenti attivi,✳️ Aktywni użytkownicy
stats,last_update,Last update:,Ultimo aggiornamento:,Ostatnia aktualizacja:
Expand Down
5 changes: 4 additions & 1 deletion lang/pl/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

'title' => '📊 Statystyki',
'category' => [
'optimized' => '🖼 Naklejki zoptymalizowane',
'optimized' => [
'stickers' => '🖼 Naklejki zoptymalizowane',
'videos' => '🎬 Zoptymalizowane naklejki',
],
'new_users' => '👥 Wszyscy',
'active_users' => '✳️ Aktywni użytkownicy',
],
Expand Down

0 comments on commit 0b4688c

Please sign in to comment.