MCPcopy Create free account
hub / github.com/Rello/analytics / DataloadMapper

Class DataloadMapper

lib/Db/DataloadMapper.php:15–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13use Psr\Log\LoggerInterface;
14
15class DataloadMapper {
16 private $userId;
17 private $db;
18 private $logger;
19 const TABLE_NAME = 'analytics_dataload';
20
21 public function __construct(
22 $userId,
23 IDBConnection $db,
24 LoggerInterface $logger
25 ) {
26 $this->userId = $userId;
27 $this->db = $db;
28 $this->logger = $logger;
29 self::TABLE_NAME;
30 }
31
32 public function beginTransaction() {
33 $this->db->beginTransaction();
34 }
35
36 public function commit() {
37 $this->db->commit();
38 }
39
40 public function rollBack() {
41 $this->db->rollBack();
42 }
43
44 /**
45 * create a new dataload
46 *
47 * @NoAdminRequired
48 * @param int $datasetId
49 * @param int $datasourceId
50 * @return integer
51 * @throws \OCP\DB\Exception
52 */
53 public function create(int $datasetId, int $datasourceId) {
54 $sql = $this->db->getQueryBuilder();
55 $sql->insert(self::TABLE_NAME)->values([
56 'user_id' => $sql->createNamedParameter($this->userId),
57 'name' => $sql->createNamedParameter('New'),
58 'dataset' => $sql->createNamedParameter($datasetId),
59 'datasource' => $sql->createNamedParameter($datasourceId),
60 'option' => $sql->createNamedParameter('{}'),
61 ]);
62 $sql->executeStatement();
63 return (int)$sql->getLastInsertId();
64 }
65
66 /**
67 * get all data loads for a dataset
68 *
69 * @NoAdminRequired
70 * @param int $datasetId
71 * @return array
72 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected