Skip to content

Commit

Permalink
add metadata table
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Mar 28, 2024
1 parent 6ea571c commit 232a02b
Show file tree
Hide file tree
Showing 9 changed files with 448 additions and 9 deletions.
34 changes: 34 additions & 0 deletions src/see_cache.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
<?php

require_once './vendor/autoload.php';

const REDIS_HOST = '172.17.0.6';
const REDIS_PORT = '6379';


$connection =
[
'scheme' => 'tcp',
'host' => REDIS_HOST,
'port' => REDIS_PORT
];


function randomString($n = 15)
{
$string = '';
for($i=0;$i<$n;$i++)
{
$string .= rand(0, 9);
}
return $string;
}


$redis_cache = new \pagopa\crawler\RedisCache($connection);

foreach($redis_cache->getAllKeys() as $key)
{
print_r($redis_cache->getValue($key));
}



die();

$mem = new Memcached();
$connect = $mem->addServer('172.17.0.3',11211);
Expand Down
1 change: 1 addition & 0 deletions src/sql/01_2024_seq.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ create sequence public.transaction_re_2024_id_seq;
create sequence public.transaction_2024_id_seq;
create sequence public.transaction_2024_details_id_seq;
create sequence public.transaction_2024_events_id_seq;
create sequence public.metadata_2024_id_seq;


11 changes: 11 additions & 0 deletions src/sql/02_2024_create_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,16 @@ create table if not exists public.transaction_re_2024 (
)
PARTITION BY RANGE (date_event);

create table if not exists public.metadata_2024 (
id bigint default nextval('public.metadata_2024_id_seq'::regclass) not null,
date_event date not null,
fk_payment bigint not null,
fk_transfer bigint not null,
meta_key varchar(140) not null,
meta_value varchar(140) not null,
constraint "METADATA_2024_pk" primary key (date_event, id)
)
PARTITION BY RANGE (date_event);



375 changes: 375 additions & 0 deletions src/sql/03_2024_create_partitions.sql

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/src/crawler/events/resp/activatePaymentNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,13 @@ public function transaction(int $index = 0): Transaction|null
*/
public function transactionDetails(int $transfer = 0, int $index = 0): TransactionDetails|null
{
return null;
$transaction_details = new TransactionDetails($this->getInsertedTimestamp());
$transaction_details->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$transaction_details->setPaTransfer($this->getMethodInterface()->getTransferPa($transfer, 0));
$transaction_details->setAmountTransfer($this->getMethodInterface()->getTransferAmount($transfer, 0));
$transaction_details->setTransferIban($this->getMethodInterface()->getTransferIban($transfer, 0));
$transaction_details->setIdTransfer($this->getMethodInterface()->getTransferId($transfer, 0));
return $transaction_details;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/src/crawler/paymentlist/req/activatePaymentNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function runCreateAttempt(int $index = 0): array
'pa_emittente' => $pa_emittente,
'token_ccp' => $token,
'transfer_added' => false,
'esito' => false,
'amount_update' => false
];
$this->addValueCache($cache_key, $cache_value);
Expand Down
6 changes: 5 additions & 1 deletion src/src/crawler/paymentlist/req/nodoInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function runCreateAttempt(int $index = 0): array
'token_ccp' => $ccp,
'id_carrello' => $id_carrello,
'transfer_add' => true,
'esito' => false,
'amount_update' => true
];

Expand All @@ -150,14 +151,15 @@ public function runCreateAttempt(int $index = 0): array
$details->setFkPayment($last_inserted_id);
$details->insert();
DB::statement($details->getQuery(), $details->getBindParams());
$last_inserted_id_transfer = DB::connection()->getPdo()->lastInsertId();

if ($this->getEvent()->getMethodInterface()->isBollo($i, $index))
{
$transfer_add = [
'pa_transfer' => $this->getEvent()->getMethodInterface()->getTransferPa($i, $index),
'bollo' => true,
'amount_transfer' => $this->getEvent()->getMethodInterface()->getTransferAmount($i, $index),
'iban_transfer' => ''
'iban_transfer' => ''
];
}
else
Expand All @@ -169,6 +171,8 @@ public function runCreateAttempt(int $index = 0): array
'iban_transfer' => $this->getEvent()->getMethodInterface()->getTransferIban($i, $index)
];
}
$transfer_add['id'] = $last_inserted_id_transfer;
$transfer_add['date_event'] = $this->getEvent()->getInsertedTimestamp()->format('Y-m-d');
$cache_value['transfer_list'][] = $transfer_add;
}

Expand Down
19 changes: 13 additions & 6 deletions src/src/crawler/paymentlist/resp/activatePaymentNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,22 @@ public function runCreateAttempt(int $index = 0): array
DB::statement($transaction->getQuery(), $transaction->getBindParams());
$last_inserted_id = DB::connection()->getPdo()->lastInsertId();

$transfer_add = [];
for($i=0;$i<$this->getEvent()->getTransferCount($index);$i++)
{
$transaction_details = new TransactionDetails($this->getEvent()->getInsertedTimestamp());
$transaction_details = $this->getEvent()->transactionDetails($i, 0);
$transaction_details->setFkPayment($last_inserted_id);
$transaction_details->setNewColumnValue('date_event', $date_event);
$transaction_details->setPaTransfer($this->getEvent()->getMethodInterface()->getTransferPa($i, 0));
$transaction_details->setAmountTransfer($this->getEvent()->getMethodInterface()->getTransferAmount($i, 0));
$transaction_details->setTransferIban($this->getEvent()->getMethodInterface()->getTransferIban($i, 0));
$transaction_details->setIdTransfer($this->getEvent()->getMethodInterface()->getTransferId($i, 0));
$transaction_details->insert();
DB::statement($transaction_details->getQuery(), $transaction_details->getBindParams());
$last_inserted_id_transfer = DB::connection()->getPdo()->lastInsertId();
$transfer_add[] = [
'pa_transfer' => $this->getEvent()->getMethodInterface()->getTransferPa($i, 0),
'bollo' => false,
'amount_transfer' => $this->getEvent()->getMethodInterface()->getTransferAmount($i, 0),
'iban_transfer' => $this->getEvent()->getMethodInterface()->getTransferIban($i, 0),
'id' => $last_inserted_id_transfer,
'date_event' => $this->getEvent()->getInsertedTimestamp()->format('Y-m-d')
];
}


Expand All @@ -159,6 +164,8 @@ public function runCreateAttempt(int $index = 0): array
'pa_emittente' => $pa_emittente,
'token_ccp' => $token,
'transfer_add' => true,
'transfer_list' => $transfer_add,
'esito' => false,
'amount_update' => true
];
$this->addValueCache($cache_key, $cache_value);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/.phpunit.result.cache

Large diffs are not rendered by default.

0 comments on commit 232a02b

Please sign in to comment.