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

GrottoCenter / grottocenter-api / 5631056675

pending completion
5631056675

push

github

vmarseguerra
refactor(right): replaces rights with a static groups system

751 of 1944 branches covered (38.63%)

Branch coverage included in aggregate %.

59 of 59 new or added lines in 35 files covered. (100.0%)

2702 of 5007 relevant lines covered (53.96%)

14.64 hits per line

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

20.59
/api/controllers/v1/location/update.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const ErrorService = require('../../../services/ErrorService');
1✔
3
const NotificationService = require('../../../services/NotificationService');
1✔
4
const LocationService = require('../../../services/LocationService');
1✔
5
const { toSimpleLocation } = require('../../../services/mapping/converters');
1✔
6
const {
7
  NOTIFICATION_TYPES,
8
  NOTIFICATION_ENTITIES,
9
} = require('../../../services/NotificationService');
1✔
10

11
module.exports = async (req, res) => {
1✔
12
  try {
×
13
    const locationId = req.param('id');
×
14
    const rawLocation = await TLocation.findOne(locationId);
×
15
    // TODO How to delete/restore entity ?
16
    if (!rawLocation || rawLocation.isDeleted) {
×
17
      return res.notFound({
×
18
        message: `Location of id ${locationId} not found.`,
19
      });
20
    }
21

22
    const newTitle = req.param('title');
×
23
    const newBody = req.param('body');
×
24
    const newLanguage = req.param('language');
×
25
    const updatedFields = {
×
26
      reviewer: req.token.id,
27
      // dateReviewed will be updated automaticly by the SQL historisation trigger
28
    };
29

30
    if (newTitle) updatedFields.title = newTitle;
×
31
    if (newBody) updatedFields.body = newBody;
×
32
    if (newLanguage) updatedFields.language = newLanguage;
×
33
    // TODO re-compute relevance ?
34

35
    await TLocation.updateOne({ id: locationId }).set(updatedFields);
×
36

37
    const populatedLocation = await LocationService.getLocation(locationId);
×
38
    await NotificationService.notifySubscribers(
×
39
      req,
40
      populatedLocation,
41
      req.token.id,
42
      NOTIFICATION_TYPES.UPDATE,
43
      NOTIFICATION_ENTITIES.LOCATION
44
    );
45

46
    return ControllerService.treatAndConvert(
×
47
      req,
48
      null,
49
      populatedLocation,
50
      { controllerMethod: 'LocationController.update' },
51
      res,
52
      toSimpleLocation
53
    );
54
  } catch (e) {
55
    return ErrorService.getDefaultErrorHandler(res)(e);
×
56
  }
57
};
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