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

hicommonwealth / commonwealth / 12752297559

13 Jan 2025 05:05PM UTC coverage: 48.424% (-0.05%) from 48.472%
12752297559

push

github

web-flow
Merge pull request #10567 from hicommonwealth/rotorsoft/refactor-select-community

Refactors select community command

1311 of 3021 branches covered (43.4%)

Branch coverage included in aggregate %.

1 of 8 new or added lines in 1 file covered. (12.5%)

2577 of 5008 relevant lines covered (51.46%)

34.9 hits per line

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

10.0
/libs/model/src/community/SelectCommunity.command.ts
1
import { InvalidInput, type Command } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { Op } from 'sequelize';
4
import { models } from '../database';
5

6
export const SelectCommunityErrors = {
28✔
7
  CommunityNotFound: 'Community not found',
8
};
9

10
export function SelectCommunity(): Command<typeof schemas.SelectCommunity> {
NEW
11
  return {
×
12
    ...schemas.SelectCommunity,
13
    auth: [],
14
    secure: true,
15
    body: async ({ actor, payload }) => {
NEW
16
      const { community_id } = payload;
×
17

NEW
18
      const community = await models.Community.findOne({
×
19
        where: { id: community_id },
20
        attributes: ['id'],
21
      });
NEW
22
      if (!community)
×
NEW
23
        throw new InvalidInput(SelectCommunityErrors.CommunityNotFound);
×
24

NEW
25
      await models.User.update(
×
26
        { selected_community_id: community_id },
27
        {
28
          where: {
29
            id: actor.user.id,
30
            selected_community_id: { [Op.ne]: community_id },
31
          },
32
        },
33
      );
34

NEW
35
      return {};
×
36
    },
37
  };
38
}
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