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

GrottoCenter / grottocenter-api / 10996210778

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

Pull #1306

github

vmarseguerra
feat(entities): adds delete / restore for document
Pull Request #1306: Adds delete / restore for entrance sub entities

740 of 2203 branches covered (33.59%)

Branch coverage included in aggregate %.

526 of 1293 new or added lines in 114 files covered. (40.68%)

23 existing lines in 18 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

18.75
/api/controllers/v1/rigging/delete.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const NotificationService = require('../../../services/NotificationService');
1✔
3
const RiggingService = require('../../../services/RiggingService');
1✔
4
const { toSimpleRigging } = require('../../../services/mapping/converters');
1✔
5
const RightService = require('../../../services/RightService');
1✔
6

7
module.exports = async (req, res) => {
1✔
NEW
8
  const hasRight = RightService.hasGroup(
×
9
    req.token.groups,
10
    RightService.G.MODERATOR
11
  );
NEW
12
  if (!hasRight)
×
NEW
13
    return res.forbidden('You are not authorized to delete rigging.');
×
14

NEW
15
  const riggingId = req.param('id');
×
NEW
16
  const rigging = await RiggingService.getRigging(riggingId);
×
NEW
17
  if (!rigging) {
×
NEW
18
    return res.notFound({ message: `Rigging of id ${riggingId} not found.` });
×
19
  }
20

NEW
21
  if (!rigging.isDeleted) {
×
NEW
22
    await TRigging.destroyOne({ id: riggingId }); // Soft delete
×
NEW
23
    rigging.isDeleted = true;
×
24
  }
25

NEW
26
  const deletePermanently = !!req.param('isPermanent');
×
NEW
27
  if (deletePermanently) {
×
NEW
28
    await HRigging.destroy({ t_id: riggingId });
×
NEW
29
    await TRigging.destroyOne({ id: riggingId }); // Hard delete
×
30
  }
31

NEW
32
  await NotificationService.notifySubscribers(
×
33
    req,
34
    rigging,
35
    req.token.id,
36
    deletePermanently
×
37
      ? NotificationService.NOTIFICATION_TYPES.PERMANENT_DELETE
38
      : NotificationService.NOTIFICATION_TYPES.DELETE,
39
    NotificationService.NOTIFICATION_ENTITIES.RIGGING
40
  );
41

NEW
42
  return ControllerService.treatAndConvert(
×
43
    req,
44
    null,
45
    rigging,
46
    { controllerMethod: 'RiggingController.delete' },
47
    res,
48
    toSimpleRigging
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