Skip to content

Commit

Permalink
Merge pull request #2256 from codeeu/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
alainvd authored Aug 8, 2024
2 parents 614dad7 + a85fd89 commit 994b6d1
Show file tree
Hide file tree
Showing 2,084 changed files with 58,195 additions and 70,206 deletions.
17 changes: 16 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
APP_ENV=local
APP_KEY=base64:ilyL17PxJTnZXqNBVr+P36ARu9NF7HgqJ87ciGWvo5E=
APP_DEBUG=false
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite

CACHE_DRIVER=array
CACHE_STORE=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

Expand All @@ -22,7 +32,12 @@ AWS_BUCKET=codeweek-dev
AWS_URL=https://codeweek-s3.s3.amazonaws.com/

LOG_CHANNEL=stack
LOG_STACK=single

LOCALES=al,ba,bg,cs,da,de,el,en,es,et,fi,fr,hr,hu,it,lt,lv,me,mk,nl,pl,pt,ro,rs,sk,sl,sv

ADMIN_EMAIL=[email protected]

SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
2 changes: 1 addition & 1 deletion .env.travis
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DB_DATABASE=codeweek
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=array
CACHE_STORE=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.1'
php-version: '8.3'
tools: composer:v2
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/public/hot
/public/build
/public/storage
/storage/*.key
/vendor
Expand All @@ -18,10 +19,13 @@ public/css/app.css
public/mix-manifest.json
public/vendor/nova/*
resources/lang/vendor/*
resources/lang/*.json
resources/latex/texput.log
!app/Nova
auth.json
vue-i18n-locales.generated.js
/storage/debugbar/
/phpunit.xml
/.phpunit.cache
/.phpunit.result.cache

12 changes: 12 additions & 0 deletions .run/dev.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dev" type="js.build_tools.npm" activateToolWindowBeforeRun="false" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="dev" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ before_script:
- travis_retry composer install ${COMPOSER_FLAGS} --no-interaction --prefer-source
- php artisan vue-i18n:generate
- yarn install
- npm run prod
- npm run build
- php artisan key:generate

cache:
Expand Down
18 changes: 9 additions & 9 deletions app/Achievements/Achievement.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php


namespace App\Achievements;


use App\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Achievement extends Model
{

protected $guarded = [];

public function awardTo(User $user){
public function awardTo(User $user)
{
$this->users()->attach($user);
}

public function users(){
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class, 'user_achievements');
}

Expand All @@ -29,9 +29,9 @@ public function levelAsNumber()
][$this->level];
}

// public function newCollection(array $models = [])
// {
// return new Achievements($models);
// }
// public function newCollection(array $models = [])
// {
// return new Achievements($models);
// }

}
7 changes: 3 additions & 4 deletions app/Achievements/Achievements.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php


namespace App\Achievements;


use Illuminate\Database\Eloquent\Collection;

class Achievements extends Collection
{
public function for($user){
public function for($user)
{
return $user->achievements;
}

Expand All @@ -30,4 +29,4 @@ public function asPercentageOfTotalAvailable()

return $totalAchievements ? round($this->count() / $totalAchievements * 100) : 0;
}
}
}
17 changes: 4 additions & 13 deletions app/Achievements/AchievementsServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<?php


namespace App\Achievements;


use App\Achievements\Console\GenerateAchievementCommand;
use App\Achievements\Console\SyncExperience;
use App\Achievements\Console\SyncUsersAchievements;
use App\Achievements\Events\UserEarnedExperience;


use App\Achievements\Types\StartYourEngines;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;

class AchievementsServiceProvider extends ServiceProvider
{

protected $achievements = [
Types\OrganiserActive2021::class,
Types\OrganiserExpert2021::class,
Expand Down Expand Up @@ -57,16 +51,16 @@ class AchievementsServiceProvider extends ServiceProvider
Types\InfluencerActive2024::class,
Types\InfluencerExpert2024::class,
Types\InfluencerChampion2024::class,
Types\InfluencerLegendary2024::class
Types\InfluencerLegendary2024::class,

];

public function boot()
public function boot(): void
{
Event::listen(UserEarnedExperience::class, AwardAchievements::class);
}

public function register()
public function register(): void
{
$this->app->singleton('achievements', function () {
return cache()->rememberForever('achievements', function () {
Expand All @@ -76,9 +70,6 @@ public function register()
});
});

$this->commands([GenerateAchievementCommand::class,SyncUsersAchievements::class, SyncExperience::class]);
$this->commands([GenerateAchievementCommand::class, SyncUsersAchievements::class, SyncExperience::class]);
}



}
4 changes: 1 addition & 3 deletions app/Achievements/AwardAchievements.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace App\Achievements;


use App\Achievements\Events\UserEarnedExperience;

class AwardAchievements
Expand All @@ -19,4 +17,4 @@ public function scanForAwards($user)
app('achievements')->filter->qualifier($user)->map->modelKey()
);
}
}
}
12 changes: 5 additions & 7 deletions app/Achievements/Console/GenerateAchievementCommand.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace App\Achievements\Console;


use Illuminate\Console\Command;

class GenerateAchievementCommand extends Command
Expand All @@ -12,19 +10,19 @@ class GenerateAchievementCommand extends Command

protected $description = 'Generate a new Achievement class stub.';

public function handle()
public function handle(): void
{
$path = app_path('Achievements/Types/'.$this->argument('name') . '.php');
$path = app_path('Achievements/Types/'.$this->argument('name').'.php');

file_put_contents($path, $this->compileTemplate());

$this->info($path . ' was created!');
$this->info($path.' was created!');
}

protected function compileTemplate()
{
$stub = file_get_contents(app_path('Achievements/Console/achievement.stub'));

return str_replace('{{CLASS}}',$this->argument('name'), $stub);
return str_replace('{{CLASS}}', $this->argument('name'), $stub);
}
}
}
28 changes: 11 additions & 17 deletions app/Achievements/Console/SyncExperience.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Carbon\Carbon;
use Illuminate\Console\Command;


class SyncExperience extends Command
{
/**
Expand All @@ -25,34 +24,29 @@ class SyncExperience extends Command

/**
* Execute the console command.
*
* @return int
*/
public function handle()
public function handle(): int
{

User::role("leading teacher")
->chunk(10, function($users, $index){
$this->reportProgress($index);
$users->each(function($user){
User::role('leading teacher')
->chunk(10, function ($users, $index) {
$this->reportProgress($index);
$users->each(function ($user) {

for ($year = 2021; $year <= Carbon::now()->year; $year++ ){
for ($year = 2021; $year <= Carbon::now()->year; $year++) {

$user->resetExperience($year);
$user->resetExperience($year);

$user->awardExperience($user->reported($year) * 2, $year);
$user->awardExperience($user->reported($year) * 2, $year);

$user->awardExperience($user->influence($year), $year);
$user->awardExperience($user->influence($year), $year);

}
}

});
});
});
}

/**
* @param $index
*/
protected function reportProgress($index): void
{
$from = ($index - 1) * 10;
Expand Down
23 changes: 9 additions & 14 deletions app/Achievements/Console/SyncUsersAchievements.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,20 @@ class SyncUsersAchievements extends Command

/**
* Execute the console command.
*
* @return int
*/
public function handle()
public function handle(): void
{
User::role("leading teacher")
->chunk(100, function($users, $index){
$this->reportProgress($index);
$users->each(function($user){
$user->achievements()->sync(
app('achievements')->filter->qualifier($user)->map->modelKey()
);
User::role('leading teacher')
->chunk(100, function ($users, $index) {
$this->reportProgress($index);
$users->each(function ($user) {
$user->achievements()->sync(
app('achievements')->filter->qualifier($user)->map->modelKey()
);
});
});
});
}

/**
* @param $index
*/
protected function reportProgress($index): void
{
$from = ($index - 1) * 100;
Expand Down
6 changes: 3 additions & 3 deletions app/Achievements/Events/UserEarnedExperience.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class UserEarnedExperience
{
use Dispatchable, SerializesModels;


public $user;

public $points;

public $totalPoints;

/**
* Create a new event instance.
*
Expand All @@ -24,6 +26,4 @@ public function __construct($user, $points, $totalPoints)
$this->points = $points;
$this->totalPoints = $totalPoints;
}


}
Loading

0 comments on commit 994b6d1

Please sign in to comment.