Skip to content

Commit

Permalink
Merge pull request #222 from deanblackborough/hiatus
Browse files Browse the repository at this point in the history
post-hiatus
  • Loading branch information
deanblackborough authored Jan 26, 2022
2 parents ddcaf79 + f4f09d3 commit e6d032c
Show file tree
Hide file tree
Showing 278 changed files with 5,648 additions and 3,695 deletions.
2 changes: 1 addition & 1 deletion .docker/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mysql:8
FROM mysql:8.0
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vendor
vendor/
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@

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.22.0] - 2022-01-26
After being away from the code for a while I've made some changes. I've reduced the complexity around different items types because things had started to get a little complex and I know what is coming next so want to clear out as much unnecessary code as possible. This is just a first pass, I'm sure there will be more but I have many other planned tickets to get on with.

### Added
- We have added additional tests for the `ResourceManage` controller.
- We have added tests for the `ResourceTypeView` controller.
- We have added a logout route.
- We have added an OPTIONS request for `/auth/create-new-password`.
- We have added an OPTIONS request for `/auth/create-password`.
- We have added an OPTIONS request for `/auth/forgot-password`.
- We have added an OPTIONS request for `/auth/login`.
- We have added an OPTIONS request for `/auth/register`.
- We have added an OPTIONS request for `/auth/update-password`.
- We have added an OPTIONS request for `/auth/update-profile`.
- We have added an OPTIONS request for `/auth/user`.
- We have added an OPTIONS request for `/auth/check`.

### Changed
- We have made a couple of minor changes to the Docker setup.
- We have updated the README because of minor Docker changes and corrected the table layouts in the README file.
- We have updated all front-end and back-end dependencies.
- We have updated the copyright, we are now in 2022.
- We have added additional feature tests and removed some duplication in the tests, the README details the current test status.
- General refactoring, switched to method injection and logging exception messages.
- We are switching to named routes and have updated some route files, more will be updated as additional tests are created.
- We have done a quick review of each of the model classes and fixed a few tiny issues.
- We have reviewed all the `ItemType` classes, improved organisation with additional namespaces, renamed classes and methods, all with the goal being to try and make everything clearer.
- We have reviewed all item based controllers and switched to methods per item type rather than hiding all the logic in larger item classes. There is slightly more duplication but this will allow us to more easily customise each item type as new ones are added, I'm looking at you forecasting.
- We have updated the item/categories routes and will return a 405 when a category is not supported for the item type.
- We have updated the item/subcategories routes and will return a 405 when a subcategory is not supported for the item type.
- The Authentication controller no longer extends from the base app controller, it was doing some unnecessary work.

### Fixed
- We have fixed the `delete_resource_type_success` test, wrong route.
- The `notFoundOrNotAccessible` response will optionally return a 403 if not accessible and not a 404.

### Removed
- We have removed a few files not used by the API.

## [v2.21.0] - 2021-04-29
### Changed
- We have updated our password requirements; the minimum length must now be 12 characters.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2020 Dean Blackborough
Copyright (c) 2018-2022 Dean Blackborough

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
307 changes: 159 additions & 148 deletions README.md

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions app/AllowedValue/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ public function __construct()
$this->hash = new Hash();
}

/**
* Generate the allowed values item type array, will be passed to the
* Option classes and merged with the fields/parameters
*
* @return array
*/
public function allowedValues(): array
{
$parameters = ['currency_id' => ['allowed_values' => []]];
Expand Down
57 changes: 33 additions & 24 deletions app/AllowedValue/ResourceItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,37 +193,46 @@ function($subcategory) use (&$parameters) {
return $parameters;
}

/**
* @return array
*/
protected function allowedValuesForYear(
int $resource_type_id,
int $resource_id
): array
{
$parameters = ['year' => ['allowed_values' => []]];

for (
$i = $this->model->minimumYearByResourceTypeAndResource(
$resource_type_id,
$resource_id,
$this->entity->table(),
$this->entity->dateRangeField()
);
$i <= $this->model->maximumYearByResourceTypeAndResource(
$resource_type_id,
$resource_id,
$this->entity->table(),
$this->entity->dateRangeField()
);
$i++
) {
$parameters['year']['allowed_values'][$i] = [
'value' => $i,
'name' => $i,
'description' => trans('item-type-' . $this->entity->type() .
'/allowed-values.description-prefix-year') . $i
];
$min_year = null;
$max_year = null;

$item_type = \App\ItemType\Entity::itemType($resource_type_id);
switch($item_type) {
case 'allocated-expense':
$min_year = $this->model->minimumYearByResourceTypeAndResource(
$resource_type_id,
$resource_id,
'item_type_allocated_expense',
'effective_date'
);
$max_year = $this->model->maximumYearByResourceTypeAndResource(
$resource_type_id,
$resource_id,
'item_type_allocated_expense',
'effective_date'
);
break;
default:
// Do nothing
break;
}

if ($min_year !== null && $max_year !== null) {
for ($i = $min_year; $i <= $max_year; $i++) {
$parameters['year']['allowed_values'][$i] = [
'value' => $i,
'name' => $i,
'description' => trans('item-type-' . $this->entity->type() .
'/allowed-values.description-prefix-year') . $i
];
}
}

return $parameters;
Expand Down
50 changes: 31 additions & 19 deletions app/AllowedValue/ResourceTypeItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,37 @@ protected function allowedValuesForYear(int $resource_type_id): array
{
$parameters = ['year' => ['allowed_values' => []]];

for (
$i = $this->model->minimumYearByResourceType(
$resource_type_id,
$this->entity->table(),
$this->entity->dateRangeField()
);
$i <= $this->model->maximumYearByResourceType(
$resource_type_id,
$this->entity->table(),
$this->entity->dateRangeField()
);
$i++
) {
$parameters['year']['allowed_values'][$i] = [
'value' => $i,
'name' => $i,
'description' => trans('resource-type-item-type-' . $this->entity->type() .
'/allowed-values.description-prefix-year') . $i
];
$min_year = null;
$max_year = null;

$item_type = \App\ItemType\Entity::itemType($resource_type_id);
switch ($item_type) {
case 'allocated-expense':
$min_year = $this->model->minimumYearByResourceType(
$resource_type_id,
'item_type_allocated_expense',
'effective_date'
);
$max_year = $this->model->maximumYearByResourceType(
$resource_type_id,
'item_type_allocated_expense',
'effective_date'
);
break;
default:
// No nothing
break;
}

if ($min_year !== null && $max_year !== null) {
for ($i = $min_year; $i <= $max_year; $i++) {
$parameters['year']['allowed_values'][$i] = [
'value' => $i,
'name' => $i,
'description' => trans('resource-type-item-type-' . $this->entity->type() .
'/allowed-values.description-prefix-year') . $i
];
}
}

return $parameters;
Expand Down
2 changes: 1 addition & 1 deletion app/Cache/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* object to interact with
*
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough 2018-2021
* @copyright Dean Blackborough 2018-2022
* @license https://github.com/costs-to-expect/api/blob/master/LICENSE
*/
class Collection
Expand Down
2 changes: 1 addition & 1 deletion app/Cache/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Cache helper, wrapper around the Laravel cache facade
*
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough 2018-2021
* @copyright Dean Blackborough 2018-2022
* @license https://github.com/costs-to-expect/api/blob/master/LICENSE
*/
class Control
Expand Down
2 changes: 1 addition & 1 deletion app/Cache/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Decode the payload for a job
*
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough 2018-2021
* @copyright Dean Blackborough 2018-2022
* @license https://github.com/costs-to-expect/api/blob/master/LICENSE
*/
class Job
Expand Down
2 changes: 1 addition & 1 deletion app/Cache/JobPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* necessary
*
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough 2018-2021
* @copyright Dean Blackborough 2018-2022
* @license https://github.com/costs-to-expect/api/blob/master/LICENSE
*/
class JobPayload
Expand Down
2 changes: 1 addition & 1 deletion app/Cache/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* object to interact with
*
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough 2018-2021
* @copyright Dean Blackborough 2018-2022
* @license https://github.com/costs-to-expect/api/blob/master/LICENSE
*/
class Summary
Expand Down
39 changes: 0 additions & 39 deletions app/Entity/Api.php

This file was deleted.

Loading

0 comments on commit e6d032c

Please sign in to comment.