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

GrottoCenter / grottocenter-api / 19482422298

18 Nov 2025 10:05PM UTC coverage: 46.224%. Remained the same
19482422298

Pull #1402

github

ClemRz
feat(entrances): adds pagination to all `/entrances/with-quality/` endpoints
Pull Request #1402: Chore/fix my email

1015 of 2915 branches covered (34.82%)

Branch coverage included in aggregate %.

276 of 386 new or added lines in 25 files covered. (71.5%)

29 existing lines in 7 files now uncovered.

3061 of 5903 relevant lines covered (51.85%)

6.97 hits per line

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

11.76
/api/services/DataQualityComputeService.js
1
const CommonService = require('./CommonService');
1✔
2

3
/**
4
 * this service is used to retrieves the elements included
5
 * in the computation of the quality of the data of an entrance.
6
 */
7
const GET_ENTRANCES_WITH_QUALITY_BY_MASSIF = `
1✔
8
  SELECT *
9
  FROM v_data_quality_compute_entrance
10
  WHERE id_massif = $1
11
  LIMIT $2 OFFSET $3
12
`;
13

14
const GET_ENTRANCES_WITH_QUALITY_BY_COUNTRY = `
1✔
15
  SELECT DISTINCT id_entrance, general_latest_date_of_update, general_nb_contributions, location_latest_date_of_update, location_nb_contributions, description_latest_date_of_update, description_nb_contributions, document_latest_date_of_update, document_nb_contributions, rigging_latest_date_of_update, rigging_nb_contributions, history_latest_date_of_update, history_nb_contributions, comment_latest_date_of_update, comment_nb_contributions, entrance_name, id_country, country_name, date_of_update
16
  FROM v_data_quality_compute_entrance
17
  WHERE id_country = $1
18
  LIMIT $2 OFFSET $3
19
`;
20

21
const GET_ENTRANCES_WITH_QUALITY_BY_REGION = `
1✔
22
  SELECT DISTINCT v.id_entrance, v.general_latest_date_of_update, v.general_nb_contributions, v.location_latest_date_of_update, v.location_nb_contributions, v.description_latest_date_of_update, v.description_nb_contributions, v.document_latest_date_of_update, v.document_nb_contributions, v.rigging_latest_date_of_update, v.rigging_nb_contributions, v.history_latest_date_of_update, v.history_nb_contributions, v.comment_latest_date_of_update, v.comment_nb_contributions, v.entrance_name, v.id_country, v.country_name, v.date_of_update
23
  FROM v_data_quality_compute_entrance v
24
  JOIN t_entrance e ON v.id_entrance = e.id
25
  WHERE e.iso_3166_2 = $1
26
  LIMIT $2 OFFSET $3
27
`;
28

29
const COUNT_ENTRANCES_WITH_QUALITY_BY_MASSIF = `
1✔
30
  SELECT COUNT(*)
31
  FROM v_data_quality_compute_entrance
32
  WHERE id_massif = $1
33
`;
34

35
const COUNT_ENTRANCES_WITH_QUALITY_BY_COUNTRY = `
1✔
36
  SELECT COUNT(DISTINCT id_entrance)
37
  FROM v_data_quality_compute_entrance
38
  WHERE id_country = $1
39
`;
40

41
const COUNT_ENTRANCES_WITH_QUALITY_BY_REGION = `
1✔
42
  SELECT COUNT(DISTINCT v.id_entrance)
43
  FROM v_data_quality_compute_entrance v
44
  JOIN t_entrance e ON v.id_entrance = e.id
45
  WHERE e.iso_3166_2 = $1
46
`;
47

48
module.exports = {
1✔
49
  /**
50
   *
51
   * @param {int} massifId
52
   * @param {int} limit
53
   * @param {int} offset
54
   * @returns {Object} the date of the latest update and the number of contributions on all entrances in a massif
55
   *          or null if no result or something went wrong
56
   */
57
  getEntrancesWithQualityByMassif: async (
58
    massifId,
59
    limit = null,
×
60
    offset = null
×
61
  ) => {
NEW
62
    try {
×
63
      const params =
NEW
64
        limit !== null && offset !== null
×
65
          ? [massifId, limit, offset]
66
          : [massifId];
67
      const query =
NEW
68
        limit !== null && offset !== null
×
69
          ? GET_ENTRANCES_WITH_QUALITY_BY_MASSIF
70
          : GET_ENTRANCES_WITH_QUALITY_BY_MASSIF.replace(
71
              'LIMIT $2 OFFSET $3',
72
              ''
73
            );
NEW
74
      const queryResult = await CommonService.query(query, params);
×
NEW
75
      return queryResult.rows;
×
76
    } catch (e) {
NEW
77
      return null;
×
78
    }
79
  },
80

81
  /**
82
   *
83
   * @param {int} massifId
84
   * @returns {int} count of entrances in massif
85
   */
86
  getEntrancesWithQualityByMassifCount: async (massifId) => {
UNCOV
87
    try {
×
UNCOV
88
      const queryResult = await CommonService.query(
×
89
        COUNT_ENTRANCES_WITH_QUALITY_BY_MASSIF,
90
        [massifId]
91
      );
NEW
92
      return parseInt(queryResult.rows[0].count, 10);
×
93
    } catch (e) {
NEW
94
      return 0;
×
95
    }
96
  },
97

98
  /**
99
   *
100
   * @param {string} countryId alpha-2 code
101
   * @param {int} limit
102
   * @param {int} offset
103
   * @returns {Object} the date of the latest update and the number of contributions on all entrances in a country
104
   *          or null if no result or something went wrong
105
   */
106
  getEntrancesWithQualityByCountry: async (
107
    countryId,
108
    limit = null,
×
109
    offset = null
×
110
  ) => {
NEW
111
    try {
×
112
      const params =
NEW
113
        limit !== null && offset !== null
×
114
          ? [countryId, limit, offset]
115
          : [countryId];
116
      const query =
NEW
117
        limit !== null && offset !== null
×
118
          ? GET_ENTRANCES_WITH_QUALITY_BY_COUNTRY
119
          : GET_ENTRANCES_WITH_QUALITY_BY_COUNTRY.replace(
120
              'LIMIT $2 OFFSET $3',
121
              ''
122
            );
NEW
123
      const queryResult = await CommonService.query(query, params);
×
NEW
124
      return queryResult.rows;
×
125
    } catch (e) {
NEW
126
      return null;
×
127
    }
128
  },
129

130
  /**
131
   *
132
   * @param {string} countryId alpha-2 code
133
   * @returns {int} count of entrances in country
134
   */
135
  getEntrancesWithQualityByCountryCount: async (countryId) => {
UNCOV
136
    try {
×
UNCOV
137
      const queryResult = await CommonService.query(
×
138
        COUNT_ENTRANCES_WITH_QUALITY_BY_COUNTRY,
139
        [countryId]
140
      );
NEW
141
      return parseInt(queryResult.rows[0].count, 10);
×
142
    } catch (e) {
NEW
143
      return 0;
×
144
    }
145
  },
146

147
  /**
148
   *
149
   * @param {string} regionId ISO 3166-2 code (e.g., 'US-TN')
150
   * @param {int} limit
151
   * @param {int} offset
152
   * @returns {Object} the date of the latest update and the number of contributions on all entrances in a region
153
   *          or null if no result or something went wrong
154
   */
155
  getEntrancesWithQualityByRegion: async (
156
    regionId,
157
    limit = null,
×
158
    offset = null
×
159
  ) => {
NEW
160
    try {
×
161
      const params =
NEW
162
        limit !== null && offset !== null
×
163
          ? [regionId, limit, offset]
164
          : [regionId];
165
      const query =
NEW
166
        limit !== null && offset !== null
×
167
          ? GET_ENTRANCES_WITH_QUALITY_BY_REGION
168
          : GET_ENTRANCES_WITH_QUALITY_BY_REGION.replace(
169
              'LIMIT $2 OFFSET $3',
170
              ''
171
            );
NEW
172
      const queryResult = await CommonService.query(query, params);
×
UNCOV
173
      return queryResult.rows;
×
174
    } catch (e) {
UNCOV
175
      return null;
×
176
    }
177
  },
178

179
  /**
180
   *
181
   * @param {string} regionId ISO 3166-2 code (e.g., 'US-TN')
182
   * @returns {int} count of entrances in region
183
   */
184
  getEntrancesWithQualityByRegionCount: async (regionId) => {
NEW
185
    try {
×
NEW
186
      const queryResult = await CommonService.query(
×
187
        COUNT_ENTRANCES_WITH_QUALITY_BY_REGION,
188
        [regionId]
189
      );
NEW
190
      return parseInt(queryResult.rows[0].count, 10);
×
191
    } catch (e) {
NEW
192
      return 0;
×
193
    }
194
  },
195
};
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