Skip to content

Commit

Permalink
Rename variables/methods for better understanding
Browse files Browse the repository at this point in the history
  • Loading branch information
lehecht committed Apr 3, 2024
1 parent 42f5ebb commit 7ce9cc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Console/Commands/CountUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function handle()

private function countUser()
{
$today = Carbon::yesterday()->toDateString();
$yesterday = Carbon::yesterday()->toDateString();

return User::where('login_at', '=', $today)->count();
return User::where('login_at', '=', $yesterday)->count();
}
}
7 changes: 4 additions & 3 deletions src/Console/Commands/DetermineStorageUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ class DetermineStorageUsage extends Command
*/
public function handle()
{
$size = $this->determineSize();
$size = $this->getSizeInGB();

$date = Carbon::now()->subMonth()->endOfMonth()->toDateString();

DB::table('kpis_storage_usage')->insert(['date' => $date, 'value' => $size]);
}

private function determineSize()
private function getSizeInGB()
{
$byte = 1000000000;
$imageStorageUsage = Image::sum(DB::raw("(attrs->>'size')::bigint"));
$videoStorageUsage = Video::sum(DB::raw("(attrs->>'size')::bigint"));
return ($imageStorageUsage + $videoStorageUsage)/1000000000;
return ($imageStorageUsage + $videoStorageUsage)/$byte;
}
}

0 comments on commit 7ce9cc4

Please sign in to comment.