• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 21191404942

20 Jan 2026 11:40PM UTC coverage: 44.316%. First build
21191404942

Pull #6461

github

web-flow
Merge f848257c7 into ec977726d
Pull Request #6461: fix: visible elements in envelope context

76 of 169 new or added lines in 5 files covered. (44.97%)

7076 of 15967 relevant lines covered (44.32%)

4.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.68
/lib/Db/FileElementMapper.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Db;
10

11
use OCP\AppFramework\Db\QBMapper;
12
use OCP\DB\QueryBuilder\IQueryBuilder;
13
use OCP\IDBConnection;
14

15
/**
16
 * Class FileElementsMapper
17
 *
18
 * @package OCA\Libresign\DB
19
 * @template-extends QBMapper<FileElement>
20
 */
21
class FileElementMapper extends QBMapper {
22
        /** @var FileElement[][] */
23
        private $cache = [];
24

25
        public function __construct(IDBConnection $db) {
26
                parent::__construct($db, 'libresign_file_element');
47✔
27
        }
28

29
        /**
30
         * @return FileElement[]
31
         */
32
        public function getByFileId(int $fileId): array {
33
                $qb = $this->db->getQueryBuilder();
1✔
34

35
                $qb->select('fe.*')
1✔
36
                        ->from($this->getTableName(), 'fe')
1✔
37
                        ->where(
1✔
38
                                $qb->expr()->eq('fe.file_id', $qb->createNamedParameter($fileId))
1✔
39
                        );
1✔
40

41
                /** @var FileElement[] */
42
                return $this->findEntities($qb);
1✔
43
        }
44

45
        /**
46
         * @param int[] $fileIds
47
         * @return FileElement[]
48
         */
49
        public function getByFileIds(array $fileIds): array {
NEW
50
                if (empty($fileIds)) {
×
NEW
51
                        return [];
×
52
                }
53

NEW
54
                $qb = $this->db->getQueryBuilder();
×
55

NEW
56
                $qb->select('fe.*')
×
NEW
57
                        ->from($this->getTableName(), 'fe')
×
NEW
58
                        ->where(
×
NEW
59
                                $qb->expr()->in('fe.file_id', $qb->createNamedParameter($fileIds, IQueryBuilder::PARAM_INT_ARRAY))
×
NEW
60
                        );
×
61

62
                /** @var FileElement[] */
NEW
63
                return $this->findEntities($qb);
×
64
        }
65

66
        /**
67
         * @return FileElement[]
68
         */
69
        public function getByFileIdAndSignRequestId(int $fileId, ?int $signRequestId): array {
70
                $qb = $this->db->getQueryBuilder();
4✔
71

72
                $qb->select('fe.*')
4✔
73
                        ->from($this->getTableName(), 'fe')
4✔
74
                        ->where(
4✔
75
                                $qb->expr()->eq('fe.file_id', $qb->createNamedParameter($fileId))
4✔
76
                        );
4✔
77
                if ($signRequestId) {
4✔
78
                        $qb->andWhere(
4✔
79
                                $qb->expr()->eq('fe.sign_request_id', $qb->createNamedParameter($signRequestId, IQueryBuilder::PARAM_INT))
4✔
80
                        );
4✔
81
                }
82

83
                /** @var FileElement[] */
84
                return $this->findEntities($qb);
4✔
85
        }
86

87
        public function getById(int $id): FileElement {
88
                if (!isset($this->cache['documentElementId'][$id])) {
2✔
89
                        $qb = $this->db->getQueryBuilder();
2✔
90

91
                        $qb->select('fe.*')
2✔
92
                                ->from($this->getTableName(), 'fe')
2✔
93
                                ->where(
2✔
94
                                        $qb->expr()->eq('fe.id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
2✔
95
                                );
2✔
96

97
                        /** @var FileElement */
98
                        $this->cache['documentElementId'][$id] = $this->findEntity($qb);
2✔
99
                }
100
                return $this->cache['documentElementId'][$id];
2✔
101
        }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc