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

GrottoCenter / grottocenter-api / 10996013011

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

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 %.

528 of 1295 new or added lines in 114 files covered. (40.77%)

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

16.67
/api/controllers/v1/location/update.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const NotificationService = require('../../../services/NotificationService');
1✔
3
const LocationService = require('../../../services/LocationService');
1✔
4
const { toSimpleLocation } = require('../../../services/mapping/converters');
1✔
5

6
module.exports = async (req, res) => {
1✔
NEW
7
  const locationId = req.param('id');
×
NEW
8
  const rawLocation = await TLocation.findOne(locationId);
×
NEW
9
  if (!rawLocation || rawLocation.isDeleted) {
×
NEW
10
    return res.notFound({ message: `Location of id ${locationId} not found.` });
×
11
  }
12

NEW
13
  const newTitle = req.param('title');
×
NEW
14
  const newBody = req.param('body');
×
NEW
15
  const newLanguage = req.param('language');
×
NEW
16
  const updatedFields = {
×
17
    reviewer: req.token.id,
18
    // dateReviewed will be updated automaticly by the SQL historisation trigger
19
  };
20

NEW
21
  if (newTitle) updatedFields.title = newTitle;
×
NEW
22
  if (newBody) updatedFields.body = newBody;
×
NEW
23
  if (newLanguage) updatedFields.language = newLanguage;
×
24
  // TODO re-compute relevance ?
25

NEW
26
  await TLocation.updateOne({ id: locationId }).set(updatedFields);
×
27

NEW
28
  const populatedLocation = await LocationService.getLocation(locationId);
×
NEW
29
  await NotificationService.notifySubscribers(
×
30
    req,
31
    populatedLocation,
32
    req.token.id,
33
    NotificationService.NOTIFICATION_TYPES.UPDATE,
34
    NotificationService.NOTIFICATION_ENTITIES.LOCATION
35
  );
36

NEW
37
  return ControllerService.treatAndConvert(
×
38
    req,
39
    null,
40
    populatedLocation,
41
    { controllerMethod: 'LocationController.update' },
42
    res,
43
    toSimpleLocation
44
  );
45
};
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