Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔨 Add missing temporary files from prod #3039

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions app/Console/Commands/CalculateMissingDuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Console\Commands;

use App\Models\Checkin;
use Illuminate\Console\Command;
use Symfony\Component\Console\Command\Command as CommandAlias;

/**
* @deprecated Just created and marked as deprecated, because it is only needed for migrating old checkins.
* Can be deleted after migration.
*/
class CalculateMissingDuration extends Command
{
protected $signature = 'trwl:calculate-missing-duration';
protected $description = 'Calculate missing duration for train checkins. Currently only needed for migrating old checkins.';

public function handle(): int {
while (true) {
Checkin::with(['HafasTrip.stopovers', 'originStation', 'destinationStation'])
->whereNull('duration')
->limit(250)
->each(function($checkin) {
// foreach ($checkins as $checkin) {
$duration = $checkin->duration;
$this->info("Duration for checkin {$checkin->id} is {$duration}");
//}
});
}
return CommandAlias::SUCCESS;
}
}
2 changes: 2 additions & 0 deletions app/Console/Commands/PolylinesToFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function handle(): int {
$start = microtime(true);
$rows = DB::table('poly_lines')
->where('polyline', '!=', '{}')
->orderBy('id', 'desc')
->limit(1000)
->get();
$this->info('Found ' . $rows->count() . ' polylines.');
$affectedRows = 0;
Expand Down
9 changes: 9 additions & 0 deletions scripts/convert-polylines.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

while true
do
echo "run!"
sudo -u www-data php ../artisan app:polylines-to-files
echo "sleep"
sleep 15
done
Loading