Skip to content

Commit

Permalink
Minor cli bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianFun123 committed Jul 24, 2022
1 parent 0723545 commit 89abf82
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "interaapps/ulole",
"type": "library",
"version": "3.0.6",
"version": "3.1.1",
"authors": [
{
"name": "JulianFun123",
Expand Down
2 changes: 1 addition & 1 deletion src/main/de/interaapps/ulole/core/cli/modules/ORMCLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function registerCommands(CLI $cli) {
echo str_pad(" model", $modelLength) . " | migrated | version\n";

foreach ($migrations as $migrationClazz) {
$migrationModel = MigrationModel::table($args[2])->where("migrated_model", $migrationClazz)->get();
$migrationModel = MigrationModel::table($args[2])->where("migrated_model", $migrationClazz)->first();
$exists = $migrationModel !== null;

$migrationClazzSplitted = explode("\\", $migrationClazz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@ public function registerCommands(CLI $cli) {
if (readline("Continue (y): ") != 'y')
return "Declined";
}
$lower = $args[2] . 's';
$output = "<?php
namespace app\model;
use de\interaapps\ulole\orm\attributes\Table;
use de\interaapps\ulole\orm\migration\Column;
use de\interaapps\ulole\orm\ORMModel;
#[Table('$lower')]
class $args[2] {
use ORMModel;
public \$id, \$name, \$gender, \$created_at;
protected \$ormSettings = [
'identifier' => 'id'
];
#[Column]
public int \$id;
#[Column]
public ?string \$name;
}";
Colors::done("Created model in $outputFile!");
$lower = $args[2] . 's';

$lower[0] = strtolower($lower[0]);
echo
"\nTo register: \n\n"
Expand All @@ -41,8 +45,6 @@ class $args[2] {
. "UloleORM" . Colors::TURQUIOUS . "::"
. Colors::BLUE . "register" .
Colors::TURQUIOUS . "(" .
Colors::GREEN . '"' . $lower . '"' .
Colors::TURQUIOUS . ", " .
Colors::YELLOW . "\\app\\model\\" . $args[2] . Colors::TURQUIOUS . "::" . Colors::BLUE . "class" .
Colors::TURQUIOUS . ");" .
" " .
Expand Down
5 changes: 4 additions & 1 deletion src/main/de/interaapps/ulole/core/jobs/JobHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function runNow(Job $job): bool {
return false;
}

/**
* @return JobModel[]|null
*/
public function getOpened(): array|null {
return JobModel::table($this->database)->where("state", "OPEN")->orWhere("state", "FAILED")->get();
}
Expand All @@ -45,7 +48,7 @@ public function handleAll(): array {
foreach ($this->getOpened() as $jobModel) {
$jobModel->state = "RUNNING";
$jobModel->save($this->database);
if ($jobModel->failed_count++ < $jobModel->repeat) {
if ($jobModel->failedCount++ < $jobModel->repeat) {
try {
$job = unserialize($jobModel->object);
$job->run($this);
Expand Down
4 changes: 2 additions & 2 deletions src/main/de/interaapps/ulole/core/jobs/JobModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class JobModel {
#[Column]
public int $repeat;
#[Column]
public int $failed_count;
public int $failedCount;
#[Column]
public string $created_at;
public string $createdAt;

}
2 changes: 1 addition & 1 deletion uppm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ulole-core",
"version": "3.1.0",
"version": "3.1.1",
"repositories": [],
"run": {},
"build": {},
Expand Down

0 comments on commit 89abf82

Please sign in to comment.