PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.12.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.12.1
5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / classes / WpMatomo / WpStatistics / RecordInserter.php
matomo / classes / WpMatomo / WpStatistics Last commit date
DataConverters 1 week ago Exceptions 4 years ago Importers 1 week ago Logger 4 years ago Config.php 4 years ago Geoip2.php 8 months ago Importer.php 1 week ago IncompatibleWpStatisticsVersion.php 8 months ago RecordInserter.php 1 week ago
RecordInserter.php
50 lines
1 <?php
2
3 namespace WpMatomo\WpStatistics;
4
5 use Piwik\DataAccess\ArchiveWriter;
6 use Piwik\DataTable;
7 use Piwik\Metrics;
8 use WpMatomo\WpStatistics\Importers\Actions\RecordImporter;
9 /**
10 * @package WpMatomo
11 * @subpackage WpStatisticsImport
12 */
13 class RecordInserter {
14
15 /**
16 * @var ArchiveWriter
17 */
18 private $archive_writer;
19
20 public function __construct( ArchiveWriter $writer ) {
21 $this->archive_writer = $writer;
22 }
23
24 public function insert_record(
25 $record_name,
26 DataTable $record,
27 $maximum_rows_in_data_table = null,
28 $maximum_rows_in_sub_data_table = null,
29 $column_to_sort_by_before_truncation = 'nb_visits'
30 ) {
31 $record->setMetadata( RecordImporter::IS_IMPORTED_FROM_WPSTATISTICS_METADATA_NAME, 1 );
32
33 $blob = $record->getSerialized( $maximum_rows_in_data_table, $maximum_rows_in_sub_data_table, $column_to_sort_by_before_truncation );
34 $this->insert_blob_record( $record_name, $blob );
35 }
36
37 public function insert_blob_record( $name, $values ) {
38 $this->archive_writer->insertBlobRecord( $name, $values );
39 }
40
41 public function insert_numeric_records( array $values ) {
42 foreach ( $values as $name => $value ) {
43 if ( is_numeric( $name ) ) {
44 $name = Metrics::getReadableColumnName( $name );
45 }
46 $this->archive_writer->insertRecord( $name, $value );
47 }
48 }
49 }
50