• 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/description/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 DescriptionService = require('../../../services/DescriptionService');
1✔
5
const {
6
  NOTIFICATION_TYPES,
7
  NOTIFICATION_ENTITIES,
8
} = require('../../../services/NotificationService');
1✔
9
const { toSimpleDescription } = require('../../../services/mapping/converters');
1✔
10

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

22
    const newTitle = req.param('title');
×
23
    const newBody = req.param('body');
×
24
    const newLanguage = req.param('language');
×
25

26
    const updatedFields = {
×
27
      reviewer: req.token.id,
28
      // dateReviewed will be updated automaticly by the SQL historisation trigger
29
    };
30

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

36
    await TDescription.updateOne({ id: descriptionId }).set(updatedFields);
×
37

38
    const populatedDescription = await DescriptionService.getDescription(
×
39
      descriptionId
40
    );
41
    await NotificationService.notifySubscribers(
×
42
      req,
43
      populatedDescription,
44
      req.token.id,
45
      NOTIFICATION_TYPES.UPDATE,
46
      NOTIFICATION_ENTITIES.DESCRIPTION
47
    );
48

49
    return ControllerService.treatAndConvert(
×
50
      req,
51
      null,
52
      populatedDescription,
53
      { controllerMethod: 'DescriptionController.update' },
54
      res,
55
      toSimpleDescription
56
    );
57
  } catch (e) {
58
    return ErrorService.getDefaultErrorHandler(res)(e);
×
59
  }
60
};
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