Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
90c11ab
updated sync command
bryce13950 Apr 7, 2025
b8f8c1b
updated message mailer
bryce13950 Apr 7, 2025
3605aec
updated service test
bryce13950 Apr 7, 2025
2bb1154
added new tests
bryce13950 Apr 7, 2025
075b14f
added initial statistic module
bryce13950 Apr 30, 2025
ec41531
added initial statistic tests
bryce13950 Apr 30, 2025
b1ac5eb
added more field
bryce13950 Apr 30, 2025
29ceee5
reworked user statistic to target statistic
bryce13950 Apr 30, 2025
4430960
added statistic contract
bryce13950 Apr 30, 2025
54181e1
made collection capable of being connected to statistics
bryce13950 Apr 30, 2025
d9431a1
added service for getting related models to a statistic
bryce13950 May 1, 2025
4a3f4fa
added service for synchronizing stats
bryce13950 May 1, 2025
5a03ef2
setup counting service for stats
bryce13950 May 1, 2025
b86217d
generalized relationship walking
bryce13950 May 1, 2025
52ebd77
created new observer for aggregated data
bryce13950 May 1, 2025
08ec61e
added tests
bryce13950 May 1, 2025
dae5078
set correct contracts
bryce13950 May 1, 2025
87250bf
registered new bits
bryce13950 May 1, 2025
df9603b
remvoed audio clip mention
bryce13950 May 1, 2025
e9cbaeb
made some fixes
bryce13950 May 2, 2025
6838336
added doc comment
bryce13950 May 2, 2025
2b6bf88
fixed some issues with the statistics controller
bryce13950 May 2, 2025
634ce0a
created needed roles
bryce13950 May 2, 2025
657f2dc
updated validation rules
bryce13950 May 2, 2025
a742e30
updated role setting
bryce13950 May 2, 2025
f049f11
fixed import
bryce13950 May 2, 2025
96a05a1
resolved some import issues
bryce13950 May 2, 2025
d712c86
moved statistic policy
bryce13950 May 2, 2025
b3add44
fixed import
bryce13950 May 2, 2025
9c3f5fc
fixed comment
bryce13950 May 2, 2025
4ec4417
set properly formated controller
bryce13950 May 2, 2025
a22e289
corrected import
bryce13950 May 2, 2025
0448dd0
added field again
bryce13950 May 2, 2025
13cb3a6
removed extra constructor
bryce13950 May 2, 2025
52633eb
fixed route
bryce13950 May 2, 2025
319435e
fixed route
bryce13950 May 2, 2025
4693324
fixed path
bryce13950 May 2, 2025
ee4b752
fixed repo
bryce13950 May 2, 2025
796fd4a
fixed import
bryce13950 May 2, 2025
5f519e0
registered route
bryce13950 May 2, 2025
a825650
updated controller structure
bryce13950 May 3, 2025
6b38d8a
set correct structure
bryce13950 May 3, 2025
3fd60a5
fixed some tests
bryce13950 May 3, 2025
067aa75
fixed some statistic request items
bryce13950 May 3, 2025
758fe52
fixed import
bryce13950 May 3, 2025
09af736
imported events
bryce13950 May 3, 2025
66b7fd7
fixed import
bryce13950 May 3, 2025
bc2170f
improved observer
bryce13950 May 3, 2025
fa67f4b
registered services
bryce13950 May 3, 2025
e386827
fixed some data items
bryce13950 May 3, 2025
aeeff2a
fixed some tests
bryce13950 May 3, 2025
8ef2d5c
passed some tests
bryce13950 May 4, 2025
d08ad8a
added more tests
bryce13950 May 4, 2025
489d320
added recount job for when statistics change
bryce13950 May 4, 2025
577da49
updated the way update works
bryce13950 May 4, 2025
6826e10
fixed use
bryce13950 May 4, 2025
0d64906
fixed namespace
bryce13950 May 4, 2025
9242839
removed log
bryce13950 May 4, 2025
1be54dc
fixed more issues
bryce13950 May 4, 2025
2067221
removed log points
bryce13950 May 4, 2025
dda21ad
fixed some test errors
bryce13950 May 4, 2025
890e454
removed extra rule
bryce13950 May 4, 2025
bf3e44c
imported statistic filter epository
bryce13950 May 4, 2025
894cc30
fixed not present test
bryce13950 May 4, 2025
d0d1b3e
added proper events
bryce13950 May 4, 2025
ac652bf
fixed some things with a repo
bryce13950 May 4, 2025
6b15ddf
fixed some test items
bryce13950 May 4, 2025
80d931d
registered repo properly
bryce13950 May 4, 2025
98ac1ac
removed extra variable
bryce13950 May 4, 2025
b68d437
fixed injections
bryce13950 May 4, 2025
b4f5a82
used trait
bryce13950 May 4, 2025
cd38204
fixed import
bryce13950 May 4, 2025
b5d174d
fixed some more issues
bryce13950 May 4, 2025
1247633
fixed some more tests
bryce13950 May 4, 2025
72403d4
fixed test
bryce13950 May 4, 2025
23677c0
fixed some tests
bryce13950 May 4, 2025
235db16
fixed repo
bryce13950 May 4, 2025
e249ec4
updated test
bryce13950 May 4, 2025
e5df12a
updated test
bryce13950 May 4, 2025
d00d462
fixed test
bryce13950 May 4, 2025
c1b41cb
fixd some tests
bryce13950 May 4, 2025
c6455db
fixed last tests
bryce13950 May 4, 2025
bbf861c
updated function to return array of paths instead of single path
bryce13950 May 4, 2025
7fe08f2
fixed some imports
bryce13950 May 4, 2025
998ba4c
added proper aggreated model observer
bryce13950 May 4, 2025
f7c19a3
updated tst
bryce13950 May 4, 2025
bcfb935
updated model name
bryce13950 May 4, 2025
b698bdc
removed extra service
bryce13950 May 4, 2025
819f8e3
removed some extra calls
bryce13950 May 5, 2025
6337a66
updated statistic events to use getters
bryce13950 May 5, 2025
244de8e
removed mock from test
bryce13950 May 5, 2025
459ae17
removed fqdn
bryce13950 May 5, 2025
b678243
removed getter
bryce13950 May 5, 2025
387ee1a
removed mocks
bryce13950 May 5, 2025
62e7c9c
registered service
bryce13950 May 5, 2025
7915e41
updated registration
bryce13950 May 5, 2025
3d51d4c
changed return type
bryce13950 May 5, 2025
2869bb1
filled in delete listener
bryce13950 May 5, 2025
d4ffac2
registered delete event
bryce13950 May 5, 2025
88de256
added modern creator
bryce13950 May 5, 2025
d624612
made trait more specific
bryce13950 May 6, 2025
5b6e6a3
removed optional user
bryce13950 May 7, 2025
b2a6df8
alphabetized providers
bryce13950 May 7, 2025
6cf1127
fixed test names
bryce13950 May 7, 2025
bf23717
used parent function for related data
bryce13950 May 7, 2025
de79f52
revisted target statistic test
bryce13950 May 8, 2025
efd9939
removed mocked model
bryce13950 May 8, 2025
f10e9ed
fixed stripe services
bryce13950 May 8, 2025
8b351de
fixed dependencies
bryce13950 May 8, 2025
7b474d9
fixed params
bryce13950 May 8, 2025
38ecacb
resolved some more tests
bryce13950 May 8, 2025
735ef30
removed event dispatcher from target statistics
bryce13950 May 8, 2025
f36c738
fixed repo injection
bryce13950 May 8, 2025
2613cfd
Updated injection
bryce13950 May 8, 2025
92a3eb4
registered remaining items
bryce13950 May 8, 2025
c10959e
fixed import
bryce13950 May 9, 2025
85d42c9
fixed provider
bryce13950 May 9, 2025
a2c5fae
removed extra field from target statistic
bryce13950 May 9, 2025
8485dc5
added test for deep nesting
bryce13950 May 9, 2025
37e883e
checked for existing statistics when syncing
bryce13950 May 9, 2025
a082f60
updated constructor
bryce13950 May 9, 2025
830a5ec
added more robust test
bryce13950 May 9, 2025
92a5327
removed extra tests
bryce13950 May 9, 2025
4d24e4e
removed extra function
bryce13950 May 10, 2025
628106c
improved collection model
bryce13950 May 10, 2025
df5f4e7
removed extra test
bryce13950 May 10, 2025
56ddc1e
added model tests
bryce13950 May 10, 2025
5819643
removed extra stuff
bryce13950 May 10, 2025
44144ef
removed extra constants and added casts back
bryce13950 May 10, 2025
17d5dd4
moved event registration to the right place
bryce13950 May 10, 2025
f0c2a04
reverted test
bryce13950 May 10, 2025
ddf7a3a
fixed import
bryce13950 May 10, 2025
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
2 changes: 1 addition & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The fastest way to upgrade is to run the following commands from your repos root
* cp $ATHENIA_REPO/.env.example ./
* rsync -arv $ATHENIA_REPO/dockerfiles ./
* rsync -arv $ATHENIA_REPO/extras ./
* rsync -arv $ATHENIA_REPO/code ./ --exclude vendor --exclude storage --exclude '.env'
* rsync -arv $ATHENIA_REPO/code ./ --exclude vendor --exclude storage --exclude '.env' --exclude code/app/Providers

After that, you always want to make sure you inspect all changes, and you still want to go through the change log to check for moved files and deleted files, as rsync cannot check for deleted files, since it would delete any files created for the child application.

Expand Down
20 changes: 20 additions & 0 deletions code/app/Athenia/Contracts/Models/CanBeAggregatedContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Contracts\Models;

/**
* Interface CanBeAggregatedContract
* @package App\Athenia\Contracts\Models
*/
interface CanBeAggregatedContract
{
/**
* Returns the relation paths to the models that can be target statistics
* For example: ["collectionItem.collection"] would mean this model affects statistics on collections
* through the collectionItem relation
*
* @return string[]
*/
public function getStatisticTargetRelationPath(): array;
}
21 changes: 21 additions & 0 deletions code/app/Athenia/Contracts/Models/CanBeStatisticTargetContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Contracts\Models;

use App\Models\Statistics\TargetStatistic;
use Illuminate\Database\Eloquent\Relations\MorphMany;

/**
* Interface CanBeStatisticTargetContract
* @package App\Athenia\Contracts\Models
*/
interface CanBeStatisticTargetContract extends CanBeMorphedToContract
{
/**
* Gets all statistics that belong to this model through a morph many relationship
*
* @return MorphMany
*/
public function targetStatistics(): MorphMany;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace App\Athenia\Contracts\Repositories\Statistics;

use App\Athenia\Contracts\Repositories\BaseRepositoryContract;

interface StatisticFilterRepositoryContract extends BaseRepositoryContract
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Contracts\Repositories\Statistics;

use App\Athenia\Contracts\Repositories\BaseRepositoryContract;

/**
* Interface StatisticRepositoryContract
*/
interface StatisticRepositoryContract extends BaseRepositoryContract
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Contracts\Repositories\Statistics;

use App\Athenia\Contracts\Repositories\BaseRepositoryContract;
use App\Models\Statistics\TargetStatistic;
use Illuminate\Database\Eloquent\Model;
use App\Athenia\Contracts\Models\CanBeStatisticTargetContract;
use Illuminate\Database\Eloquent\Collection;

/**
* Interface TargetStatisticRepositoryContract
* @package App\Athenia\Contracts\Repositories\Statistics
*/
interface TargetStatisticRepositoryContract extends BaseRepositoryContract
{
/**
* Creates a new target statistic model
*
* @param CanBeStatisticTargetContract $target
* @param array $data
* @return TargetStatistic
*/
public function createForTarget(CanBeStatisticTargetContract $target, array $data): TargetStatistic;

/**
* Find all statistics for a specific target
*
* @param CanBeStatisticTargetContract $target
* @return Collection
*/
public function findAllForTarget(CanBeStatisticTargetContract $target): Collection;

/**
* Find a specific statistic for a target
*
* @param CanBeStatisticTargetContract $target
* @param int $statisticId
* @return TargetStatistic|null
*/
public function findForTarget(CanBeStatisticTargetContract $target, int $statisticId): ?TargetStatistic;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Contracts\Services\Relations;

use App\Athenia\Models\BaseModelAbstract;
use Illuminate\Database\Eloquent\Collection;

/**
* Interface RelationTraversalServiceContract
* @package App\Athenia\Contracts\Services\Relations
*/
interface RelationTraversalServiceContract
{
/**
* Traverses the relations on a model and returns all related models
*
* @param BaseModelAbstract $model
* @param string $relationPath
* @return Collection
*/
public function traverseRelations(BaseModelAbstract $model, string $relationPath): Collection;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Contracts\Services\Statistics;

use App\Athenia\Contracts\Models\CanBeStatisticTargetContract;
use App\Models\Statistics\TargetStatistic;
use Illuminate\Database\Eloquent\Collection;
use App\Models\Statistics\Statistic;

/**
* Interface StatisticSynchronizationServiceContract
* @package App\Athenia\Contracts\Services\Statistics
*/
interface StatisticSynchronizationServiceContract
{
/**
* Takes in a model that can be a statistic target, and ensures that all necessary target
* statistics exist for that model based on the available statistics for its type
*
* @param CanBeStatisticTargetContract $model
* @return Collection|TargetStatistic[]
*/
public function synchronizeTargetStatistics(CanBeStatisticTargetContract $model): Collection;

/**
* Create target statistics for a newly created statistic.
*
* @param Statistic $statistic
* @return Collection|TargetStatistic[]
*/
public function createTargetStatisticsForStatistic(Statistic $statistic): Collection;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Contracts\Services\Statistics;

use App\Models\Statistics\TargetStatistic;

/**
* Interface TargetStatisticProcessingServiceContract
* @package App\Athenia\Contracts\Services\Statistics
*/
interface TargetStatisticProcessingServiceContract
{
/**
* Processes a single target statistic and updates its result
*
* @param TargetStatistic $targetStatistic
* @return void
*/
public function processSingleTargetStatistic(TargetStatistic $targetStatistic): void;
}
19 changes: 19 additions & 0 deletions code/app/Athenia/Events/Statistics/StatisticCreatedEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Athenia\Events\Statistics;

use App\Models\Statistics\Statistic;

class StatisticCreatedEvent
{
public function __construct(
private readonly Statistic $statistic
) {}

public function getStatistic(): Statistic
{
return $this->statistic;
}
}
19 changes: 19 additions & 0 deletions code/app/Athenia/Events/Statistics/StatisticDeletedEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Athenia\Events\Statistics;

use App\Models\Statistics\Statistic;

class StatisticDeletedEvent
{
public function __construct(
private readonly Statistic $statistic
) {}

public function getStatistic(): Statistic
{
return $this->statistic;
}
}
19 changes: 19 additions & 0 deletions code/app/Athenia/Events/Statistics/StatisticUpdatedEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Athenia\Events\Statistics;

use App\Models\Statistics\Statistic;

class StatisticUpdatedEvent
{
public function __construct(
private readonly Statistic $statistic
) {}

public function getStatistic(): Statistic
{
return $this->statistic;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
* description="Any routes related to foreground asset models."
* )
* @SWG\Tag(
* name="AudioClips",
* description="Any routes related to audio clip asset models."
* )
* @SWG\Tag(
* name="Users",
* description="Any information that is related to the user object of the app"
* )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);

namespace App\Athenia\Http\Core\Controllers;

use App\Athenia\Contracts\Repositories\Statistics\StatisticRepositoryContract;
use App\Athenia\Http\Core\Controllers\Traits\HasIndexRequests;
use App\Http\Core\Requests;
use App\Models\Statistics\Statistic;
use Illuminate\Http\JsonResponse;

/**
* Class StatisticControllerAbstract
* @package App\Athenia\Http\Core\Controllers
*/
abstract class StatisticControllerAbstract extends BaseControllerAbstract
{
use HasIndexRequests;

/**
* @var StatisticRepositoryContract
*/
protected $repository;

/**
* StatisticControllerAbstract constructor.
* @param StatisticRepositoryContract $repository
*/
public function __construct(StatisticRepositoryContract $repository)
{
$this->repository = $repository;
}

/**
* Display a listing of the resource
*
* @param Requests\Statistics\IndexRequest $request
* @return JsonResponse
*/
public function index(Requests\Statistics\IndexRequest $request)
{
return $this->repository->findAll($this->filter($request), $this->search($request), $this->order($request), $this->expand($request), $this->limit($request), [], (int)$request->input('page', 1));
}

/**
* Creates a Statistic model
*
* @param Requests\Statistics\StoreRequest $request
* @return JsonResponse
*/
public function store(Requests\Statistics\StoreRequest $request)
{
$model = $this->repository->create($request->json()->all());
return response($model, 201);
}

/**
* View a single Statistic model
*
* @param Requests\Statistics\ViewRequest $request
* @param Statistic $statistic
* @return JsonResponse
*/
public function show(Requests\Statistics\ViewRequest $request, Statistic $statistic)
{
return $statistic->load($this->expand($request));
}

/**
* Updates a Statistic model
*
* @param Requests\Statistics\UpdateRequest $request
* @param Statistic $statistic
* @return JsonResponse
*/
public function update(Requests\Statistics\UpdateRequest $request, Statistic $statistic)
{
return $this->repository->update($statistic, $request->json()->all());
}

/**
* Deletes a Statistic model
*
* @param Requests\Statistics\DeleteRequest $request
* @param Statistic $statistic
* @return JsonResponse
*/
public function destroy(Requests\Statistics\DeleteRequest $request, Statistic $statistic)
{
$this->repository->delete($statistic);
return response(null, 204);
}
}
Loading