| 14 | use Psr\Log\LoggerInterface; |
| 15 | |
| 16 | class DatasetMapper { |
| 17 | private $l10n; |
| 18 | private $userId; |
| 19 | private $db; |
| 20 | private $logger; |
| 21 | const TABLE_NAME = 'analytics_dataset'; |
| 22 | |
| 23 | public function __construct( |
| 24 | $userId, |
| 25 | IL10N $l10n, |
| 26 | IDBConnection $db, |
| 27 | LoggerInterface $logger |
| 28 | ) { |
| 29 | $this->userId = $userId; |
| 30 | $this->l10n = $l10n; |
| 31 | $this->db = $db; |
| 32 | $this->logger = $logger; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * get datasets |
| 37 | * @return array |
| 38 | * @throws Exception |
| 39 | */ |
| 40 | public function index(): array { |
| 41 | $sql = $this->db->getQueryBuilder(); |
| 42 | $sql->from(self::TABLE_NAME) |
| 43 | ->select('id') |
| 44 | ->addSelect('name') |
| 45 | ->addSelect('dimension1') |
| 46 | ->addSelect('dimension2') |
| 47 | ->addSelect('value') |
| 48 | ->addSelect('type') |
| 49 | ->addSelect('parent') |
| 50 | ->where($sql->expr()->eq('user_id', $sql->createNamedParameter($this->userId))) |
| 51 | ->orderBy('parent', 'ASC') |
| 52 | ->addOrderBy('name', 'ASC'); |
| 53 | $statement = $sql->executeQuery(); |
| 54 | $result = $statement->fetchAll(); |
| 55 | $statement->closeCursor(); |
| 56 | return $result; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * get datasets |
| 61 | * @param $userId |
| 62 | * @return array |
| 63 | * @throws Exception |
| 64 | */ |
| 65 | public function indexByUser($userId): array { |
| 66 | $sql = $this->db->getQueryBuilder(); |
| 67 | $sql->from(self::TABLE_NAME)->select('id')->where($sql->expr() |
| 68 | ->eq('user_id', $sql->createNamedParameter($userId))); |
| 69 | $statement = $sql->executeQuery(); |
| 70 | $result = $statement->fetchAll(); |
| 71 | $statement->closeCursor(); |
| 72 | return $result; |
| 73 | } |
nothing calls this directly
no outgoing calls
no test coverage detected