Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
43c3ee1
Add support for arrays in actions
tobytwigger Nov 11, 2021
d64ee76
Updates
tobytwigger Nov 30, 2021
bef1613
Make action values nullable and text not string
tobytwigger Dec 6, 2021
fadc8b7
Fix failing test
tobytwigger Dec 6, 2021
8be849e
Fix issue with logic decorator unique key failure
tobytwigger Feb 22, 2022
7b2d99e
Add transaction to logic decorator
tobytwigger Feb 23, 2022
a1ab527
Fix action builder errors where data is null
tobytwigger Feb 28, 2022
bc4d5ca
phpcs fixer
tobytwigger Feb 28, 2022
bd20402
Log URL
tobytwigger Mar 21, 2022
5a96e61
Remove logging
tobytwigger Mar 21, 2022
780440f
Cache evaluation
tobytwigger Mar 21, 2022
4dbbe5a
Hopefully get rid of any overlapping jobd
tobytwigger Mar 23, 2022
a88500a
redispatch job rather than sleeping
tobytwigger Mar 24, 2022
f92d238
Add logging
tobytwigger Mar 24, 2022
3797a3c
Add idnexes to logic
tobytwigger Mar 24, 2022
4bf6a7d
Remove logic index£
tobytwigger Mar 24, 2022
a588b5a
Re-add logic index
tobytwigger Mar 24, 2022
0858a09
Change logic results table to backup
tobytwigger Mar 24, 2022
fffdc05
Logic backip again
tobytwigger Mar 24, 2022
a513aa2
Add new index name
tobytwigger Mar 24, 2022
7d0b2eb
Remove backup stuff
tobytwigger Mar 24, 2022
7768621
Remove backup stuff
tobytwigger Mar 24, 2022
19d0fd6
Fix issue with params not being initialised
tobytwigger Mar 25, 2022
e66c615
Update queue names
tobytwigger Mar 25, 2022
6ca27fa
Comment out index adding
tobytwigger Mar 25, 2022
704d852
Remove log statements
tobytwigger Mar 25, 2022
59a939f
Add logs
tobytwigger Mar 25, 2022
0a5486d
Add logs
tobytwigger Mar 25, 2022
c718bc0
PRemove logsg
tobytwigger Mar 25, 2022
24415c4
Update logic cache
tobytwigger Mar 28, 2022
7e18750
Remove redispatching of job!
tobytwigger Mar 28, 2022
24cfd8e
Add indexes and without overlapping for export jobs
tobytwigger Mar 29, 2022
dff1797
Change queue that exports work on
tobytwigger Mar 29, 2022
e537c07
Add analytics back in
tobytwigger Apr 7, 2022
9bf3697
Add indexes for user, group and role iD
tobytwigger May 23, 2022
e2d73b5
Rename migration
tobytwigger May 23, 2022
abdaa86
Add interacts with queue trait
tobytwigger May 24, 2022
a5f20dd
Log any exceptions thrown by progress job
tobytwigger May 31, 2022
93c0b32
Use timeout value based on time
tobytwigger May 31, 2022
75c12b3
Add logging to progress jobs
tobytwigger May 31, 2022
e673157
Remove the retry until statement
tobytwigger May 31, 2022
dc300b0
Limit progress to only a single group
tobytwigger May 31, 2022
ee8a98a
Disable middleware for jobs
tobytwigger May 31, 2022
fa8bc01
Logging for without overlapping, including adding a release at
tobytwigger May 31, 2022
de0ab4f
Checking if the cache exists
tobytwigger May 31, 2022
26e043b
Force release the lock before running
tobytwigger May 31, 2022
22a3e11
More logging around getting the cache lock
tobytwigger May 31, 2022
0576af3
Final test for getting the cache lock using
tobytwigger May 31, 2022
1df8416
Remove other debug statements, just acquire the lock
tobytwigger May 31, 2022
20a8132
Use a full callback not a shorthand one
tobytwigger May 31, 2022
83601a8
Add a new command for checking the progress of a single group
tobytwigger May 31, 2022
a883e7c
Remove without overlapping
tobytwigger May 31, 2022
dc56506
Remove limit of only one group for exporting to airtable
tobytwigger May 31, 2022
d379162
change logging
tobytwigger May 31, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Add support for arrays in actions

## [5.2.0] - (30/11/2021)

### Changed
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,10 @@
"fix-code-style": "vendor/bin/php-cs-fixer fix --config .php_cs --verbose --using-cache=no",
"phpstan": "vendor/bristol-su/portal-code-style/src/PHPStan/phpstan.sh",
"coverage": "vendor/bin/phpunit --colors=always --process-isolation --verbose --configuration phpunit.xml --coverage-html coverage"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true
}
}
}
1,955 changes: 943 additions & 1,012 deletions composer.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

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

class AlterTableActionInstanceFieldsMakeActionValueNullable extends Migration
{
/**
* Run the migrations.
*
*/
public function up()
{
Schema::table('action_instance_fields', function(Blueprint $table) {
$table->text('action_value')->nullable()->change();
});
}

/**
* Reverse the migrations.
*
*/
public function down()
{
Schema::table('action_instance_fields', function(Blueprint $table) {
$table->string('action_value')->change();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

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

class AddIndexesToLogicResultsTable extends Migration
{
/**
* Run the migrations.
*
*/
public function up()
{
Schema::table('logic_results', function (Blueprint $table) {
// $table->index(['logic_id']);
// $table->index(['user_id']);
// $table->index(['group_id']);
// $table->index(['role_id']);
// $table->index(['result']);
// $table->index(['logic_id', 'user_id']);
// $table->index(['logic_id', 'user_id', 'group_id']);
// $table->index(['logic_id', 'result']);
// $table->index(['logic_id', 'user_id', 'result']);
// $table->index(['logic_id', 'user_id', 'group_id', 'result']);
// $table->index(['logic_id', 'user_id', 'group_id', 'role_id', 'result'], 'logic_results_lugr_results_index');
});

}

/**
* Reverse the migrations.
*
*/
public function down()
{
Schema::table('logic_results', function(Blueprint $table) {
// $table->dropIndex(['logic_id']);
// $table->dropIndex(['user_id']);
// $table->dropIndex(['group_id']);
// $table->dropIndex(['role_id']);
// $table->dropIndex(['result']);
//
// $table->dropIndex(['logic_id', 'user_id']);
// $table->dropIndex(['logic_id', 'user_id', 'group_id']);
// $table->dropIndex(['logic_id', 'result']);
//
// $table->dropIndex(['logic_id', 'user_id', 'result']);
// $table->dropIndex(['logic_id', 'user_id', 'group_id', 'result']);
// $table->dropIndex(['logic_id', 'user_id', 'group_id', 'role_id', 'result']);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

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

class AddIndexesToLogicResultsAgainTable extends Migration
{
/**
* Run the migrations.
*
*/
public function up()
{
Schema::table('logic_results', function (Blueprint $table) {
$table->index(['logic_id', 'result'], 'log_res_logic_res_index');
$table->index(['logic_id', 'user_id', 'result'], 'log_res_logic_res_user_index');
$table->index(['logic_id', 'user_id', 'group_id', 'result'], 'log_res_logic_res_user_grp_index');
$table->index(['logic_id', 'user_id', 'group_id', 'role_id', 'result'], 'logic_results_lugr_results_index');
});

}

/**
* Reverse the migrations.
*
*/
public function down()
{
Schema::table('logic_results', function(Blueprint $table) {
$table->dropIndex('log_res_logic_res_index');
$table->dropIndex('log_res_logic_res_user_index');
$table->dropIndex('log_res_logic_res_user_grp_index');
$table->dropIndex('logic_results_lugr_results_index');
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

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

class AddSingleIndexesToLogicResultsTable extends Migration
{
/**
* Run the migrations.
*
*/
public function up()
{
Schema::table('logic_results', function (Blueprint $table) {
$table->index(['user_id'], 'log_res_user_index');
$table->index(['group_id'], 'log_res_grp_index');
$table->index(['role_id'], 'log_res_role_index');
});

}

/**
* Reverse the migrations.
*
*/
public function down()
{
Schema::table('logic_results', function(Blueprint $table) {
$table->dropIndex('log_res_user_index');
$table->dropIndex('log_res_grp_index');
$table->dropIndex('log_res_role_index');
});
}
}
1 change: 1 addition & 0 deletions resources/views/base.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@componentFirst(['partials.components.head', 'bristolsu::partials.components.head'])
@stack('meta-tags')
@includeFirst(['partials.javascript', 'bristolsu::partials.javascript'])
@includeFirst(['partials.analytics', 'bristolsu::partials.analytics'])
<title>@yield('title-prefix', '')@yield('title', 'Portal')</title>
@stack('fonts')
@stack('styles')
Expand Down
11 changes: 10 additions & 1 deletion src/Action/ActionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,20 @@ private function mapFields($fields, array $data)
foreach ($fields as $field) {
$actionValue = $field->action_value;
foreach ($data as $key => $value) {
$actionValue = str_replace(sprintf('{{event:%s}}', $key), $value, $actionValue);
$actionValue = $this->replaceField($actionValue, $key, $value);
}
$actionFields[$field->action_field] = $actionValue;
}

return $actionFields;
}

private function replaceField(string|array $data, string $key, ?string $value)
{
if (is_string($data)) {
return str_replace(sprintf('{{event:%s}}', $key), $value ?? '', $data);
}

return array_map(fn ($dataElement) => $this->replaceField($dataElement, $key, $value), $data);
}
}
2 changes: 1 addition & 1 deletion src/Action/ActionInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use BristolSU\ControlDB\Contracts\Repositories\User;
use BristolSU\Support\Action\History\ActionHistory;
use BristolSU\Support\Authentication\Contracts\Authentication;
use BristolSU\Support\Eloquent\CascadeRestoreDeletes;
use BristolSU\Support\ModuleInstance\ModuleInstance;
use BristolSU\Support\Revision\HasRevisions;
use BristolSU\Support\Eloquent\CascadeRestoreDeletes;
use Database\Factories\ActionInstanceFactory;
use Dyrynda\Database\Support\CascadeSoftDeletes;
use FormSchema\Transformers\Transformer;
Expand Down
18 changes: 18 additions & 0 deletions src/Action/ActionInstanceField.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ class ActionInstanceField extends Model
'action_value', 'action_field', 'action_instance_id'
];

public function getActionValueAttribute($value)
{
$json = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE) {
return $json;
}

return $value;
}

public function setActionValueAttribute($value)
{
if (is_array($value)) {
$value = json_encode($value);
}
$this->attributes['action_value'] = $value;
}

/**
* The action instance relationship.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Activity/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use BristolSU\ControlDB\Contracts\Repositories\User;
use BristolSU\Support\ActivityInstance\ActivityInstance;
use BristolSU\Support\Authentication\Contracts\Authentication;
use BristolSU\Support\Eloquent\CascadeRestoreDeletes;
use BristolSU\Support\Logic\Logic;
use BristolSU\Support\ModuleInstance\ModuleInstance;
use BristolSU\Support\ModuleInstance\ModuleInstanceGrouping;
use BristolSU\Support\Revision\HasRevisions;
use BristolSU\Support\Eloquent\CascadeRestoreDeletes;
use Carbon\Carbon;
use Database\Factories\ActivityFactory;
use Dyrynda\Database\Support\CascadeSoftDeletes;
Expand Down
6 changes: 3 additions & 3 deletions src/ActivityInstance/ActivityInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use BristolSU\ControlDB\Contracts\Repositories\Group as GroupRepository;
use BristolSU\ControlDB\Contracts\Repositories\Role as RoleRepository;
use BristolSU\ControlDB\Contracts\Repositories\User as UserRepository;
use BristolSU\ControlDB\Models\Dummy\GroupDummy;
use BristolSU\ControlDB\Models\Dummy\RoleDummy;
use BristolSU\ControlDB\Models\Dummy\UserDummy;
use BristolSU\ControlDB\Models\Group;
use BristolSU\ControlDB\Models\Role;
use BristolSU\ControlDB\Models\User;
Expand All @@ -17,9 +20,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use BristolSU\ControlDB\Models\Dummy\UserDummy;
use BristolSU\ControlDB\Models\Dummy\GroupDummy;
use BristolSU\ControlDB\Models\Dummy\RoleDummy;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Connection/Client/CachedClientDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function request($method, $uri, array $options = [])
$this->cache->remember(
$this->getKey($method, $uri, $options),
7200,
fn() => $this->toCacheArray(
fn () => $this->toCacheArray(
$this->forwardCall($method, $uri, $options)
)
)
Expand Down
10 changes: 5 additions & 5 deletions src/Eloquent/CascadeRestoreDeletes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use BristolSU\Support\Eloquent\Exceptions\CascadeRestoreDeletesException;
use Illuminate\Database\Eloquent\Relations\Relation;

trait CascadeRestoreDeletes {

trait CascadeRestoreDeletes
{
protected static function bootCascadeRestoreDeletes()
{
static::restoring(function($model) {
static::restoring(function ($model) {
$model->validateRestoringRelationships();

$model->runCascadingRestores();
Expand All @@ -22,7 +22,7 @@ protected function validateRestoringRelationships()
throw CascadeRestoreDeletesException::softDeleteNotImplemented(get_called_class());
}

if($invalidCascadingRelationships = $this->hasInvalidCascadingRestoreRelationships()) {
if ($invalidCascadingRelationships = $this->hasInvalidCascadingRestoreRelationships()) {
throw CascadeRestoreDeletesException::invalidRelationships($invalidCascadingRelationships);
}
}
Expand Down Expand Up @@ -55,7 +55,7 @@ protected function runCascadingRestores()

protected function cascadeRestore($relationship)
{
foreach($this->{$relationship}()->withTrashed()->where('deleted_at', '>=', $this->deleted_at)->get() as $model) {
foreach ($this->{$relationship}()->withTrashed()->where('deleted_at', '>=', $this->deleted_at)->get() as $model) {
$model->restore();
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Eloquent/Exceptions/CascadeRestoreDeletesException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static function softDeleteNotImplemented($class)
return new static(sprintf('%s does not implement Illuminate\Database\Eloquent\SoftDeletes', $class));
}


public static function invalidRelationships($relationships)
{
return new static(sprintf(
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/Events/AudienceChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace BristolSU\Support\Filters\Events;

use BristolSU\ControlDB\Contracts\Models\Group;
use BristolSU\ControlDB\Contracts\Models\Role;
use BristolSU\ControlDB\Contracts\Models\User;
use BristolSU\ControlDB\Contracts\Models\Group;
use BristolSU\Support\Filters\FilterInstance;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
Expand All @@ -17,6 +17,7 @@ class AudienceChanged
* @var array|FilterInstance[]
*/
public array $filterInstances;

public User|Group|Role|null $model;

/**
Expand All @@ -30,5 +31,4 @@ public function __construct(array $filterInstances, User|Group|Role|null $model
$this->filterInstances = $filterInstances;
$this->model = $model;
}

}
5 changes: 2 additions & 3 deletions src/Filters/FilterInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use function Illuminate\Events\queueable;

/**
* Represents a filter instance.
Expand Down Expand Up @@ -58,12 +57,12 @@ protected static function booted()
AudienceChanged::dispatch([$filterInstance]);
});
static::created(function (FilterInstance $filterInstance) {
if($filterInstance->logic_id) {
if ($filterInstance->logic_id) {
AudienceChanged::dispatch([$filterInstance]);
}
});
static::updated(function (FilterInstance $filterInstance) {
if($filterInstance->isDirty(['settings', 'logic_id', 'logic_type'])) {
if ($filterInstance->isDirty(['settings', 'logic_id', 'logic_type'])) {
AudienceChanged::dispatch([$filterInstance]);
}
});
Expand Down
2 changes: 0 additions & 2 deletions src/Filters/FilterManagerEventRegistrationDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
*/
class FilterManagerEventRegistrationDecorator implements FilterManagerContract
{

private FilterManagerContract $baseFilterManager;

public function __construct(FilterManagerContract $baseFilterManager)
{
$this->baseFilterManager = $baseFilterManager;
}


/**
* Register a new filter.
*
Expand Down
Loading