Skip to content

Commit

Permalink
styleci
Browse files Browse the repository at this point in the history
  • Loading branch information
recursivetree committed Aug 20, 2024
1 parent cb42103 commit 3f2c58f
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 62 deletions.
22 changes: 21 additions & 1 deletion src/Config/web.characterfilter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

return [
['name' => 'scopes', 'src' => 'seatcore::fastlookup.scopes', 'path' => 'refresh_token', 'field' => 'scopes', 'label' => 'Scopes'],
['name' => 'character', 'src' => 'seatcore::fastlookup.characters', 'path' => '', 'field' => 'character_id', 'label' => 'Character'],
Expand All @@ -10,4 +30,4 @@
['name' => 'skill_level', 'src' => [['id' => 1, 'text' => 'Level 1'], ['id' => 2, 'text' => 'Level 2'], ['id' => 3, 'text' => 'Level 3'], ['id' => 4, 'text' => 'Level 4'], ['id' => 5, 'text' => 'Level 5']], 'path' => 'skills', 'field' => 'trained_skill_level', 'label' => 'Skill Level'],
['name' => 'type', 'src' => 'seatcore::fastlookup.items', 'path' => 'assets', 'field' => 'type_id', 'label' => 'Item'],
['name' => 'role', 'src' => 'seatcore::fastlookup.roles', 'path' => 'corporation_roles', 'field' => 'role', 'label' => 'Role'],
];
];
24 changes: 22 additions & 2 deletions src/Events/CharacterFilterDataUpdate.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

namespace Seat\Web\Events;

use Illuminate\Queue\SerializesModels;
Expand All @@ -16,10 +36,10 @@ class CharacterFilterDataUpdate
public CharacterInfo $character;

/**
* @param User $user
* @param User $user
*/
public function __construct(CharacterInfo $character)
{
$this->character = $character;
}
}
}
27 changes: 23 additions & 4 deletions src/Http/Composers/CharacterFilter.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
<?php

namespace Seat\Web\Http\Composers;
/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

namespace Seat\Web\Http\Composers;

use Illuminate\View\View;

class CharacterFilter
{
public function compose(View $view)
{
$rules = config("web.characterfilter");
$rules = config('web.characterfilter');

// work with raw arrays since the filter code requires an array of objects, and laravel collections don't like to give us that
$newrules = [];
Expand All @@ -22,6 +41,6 @@ public function compose(View $view)

}

$view->with("characterFilterRules", $newrules);
$view->with('characterFilterRules', $newrules);
}
}
}
10 changes: 5 additions & 5 deletions src/Http/Controllers/Configuration/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function createSchedulingRule(Request $request)
'filters' => 'required|json',
'name' => 'required|string',
'time' => 'required|numeric',
'timeunit' => 'required|in:hour,day,week'
'timeunit' => 'required|in:hour,day,week',
]);

// $time_modifier: conversion factor from timeunit to seconds
Expand All @@ -118,7 +118,7 @@ public function createSchedulingRule(Request $request)
$rule->filter = $request->filters;
$rule->save();

RefreshToken::all()->each(function ($token){
RefreshToken::all()->each(function ($token) {
CharacterSchedulingRule::updateRefreshTokenSchedule($token);
});

Expand All @@ -129,15 +129,15 @@ public function createSchedulingRule(Request $request)
public function deleteSchedulingRule(Request $request)
{
$request->validate([
'rule_id' => 'required|numeric'
'rule_id' => 'required|numeric',
]);

CharacterSchedulingRule::destroy($request->rule_id);

RefreshToken::all()->each(function ($token){
RefreshToken::all()->each(function ($token) {
CharacterSchedulingRule::updateRefreshTokenSchedule($token);
});

return redirect()->back()->with('success','Successfully removed character scheduling rule!');
return redirect()->back()->with('success', 'Successfully removed character scheduling rule!');
}
}
22 changes: 21 additions & 1 deletion src/Listeners/CharacterFilterDataUpdatedSquads.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

namespace Seat\Web\Listeners;

use Seat\Web\Events\CharacterFilterDataUpdate;
Expand Down Expand Up @@ -30,4 +50,4 @@ public static function handle(CharacterFilterDataUpdate $event)
$squad->members()->save($user);
});
}
}
}
22 changes: 21 additions & 1 deletion src/Listeners/CharacterFilterDataUpdatedTokens.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

namespace Seat\Web\Listeners;

use Seat\Web\Events\CharacterFilterDataUpdate;
Expand All @@ -11,4 +31,4 @@ public static function handle(CharacterFilterDataUpdate $update)
{
CharacterSchedulingRule::updateRefreshTokenSchedule($update->character->refresh_token);
}
}
}
12 changes: 6 additions & 6 deletions src/Models/CharacterSchedulingRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function getFilters(): stdClass
}

/**
* Recomputes the update interval of a character and saves it in the refresh_token_schedules table
* Recomputes the update interval of a character and saves it in the refresh_token_schedules table.
*
* @param RefreshToken $token
* @param RefreshToken $token
* @return void
*/
public static function updateRefreshTokenSchedule(RefreshToken $token): void
Expand All @@ -66,9 +66,9 @@ public static function updateRefreshTokenSchedule(RefreshToken $token): void
}

/**
* Computes the scheduling interval from the character scheduling rules for a character
* Computes the scheduling interval from the character scheduling rules for a character.
*
* @param CharacterInfo $character
* @param CharacterInfo $character
* @return int
*/
private static function getCharacterSchedulingInterval(CharacterInfo $character): int
Expand All @@ -81,6 +81,6 @@ private static function getCharacterSchedulingInterval(CharacterInfo $character)
}
}

return 60*60; // 1 hour
return 60 * 60; // 1 hour
}
}
}
1 change: 0 additions & 1 deletion src/Observers/AbstractCharacterFilterObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Seat\Eveapi\Models\Character\CharacterInfo;
use Seat\Web\Events\CharacterFilterDataUpdate;
use Seat\Web\Exceptions\InvalidFilterException;
use Seat\Web\Models\Squads\Squad;
use Seat\Web\Models\User;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Observers/CharacterAffiliationObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function updated(CharacterAffiliation $affiliation)
/**
* Return the User owning the model which fired the catch event.
*
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @return ?CharacterInfo The character that is affected by this update
*/
protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo
Expand Down
2 changes: 1 addition & 1 deletion src/Observers/CharacterAssetObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function deleted(CharacterAsset $asset)
/**
* Return the User owning the model which fired the catch event.
*
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @return ?CharacterInfo The character that is affected by this update
*/
protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo
Expand Down
2 changes: 1 addition & 1 deletion src/Observers/CharacterRoleObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function deleted(CharacterRole $role)
/**
* Return the User owning the model which fired the catch event.
*
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @return ?CharacterInfo The character that is affected by this update
*/
protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo
Expand Down
2 changes: 1 addition & 1 deletion src/Observers/CharacterSkillObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function findRelatedUser(Model $fired_model): ?User
/**
* Return the User owning the model which fired the catch event.
*
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @return ?CharacterInfo The character that is affected by this update
*/
protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo
Expand Down
2 changes: 1 addition & 1 deletion src/Observers/CharacterTitleObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function deleted(CharacterTitle $title)
/**
* Return the User owning the model which fired the catch event.
*
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @return ?CharacterInfo The character that is affected by this update
*/
protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo
Expand Down
2 changes: 1 addition & 1 deletion src/Observers/RefreshTokenObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function restored(RefreshToken $token)
/**
* Return the User owning the model which fired the catch event.
*
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event
* @return ?CharacterInfo The character that is affected by this update
*/
protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo
Expand Down
2 changes: 1 addition & 1 deletion src/WebServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private function add_view_composers()
$this->app['view']->composer([
'web::squads.edit',
'web::squads.create',
'web::configuration.schedule.view'
'web::configuration.schedule.view',
], CharacterFilter::class);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<?php

use \Illuminate\Database\Migrations\Migration;
/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Expand All @@ -14,9 +34,9 @@ public function up()
{
Schema::create('character_scheduling_rules', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string("name");
$table->integer("interval")->unsigned();
$table->json("filter");
$table->string('name');
$table->integer('interval')->unsigned();
$table->json('filter');
});
}

Expand All @@ -29,4 +49,4 @@ public function down()
{
Schema::drop('character_scheduling_rules');
}
};
};
3 changes: 1 addition & 2 deletions src/resources/lang/en/seat.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,14 @@
'scheduled_commands' => 'Scheduled Commands',
'choose_prepop' => 'Choose a pre-populated cron expression, or write your own.',
'add_scheduled' => 'Add Scheduled Command',
'character_scheduling_rule'=>'character scheduling rule',
'character_scheduling_rule' => 'character scheduling rule',
'character_scheduling_rules' => 'Character Scheduling Rules',
'new_character_scheduling_rule' => 'New Character Scheduling Rule',
'update_interval' => 'Update Interval',
'name_input_placeholder' => 'Enter a name...',
'character_scheduling_rules_empty' => 'There are no character scheduling rules defined, using a default of one hour for everyone.',
'character_scheduling_rules_default' => 'When no rules apply to a character, an update interval of one hour is used.',


// Security
'category' => 'Category',
'message' => 'Message',
Expand Down
Loading

0 comments on commit 3f2c58f

Please sign in to comment.