Skip to content

Commit

Permalink
add extrainfo table class
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Apr 10, 2024
1 parent 07a1618 commit d491ec5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mock_crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

const METADATA_TABLE = "metadata_%s";

const EXTRA_INFO_TABLE = "extra_info_%s";

$capsule = new Capsule;

$capsule->addConnection([
Expand Down
65 changes: 65 additions & 0 deletions src/src/database/sherlock/ExtraInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace pagopa\database\sherlock;

use pagopa\database\SingleRow;
use Illuminate\Database\Capsule\Manager as Capsule;

class ExtraInfo extends SingleRow
{

/**
* Chiavi primarie della tabella TRANSACTION
* @var array|string[]
*/
protected array $primary_keys = ['id', 'date_event'];

/**
* Solo date event è sufficiente per le insert
* @var array
*/
protected array $need_primary_keys = ['date_event'];


public function __construct(\DateTime $date, array $eventData = [])
{
$table = sprintf(EXTRA_INFO_TABLE, $date->format('Y'));
parent::__construct($table, $eventData, ['id', 'date_event'], ['date_event']);
}


/**
* Configura la inserted timestamp
* @param \DateTime $date
* @return $this
*/
public function setInsertedTimestamp(\DateTime $date) : self
{
$this->setNewColumnValue('inserted_timestamp', $date->format('Y-m-d H:i:s.v'));
return $this;
}

/**
* Configura l'id del pagamento
* @param string $fk_payment
* @return $this
*/
public function setFkPayment(string $fk_payment) : self
{
$this->setNewColumnValue('fk_payment', $fk_payment);
return $this;
}

/**
* Configura il metadata
* @param string $key
* @param string $value
* @return $this
*/
public function setMetaData(string $key, string $value) : self
{
$this->setNewColumnValue('meta_key', $key);
$this->setNewColumnValue('meta_value', $value);
return $this;
}
}

0 comments on commit d491ec5

Please sign in to comment.