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

GrottoCenter / grottocenter-api / 10511865220

22 Aug 2024 04:19PM UTC coverage: 47.822% (-1.1%) from 48.96%
10511865220

push

github

vmarseguerra
feat(entities): adds delete / restore for entrance sub entities

711 of 2020 branches covered (35.2%)

Branch coverage included in aggregate %.

193 of 432 new or added lines in 35 files covered. (44.68%)

4 existing lines in 4 files now uncovered.

2528 of 4753 relevant lines covered (53.19%)

4.41 hits per line

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

59.26
/api/services/LocationService.js
1
module.exports = {
2✔
2
  getEntranceLocations: async (entranceId, where = {}) => {
1✔
3
    if (!entranceId) return [];
2!
4
    return TLocation.find({ ...where, entrance: entranceId })
2✔
5
      .populate('author')
6
      .populate('reviewer');
7
  },
8
  getEntranceHLocations: async (
9
    entranceId,
10
    hasCompleteViewRight,
11
    where = {}
×
12
  ) => {
13
    if (!entranceId) return [];
×
NEW
14
    const loactionIds = await TLocation.find({
×
15
      where: { ...where, entrance: entranceId },
16
      select: ['id'],
17
    });
NEW
18
    return module.exports.getHLocation(
×
NEW
19
      loactionIds.map((e) => e.id),
×
20
      hasCompleteViewRight
21
    );
22
  },
23

24
  getLocation: async (locationId) =>
NEW
25
    TLocation.findOne({ id: locationId })
×
26
      .populate('author')
27
      .populate('reviewer'),
28

29
  getHLocation: async (locationId, hasCompleteViewRight) => {
30
    const CHECK_SENSITIVTY_OF_ENTRANCE_FROM_LOCATION_ID = `
3✔
31
    SELECT TE.is_sensitive
32
    FROM h_location HL
33
          JOIN t_entrance TE ON HL.id_entrance = TE.id
34
    WHERE HL.id = $1;`;
35

36
    if (!hasCompleteViewRight) {
3!
37
      // For non admin user, we do not return locations for sensitive entrance
38
      const sensitivity = await HLocation.getDatastore().sendNativeQuery(
3✔
39
        CHECK_SENSITIVTY_OF_ENTRANCE_FROM_LOCATION_ID,
40
        [Array.isArray(locationId) ? locationId[0] : locationId]
3!
41
      );
42

43
      if (!sensitivity.rows[0] || sensitivity.rows[0].is_sensitive) return [];
3✔
44
    }
45

46
    return HLocation.find({ t_id: locationId })
1✔
47
      .populate('reviewer')
48
      .populate('author');
49
  },
50
};
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