• 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

82.14
/api/controllers/v1/organization/update.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const GrottoService = require('../../../services/GrottoService');
1✔
3
const NotificationService = require('../../../services/NotificationService');
1✔
4
const GeocodingService = require('../../../services/GeocodingService');
1✔
5
const { toOrganization } = require('../../../services/mapping/converters');
1✔
6

7
module.exports = async (req, res) => {
1✔
8
  // Check if organization exists
9
  const organizationId = req.param('id');
1✔
10
  const rawOrganization = await TGrotto.findOne(organizationId);
1✔
11
  if (!rawOrganization || rawOrganization.isDeleted) {
1!
UNCOV
12
    return res.notFound({
×
13
      message: `Organization of id ${organizationId} not found.`,
14
    });
15
  }
16

17
  const cleanedData = {
1✔
18
    ...GrottoService.getConvertedDataFromClientRequest(req),
19
    reviewer: req.token.id,
20
    id: organizationId,
21
  };
22

23
  // Update reverse geocoding if the position has changed
24
  if (
1!
25
    Math.abs(rawOrganization.latitude - cleanedData.latitude) > 0.001 ||
1!
26
    Math.abs(rawOrganization.longitude - cleanedData.longitude) > 0.001
27
  ) {
28
    const address = await GeocodingService.reverse(
1✔
29
      cleanedData.latitude,
30
      cleanedData.longitude
31
    );
32
    if (address) cleanedData.iso_3166_2 = address.iso_3166_2;
1!
33
  }
34

35
  // The name is updated via the /api/v1/names route by the front
36
  await TGrotto.updateOne({ id: organizationId }).set(cleanedData);
1✔
37

38
  const updatedOrganization =
39
    await GrottoService.getPopulatedOrganization(organizationId);
1✔
40

41
  await NotificationService.notifySubscribers(
1✔
42
    req,
43
    updatedOrganization,
44
    req.token.id,
45
    NotificationService.NOTIFICATION_TYPES.UPDATE,
46
    NotificationService.NOTIFICATION_ENTITIES.ORGANIZATION
47
  );
48

49
  return ControllerService.treatAndConvert(
1✔
50
    req,
51
    null,
52
    updatedOrganization,
53
    { controllerMethod: 'OrganizationController.update' },
54
    res,
55
    toOrganization
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