This commit is contained in:
Patrick Niebeling
2025-03-12 11:29:30 +01:00
parent 9538c99576
commit 1e46c19f1b
14 changed files with 202 additions and 130 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace OCA\Deckflow\Migrations;
use OCP\Migration\ITransaction;
use OCP\Migration\IOutput;
class Version20250312000000 implements ITransaction {
public function execute(IOutput $output) {
// Erstelle die Workflow-Tabelle
$output->output('Erstelle die deckflow_workflows-Tabelle...');
$query = 'CREATE TABLE IF NOT EXISTS `*deckflow_workflows` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` VARCHAR(255) NOT NULL,
`deck_id` INT NOT NULL,
`source_stack_id` INT NOT NULL,
`target_stack_id` INT NOT NULL,
`created_at` DATETIME NOT NULL,
`last_run` DATETIME DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;';
\OC::$server->getDatabaseConnection()->executeQuery($query);
$output->output('Migration abgeschlossen.');
}
}

18
lib/WorkflowJob.php Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace OCA\Deckflow;
use OC\BackgroundJob\TimedJob;
use OCP\BackgroundJob\IJob;
class WorkflowJob extends TimedJob {
public function run($argument) {
// Hole überfällige Workflows und verschiebe Karten
$workflowRepo = new WorkflowRepository();
$overdueWorkflows = $workflowRepo->getOverdueWorkflows();
foreach ($overdueWorkflows as $workflow) {
$workflowRepo->moveCardToTargetStack($workflow['card_id'], $workflow['target_stack_id']);
}
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace OCA\Deckflow;
use OCP\DB\DbWrapper\SimpleDatabase;
use OCP\DB\DB;
class WorkflowRepository {
private $db;
public function __construct() {
$this->db = DB::getConnection();
}
// Alle Workflows eines Benutzers abrufen
public function getWorkflowsForUser($user_id) {
$query = 'SELECT * FROM *deckflow_workflows WHERE user_id = ?';
return $this->db->executeQuery($query, [$user_id])->fetchAll();
}
// Workflow erstellen
public function createWorkflow($user_id, $deck_id, $source_stack_id, $target_stack_id) {
$query = 'INSERT INTO *deckflow_workflows (user_id, deck_id, source_stack_id, target_stack_id, created_at) VALUES (?, ?, ?, ?, ?)';
$this->db->executeQuery($query, [$user_id, $deck_id, $source_stack_id, $target_stack_id, date('Y-m-d H:i:s')]);
}
// Workflow löschen
public function deleteWorkflow($workflow_id) {
$query = 'DELETE FROM *deckflow_workflows WHERE id = ?';
$this->db->executeQuery($query, [$workflow_id]);
}
// Workflows mit überfälligen Karten abrufen
public function getOverdueWorkflows() {
// Logik zum Abrufen überfälliger Karten
}
// Karte verschieben
public function moveCardToTargetStack($card_id, $target_stack_id) {
// Logik zum Verschieben von Karten
}
}