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

GrottoCenter / grottocenter-api / 10996310862

23 Sep 2024 02:22PM UTC coverage: 46.158% (-2.8%) from 48.952%
10996310862

push

github

vmarseguerra
feat(entities): adds delete / restore for document

740 of 2203 branches covered (33.59%)

Branch coverage included in aggregate %.

24 of 153 new or added lines in 17 files covered. (15.69%)

484 existing lines in 49 files now uncovered.

2462 of 4734 relevant lines covered (52.01%)

4.5 hits per line

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

66.67
/api/services/RiggingService.js
1
const SEPARATOR = '|;|';
2✔
2

3
module.exports = {
2✔
4
  /**
5
   * Convert rigging objects with 1 property for obstacles, ropes, ... containing
6
   * each one a string representing multiple columns (with |!| separator into a
7
   * line by line object.
8
   *
9
   * @see RiggingService.test.js for examples
10
   * @param {Object} rigging
11
   */
12
  deserializeForAPI: (rigging) => {
13
    const obstacles = (rigging.obstacles ?? '').split(SEPARATOR);
12!
14
    const ropes = (rigging.ropes ?? '').split(SEPARATOR);
12!
15
    const anchors = (rigging.anchors ?? '').split(SEPARATOR);
12!
16
    const observations = (rigging.observations ?? '').split(SEPARATOR);
12!
17

18
    // eslint-disable-next-line no-param-reassign
19
    return (
12✔
20
      obstacles
21
        .map((_, i) => ({
46✔
22
          obstacle: obstacles[i] ?? '',
46!
23
          rope: ropes[i] ?? '',
46!
24
          anchor: anchors[i] ?? '',
46!
25
          observation: observations[i] ?? '',
46!
26
        }))
27
        // remove empty data (badly formatted data in the db)
28
        .filter(
29
          (o) =>
30
            o.obstacle !== '' ||
46!
31
            o.rope !== '' ||
32
            o.anchor !== '' ||
33
            o.observation !== ''
34
        )
35
    );
36
  },
37
  /**
38
   * Convert an obstacles array (usually coming from the API) into an object of
39
   * obstacles, ropes, anchors and observations where each property has a string
40
   * value with the DB format representing multiple columns (with |!| separator)
41
   *
42
   * @see RiggingService.test.js for examples
43
   * @param {Object[]} obstaclesArr
44
   */
45
  serializeObstaclesForDB: async (obstaclesArr) => {
46
    const obstacles = [];
3✔
47
    const ropes = [];
3✔
48
    const anchors = [];
3✔
49
    const observations = [];
3✔
50
    for (const line of obstaclesArr) {
3✔
51
      obstacles.push(line.obstacle ? line.obstacle : '');
9!
52
      ropes.push(line.rope ? line.rope : '');
9✔
53
      anchors.push(line.anchor ? line.anchor : '');
9✔
54
      observations.push(line.observation ? line.observation : '');
9✔
55
    }
56
    return {
3✔
57
      obstacles: obstacles.join(SEPARATOR),
58
      ropes: ropes.join(SEPARATOR),
59
      anchors: anchors.join(SEPARATOR),
60
      observations: observations.join(SEPARATOR),
61
    };
62
  },
63
  getEntranceRiggings: async (entranceId, where = {}) => {
×
64
    if (!entranceId) return [];
8!
65
    return TRigging.find({ ...where, entrance: entranceId })
8✔
66
      .populate('author')
67
      .populate('reviewer');
68
  },
69
  getEntranceHRiggings: async (entranceId, where = {}) => {
×
UNCOV
70
    if (!entranceId) return [];
×
UNCOV
71
    const riggingIds = await TRigging.find({
×
72
      where: { ...where, entrance: entranceId },
73
      select: ['id'],
74
    });
UNCOV
75
    return module.exports.getHRiggings(riggingIds.map((e) => e.id));
×
76
  },
77

78
  getRigging: async (riggingId) =>
79
    TRigging.findOne({ id: riggingId }).populate('author').populate('reviewer'),
2✔
80

81
  getHRiggings: async (riggingId) =>
UNCOV
82
    HRigging.find({ t_id: riggingId }).populate('reviewer').populate('author'),
×
83
};
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