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

fix: Story Timestamp will be filled now when inserting by DEI import (Java Api) #141

Merged
merged 3 commits into from
Mar 20, 2025
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
39 changes: 39 additions & 0 deletions src/app/Console/Commands/FillStoryTimestampFromImportName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Console\Commands;

use Illuminate\Support\Facades\DB;
use Illuminate\Console\Command;
use Carbon\Carbon;

class FillStoryTimestampFromImportName extends Command
{
protected $signature = 'fill:timestamps';
protected $description = 'Fill NULL Timestamp columns with datetime extracted from ImportName';

public function __construct()
{
parent::__construct();
}

public function handle(): void
{
$stories = DB::table('Story')
->whereNull('Timestamp')
->get();

foreach ($stories as $story) {
preg_match('/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})/', $story->ImportName, $matches);

if (!empty($matches)) {
$datetime = Carbon::parse($matches[0]);

DB::table('Story')
->where('StoryId', $story->StoryId)
->update(['Timestamp' => $datetime]);
}
}

$this->info('Timestamps have been filled successfully!');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
public function up()
{
DB::statement('ALTER TABLE `Story` MODIFY `Timestamp` DATETIME DEFAULT CURRENT_TIMESTAMP');
}

public function down()
{
DB::statement('ALTER TABLE `Story` MODIFY `Timestamp` DATETIME NULL');
}
};
2 changes: 1 addition & 1 deletion src/storage/api-docs/api-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.1.1

info:
version: 1.58.0
version: 1.58.1
title: Transcribathon Platform API v2
description: This is the documentation of the Transcribathon API v2 used by [https:transcribathon.eu](https://transcribathon.eu/).<br />
For authorization you can use the the bearer token you are provided with.
Expand Down