Skip to content

Commit

Permalink
add map events
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Apr 4, 2024
1 parent f026c3f commit f0aaa7a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/sql/02_2024_create_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,3 @@ create table if not exists public.metadata_2024 (
constraint "METADATA_2024_pk" primary key (date_event, id)
)
PARTITION BY RANGE (date_event);



44 changes: 44 additions & 0 deletions src/src/crawler/MapEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace pagopa\crawler;

class MapEvents
{

protected static array $map_events =
[
array(
'type' => 'activatePaymentNotice',
'subtype' => 'REQ',
'id' => 1
),
array(
'type' => 'activatePaymentNotice',
'subtype' => 'RESP',
'id' => 2
),
array(
'type' => 'nodoInviaCarrelloRPT',
'subtype' => 'REQ',
'id' => 3
),
array(
'type' => 'nodoInviaCarrelloRPT',
'subtype' => 'RESP',
'id' => 4
)
];


public static function getMethodId(string $type, string $subtype) : int|null
{
foreach(self::$map_events as $event)
{
if (($event['type'] == $type) && ($event['subtype'] == $subtype))
{
return $event['id'];
}
}
return null;
}
}
3 changes: 2 additions & 1 deletion src/src/crawler/events/req/activatePaymentNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace pagopa\crawler\events\req;

use pagopa\crawler\AbstractEvent;
use pagopa\crawler\MapEvents;
use pagopa\crawler\methods\MethodInterface;
use pagopa\crawler\methods\req\activatePaymentNotice as Payload;
use pagopa\database\sherlock\Transaction;
Expand Down Expand Up @@ -285,7 +286,7 @@ public function workflowEvent(int $index = 0): Workflow|null
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$workflow->setEventTimestamp($this->getInsertedTimestamp());
$workflow->setEventId($this->getUniqueId());
$workflow->setFkTipoEvento(1);
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));

$id_psp = $this->getPsp();
$stazione = $this->getStazione();
Expand Down
3 changes: 2 additions & 1 deletion src/src/crawler/events/req/nodoInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace pagopa\crawler\events\req;

use pagopa\crawler\AbstractEvent;
use pagopa\crawler\MapEvents;
use pagopa\database\sherlock\Transaction;
use pagopa\crawler\methods\req\nodoInviaCarrelloRPT as Payload;
use pagopa\database\sherlock\TransactionDetails;
Expand Down Expand Up @@ -266,7 +267,7 @@ public function workflowEvent(int $index = 0): Workflow|null
{
$workflow->setStazione($this->getStazione());
}
$workflow->setFkTipoEvento(3);
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));
return $workflow;
}

Expand Down
4 changes: 3 additions & 1 deletion src/src/crawler/events/resp/activatePaymentNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use pagopa\crawler\AbstractEvent;
use pagopa\crawler\FaultInterface;
use pagopa\crawler\MapEvents;
use pagopa\crawler\methods\resp\activatePaymentNotice as Payload;
use pagopa\database\sherlock\Transaction;
use pagopa\database\sherlock\TransactionDetails;
Expand Down Expand Up @@ -230,7 +231,8 @@ public function workflowEvent(int $index = 0): Workflow|null
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$workflow->setEventTimestamp($this->getInsertedTimestamp());
$workflow->setEventId($this->getUniqueId());
$workflow->setFkTipoEvento(2);
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));


$id_psp = $this->getPsp();
$stazione = $this->getStazione();
Expand Down
3 changes: 2 additions & 1 deletion src/src/crawler/events/resp/nodoInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace pagopa\crawler\events\resp;

use pagopa\crawler\AbstractEvent;
use pagopa\crawler\MapEvents;
use pagopa\crawler\methods\MethodInterface;
use pagopa\database\sherlock\Transaction;
use pagopa\crawler\methods\resp\nodoInviaCarrelloRPT as Payload;
Expand Down Expand Up @@ -209,7 +210,7 @@ public function workflowEvent(int $index = 0): Workflow|null
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$workflow->setEventId($this->getUniqueId());
$workflow->setEventTimestamp($this->getInsertedTimestamp());
$workflow->setFkTipoEvento(4);
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));
$stazione = $this->getStazione();
if (!is_null($this->getMethodInterface()->getFaultCode()))
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/.phpunit.result.cache

Large diffs are not rendered by default.

0 comments on commit f0aaa7a

Please sign in to comment.