PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
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 7 months ago Exceptions 4 years ago Importers 7 months ago Logger 4 years ago Config.php 4 years ago Geoip2.php 7 months ago Importer.php 5 months ago IncompatibleWpStatisticsVersion.php 7 months ago RecordInserter.php 4 years ago
RecordInserter.php
45 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( $record_name, DataTable $record, $maximum_rows_in_data_table = null,
25 $maximum_rows_in_sub_data_table = null, $column_to_sort_by_before_truncation = 'nb_visits' ) {
26 $record->setMetadata( RecordImporter::IS_IMPORTED_FROM_WPSTATISTICS_METADATA_NAME, 1 );
27
28 $blob = $record->getSerialized( $maximum_rows_in_data_table, $maximum_rows_in_sub_data_table, $column_to_sort_by_before_truncation );
29 $this->insert_blob_record( $record_name, $blob );
30 }
31
32 public function insert_blob_record( $name, $values ) {
33 $this->archive_writer->insertBlobRecord( $name, $values );
34 }
35
36 public function insert_numeric_records( array $values ) {
37 foreach ( $values as $name => $value ) {
38 if ( is_numeric( $name ) ) {
39 $name = Metrics::getReadableColumnName( $name );
40 }
41 $this->archive_writer->insertRecord( $name, $value );
42 }
43 }
44 }
45