Skip to content

Commit

Permalink
Merge pull request #115 from itk-dev/feature/booking-288-location
Browse files Browse the repository at this point in the history
BOOKING-288: Fixed issues with creating cache entry. Added resource d…
  • Loading branch information
tuj authored Nov 15, 2023
2 parents ea6f891 + f2fd4f9 commit 710387a
Show file tree
Hide file tree
Showing 18 changed files with 204 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DEFAULT_URI=https://bookaarhus.local.itkdev.dk
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7&charset=utf8mb4"
# DATABASE_URL="postgresql://symfony:[email protected]:5432/app?serverVersion=13&charset=utf8"
DATABASE_URL="mysql://db:db@mariadb:3306/db?serverVersion=mariadb-10.5.13&charset=utf8mb4"
DATABASE_URL="mysql://db:db@mariadb:3306/db?serverVersion=10.9.3-MariaDB&charset=utf8mb4"

BOOKING_RESOURCES_DATABASE_DBNAME="sqlbooking"
BOOKING_RESOURCES_DATABASE_HOST="azure-sql"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ See [keep a changelog](https://keepachangelog.com/en/1.0.0/) for information abo
- Removed Rabbit MQ (remeber to update the DSN in local .env)
- Updated docker compose setup to newest version
- Fixed issue with booking cache entries not being created.
- Added resourceDisplayName to cache.
- Moved AddBookingToCacheMessage handling to own queue.

## [1.1.2] - 2023-08-29

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"./vendor/bin/psalm --no-cache --alter --issues=MissingReturnType,MissingParamType --dry-run"
],
"queues": [
"bin/console messenger:consume async --failure-limit=1 -vvv"
"bin/console messenger:consume async cache --failure-limit=3 -vvv"
],
"tests": [
"bin/console --env=test doctrine:database:drop --if-exists --force --quiet",
Expand Down
3 changes: 2 additions & 1 deletion config/api_platform/user-booking-cache-entry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources:
attributes:
pagination_items_per_page: 10
normalization_context:
groups: ['userBookingCacheEntry']
datetime_format: 'Y-m-d\TH:i:s.v\Z'
itemOperations:
get:
Expand Down Expand Up @@ -51,4 +52,4 @@ resources:
example1:
value:
- { exchangeId: 'value1', status: 'value2' }
headers: { }
headers: { }
10 changes: 10 additions & 0 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ framework:
multiplier: 3
max_delay: 3600000 # 1 hour

cache:
dsn: "%env(MESSENGER_TRANSPORT_DSN)%"
retry_strategy:
# 1, 2, 4, 8
max_retries: 4
delay: 60000 # 1 minutes
multiplier: 2
max_delay: 3600000 # 1 hour

failed:
dsn: '%env(MESSENGER_TRANSPORT_DSN_FAILED)%'
options:
Expand All @@ -23,6 +32,7 @@ framework:
'App\Message\CreateBookingMessage': async
'App\Message\SendBookingNotificationMessage': async
'App\Message\SendUserBookingNotificationMessage': async
'App\Message\AddBookingToCacheMessage': cache

when@test:
framework:
Expand Down
2 changes: 1 addition & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ services:
user_booking_cache_entry.order_filter:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { title: ~, start: ~, end: ~, resource: ~ }
$properties: { title: ~, start: ~, end: ~, resourceMail: ~, resourceDisplayName: ~ }
$orderParameterName: order
tags: [ 'api_platform.filter' ]
autowire: false
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.server.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
restart: unless-stopped
stop_grace_period: 20s
environment:
- APP_SUPERVISOR_COMMAND=/app/bin/console messenger:consume --env=prod --no-debug --time-limit=900 --failure-limit=1 async
- APP_SUPERVISOR_COMMAND=/app/bin/console messenger:consume --env=prod --no-debug --time-limit=900 --failure-limit=1 async cache
- APP_SUPERVISOR_WORKERS=1
- APP_SUPERVISOR_USER=deploy
networks:
Expand Down
2 changes: 1 addition & 1 deletion documentation/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ Replace `1.1.0` with the tag you are releasing.

**Important**: The job consumers MUST be stopped and restarted when doing releases. If they are not
we risk having a consumer of version a previous version process messages from the current version (E.g. `1.0.0` process messages from version `1.1.0`.). This is most easily done by simply restarting the
containers.
containers.
31 changes: 31 additions & 0 deletions migrations/Version20231113105714.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231113105714 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user_booking_cache_entry ADD resource_display_name VARCHAR(255) NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user_booking_cache_entry DROP resource_display_name');
}
}
31 changes: 31 additions & 0 deletions migrations/Version20231114100442.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231114100442 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user_booking_cache_entry CHANGE resource resource_mail VARCHAR(255) NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user_booking_cache_entry CHANGE resource_mail resource VARCHAR(255) NOT NULL');
}
}
40 changes: 29 additions & 11 deletions public/api-spec-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,25 @@
"allowReserved": false
},
{
"name": "order[resource]",
"name": "order[resourceMail]",
"in": "query",
"description": "",
"required": false,
"deprecated": false,
"allowEmptyValue": true,
"schema": {
"type": "string",
"enum": [
"asc",
"desc"
]
},
"style": "form",
"explode": false,
"allowReserved": false
},
{
"name": "order[resourceDisplayName]",
"in": "query",
"description": "",
"required": false,
Expand Down Expand Up @@ -2354,7 +2372,7 @@
}
}
},
"UserBookingCacheEntry": {
"UserBookingCacheEntry-userBookingCacheEntry": {
"type": "object",
"description": "",
"properties": {
Expand All @@ -2368,9 +2386,6 @@
"exchangeId": {
"type": "string"
},
"uid": {
"type": "string"
},
"start": {
"type": "string",
"format": "date-time"
Expand All @@ -2382,12 +2397,15 @@
"status": {
"type": "string"
},
"resource": {
"resourceMail": {
"type": "string"
},
"resourceDisplayName": {
"type": "string"
}
}
},
"UserBookingCacheEntry.jsonld": {
"UserBookingCacheEntry.jsonld-userBookingCacheEntry": {
"type": "object",
"description": "",
"properties": {
Expand All @@ -2409,9 +2427,6 @@
"exchangeId": {
"type": "string"
},
"uid": {
"type": "string"
},
"start": {
"type": "string",
"format": "date-time"
Expand All @@ -2423,7 +2438,10 @@
"status": {
"type": "string"
},
"resource": {
"resourceMail": {
"type": "string"
},
"resourceDisplayName": {
"type": "string"
}
}
Expand Down
33 changes: 24 additions & 9 deletions public/api-spec-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,22 @@ paths:
explode: false
allowReserved: false
-
name: 'order[resource]'
name: 'order[resourceMail]'
in: query
description: ''
required: false
deprecated: false
allowEmptyValue: true
schema:
type: string
enum:
- asc
- desc
style: form
explode: false
allowReserved: false
-
name: 'order[resourceDisplayName]'
in: query
description: ''
required: false
Expand Down Expand Up @@ -1679,7 +1694,7 @@ components:
type: string
resourceName:
type: string
UserBookingCacheEntry:
UserBookingCacheEntry-userBookingCacheEntry:
type: object
description: ''
properties:
Expand All @@ -1690,8 +1705,6 @@ components:
type: string
exchangeId:
type: string
uid:
type: string
start:
type: string
format: date-time
Expand All @@ -1700,9 +1713,11 @@ components:
format: date-time
status:
type: string
resource:
resourceMail:
type: string
resourceDisplayName:
type: string
UserBookingCacheEntry.jsonld:
UserBookingCacheEntry.jsonld-userBookingCacheEntry:
type: object
description: ''
properties:
Expand All @@ -1719,8 +1734,6 @@ components:
type: string
exchangeId:
type: string
uid:
type: string
start:
type: string
format: date-time
Expand All @@ -1729,7 +1742,9 @@ components:
format: date-time
status:
type: string
resource:
resourceMail:
type: string
resourceDisplayName:
type: string
responses: { }
parameters: { }
Expand Down
2 changes: 1 addition & 1 deletion src/Command/UserBookingCacheChangeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Options are used in the entity set methods, ie setTitle, setUid etc.
$field = $io->choice(
'Please select the field to update',
['title', 'uid', 'start', 'end', 'status', 'resource'],
['title', 'uid', 'start', 'end', 'status', 'resourceMail', 'resourceDisplayName'],
0
);

Expand Down
Loading

0 comments on commit 710387a

Please sign in to comment.