Skip to content

Commit

Permalink
Merge pull request #201 from deanblackborough/v2.13.1
Browse files Browse the repository at this point in the history
v2.13.1
  • Loading branch information
deanblackborough authored Sep 17, 2020
2 parents 931e4d9 + 58db0ba commit b551e88
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 45 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

The complete changelog for the Costs to Expect REST API, our changelog follows the format defined at https://keepachangelog.com/en/1.0.0/

## [v2.13.1] - 2020-09-17
### Changed
- We have changed the cache which gets cleared when we create or delete a resource.
- We have added a delay for the job which clears the cache on creation or deletion of a resource type and resource.

### Fixed
- We have corrected a type error; the permitted user check fails because of a type error.

## [v2.13.0] - 2020-09-15
### Added
- We have added support for queues; we clear all cache via queues.
Expand All @@ -11,7 +19,7 @@ The complete changelog for the Costs to Expect REST API, our changelog follows t
- We have added the Postman collection link to the menu and renamed the documentation button.
- We have updated our README and included details on how to start the queue.

## Fixed
### Fixed
- We have corrected a couple of minor coding issues, unused parameters etc.
- We have updated our changelog, small spelling error.
- We have updated our controllers and added missing return statements.
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/CategoryManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function create($resource_type_id): JsonResponse
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down Expand Up @@ -93,7 +93,7 @@ public function delete(
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

$category = (new Category())->find($category_id);
Expand Down Expand Up @@ -166,7 +166,7 @@ public function update($resource_type_id, $category_id): JsonResponse
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ItemCategoryManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function create(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down Expand Up @@ -127,7 +127,7 @@ public function delete(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/ItemManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function create(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($user_id);

try {
Expand Down Expand Up @@ -125,7 +125,7 @@ public function update(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

$item = (new Item())->instance($resource_type_id, $resource_id, $item_id);
Expand Down Expand Up @@ -183,7 +183,7 @@ public function delete(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

$item_model = $entity->model();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ItemPartialTransferManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function delete(
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down Expand Up @@ -102,7 +102,7 @@ public function transfer(
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ItemSubcategoryManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function create(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down Expand Up @@ -144,7 +144,7 @@ public function delete(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ItemTransferManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function transfer(
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down
12 changes: 6 additions & 6 deletions app/Http/Controllers/ResourceManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function create(string $resource_type_id): JsonResponse
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand All @@ -59,7 +59,7 @@ public function create(string $resource_type_id): JsonResponse
]);
$resource->save();

ClearCache::dispatch($cache_job_payload->payload());
ClearCache::dispatch($cache_job_payload->payload())->delay(now()->addMinute());

} catch (Exception $e) {
return Responses::failedToSaveModelForCreate();
Expand Down Expand Up @@ -103,13 +103,13 @@ public function delete(
'resource_type_id' => $resource_type_id,
'resource_id' => $resource_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
(new Resource())->find($resource_id)->delete();

ClearCache::dispatch($cache_job_payload->payload());
ClearCache::dispatch($cache_job_payload->payload())->delay(now()->addMinute());

return Responses::successNoContent();
} catch (QueryException $e) {
Expand Down Expand Up @@ -169,13 +169,13 @@ public function update(
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
$resource->save();

ClearCache::dispatch($cache_job_payload->payload());
ClearCache::dispatch($cache_job_payload->payload())->delay(now()->addMinute());

} catch (Exception $e) {
return Responses::failedToSaveModelForUpdate();
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/ResourceTypeManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function create(): JsonResponse
]);
$resource_type_item_type->save();

ClearCache::dispatch($cache_job_payload->payload());
ClearCache::dispatch($cache_job_payload->payload())->delay(now()->addMinute());

} catch (Exception $e) {
return \App\Response\Responses::failedToSaveModelForCreate();
Expand Down Expand Up @@ -123,7 +123,7 @@ public function delete(
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

if (
Expand All @@ -140,7 +140,7 @@ public function delete(
$resource_type->delete();
});

ClearCache::dispatch($cache_job_payload->payload());
ClearCache::dispatch($cache_job_payload->payload())->delay(now()->addMinute());

return \App\Response\Responses::successNoContent();
} catch (QueryException $e) {
Expand Down Expand Up @@ -200,13 +200,13 @@ public function update(
->setRouteParameters([
'resource_type_id' => $resource_type_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
$resource_type->save();

ClearCache::dispatch($cache_job_payload->payload());
ClearCache::dispatch($cache_job_payload->payload())->delay(now()->addMinute());

} catch (Exception $e) {
return \App\Response\Responses::failedToSaveModelForUpdate();
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/SubcategoryManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function create($resource_type_id, $category_id): JsonResponse
'resource_type_id' => $resource_type_id,
'category_id' => $category_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down Expand Up @@ -111,7 +111,7 @@ public function delete(
'resource_type_id' => $resource_type_id,
'category_id' => $category_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down Expand Up @@ -181,7 +181,7 @@ public function update(
'resource_type_id' => $resource_type_id,
'category_id' => $category_id
])
->setPermittedUser(in_array($resource_type_id, $this->permitted_resource_types, true))
->setPermittedUser(in_array((int) $resource_type_id, $this->permitted_resource_types, true))
->setUserId($this->user_id);

try {
Expand Down
4 changes: 1 addition & 3 deletions app/Response/Cache/KeyGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ public function keys(string $group_key): array
case self::RESOURCE_CREATE:
case self::RESOURCE_DELETE:
return [
$this->key->resources(
(int) $this->parameters['resource_type_id']
)
$this->key->resourceTypes()
];

case self::SUBCATEGORY_CREATE:
Expand Down
4 changes: 2 additions & 2 deletions config/api/app/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

return [
'version'=> 'v2.13.0',
'version'=> 'v2.13.1',
'prefix' => 'v2',
'release_date' => '2020-09-15',
'release_date' => '2020-09-17',
'changelog' => [
'api' => '/v2/changelog',
'markdown' => 'https://github.com/costs-to-expect/api/blob/master/CHANGELOG.md'
Expand Down
15 changes: 3 additions & 12 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,26 +222,17 @@ function gtag(){dataLayer.push(arguments);}
<p>The changelog below shows all the fixes and improvements we have made, to view
the entire changelog please check <a href="https://github.com/costs-to-expect/api/releases">here</a>.</p>

<h3>Added</h3>

<ul>
<li>We have added support for queues; we clear all cache via queues.</li>
</ul>

<h3>Changed</h3>

<ul>
<li>We have updated all our management controllers, we add a job to the queue rather than clearing the necessary cache synchronously.</li>
<li>We have added the Postman collection link to the menu and renamed the documentation button.</li>
<li>We have updated our README and included details on how to start the queue.</li>
<li>We have changed the cache which gets cleared when we create or delete a resource.</li>
<li>We have added a delay for the job which clears the cache on creation or deletion of a resource type and resource.</li>
</ul>

<h3>Fixed</h3>

<ul>
<li>We have corrected a couple of minor coding issues, unused parameters etc.</li>
<li>We have updated our changelog, small spelling error.</li>
<li>We have updated our controllers and added missing return statements.</li>
<li>We have corrected a type error; the permitted user check fails because of a type error.</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit b551e88

Please sign in to comment.