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

hicommonwealth / commonwealth / 13845955660

13 Mar 2025 10:37PM UTC coverage: 43.588% (-1.1%) from 44.638%
13845955660

Pull #11430

github

web-flow
Merge 384ed128b into 54d5b089a
Pull Request #11430: Allow delete contest

1384 of 3534 branches covered (39.16%)

Branch coverage included in aggregate %.

1 of 9 new or added lines in 1 file covered. (11.11%)

219 existing lines in 24 files now uncovered.

2606 of 5620 relevant lines covered (46.37%)

37.7 hits per line

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

0.0
/libs/model/src/aggregates/thread/GetThreadsByIds.query.ts
1
import { InvalidInput, Query } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { Op } from 'sequelize';
4
import { z } from 'zod';
5
import { models, sequelize } from '../../database';
6

7
export function GetThreadsByIds(): Query<typeof schemas.GetThreadsByIds> {
8
  return {
UNCOV
9
    ...schemas.GetThreadsByIds,
×
10
    auth: [],
11
    secure: false,
12
    body: async ({ payload }) => {
13
      const { community_id, thread_ids } = payload;
14
      if (thread_ids === '') return [];
×
UNCOV
15

×
16
      let parsedThreadIds: number[];
17

18
      try {
19
        parsedThreadIds = z
×
UNCOV
20
          .string()
×
21
          .transform((ids) =>
22
            ids.split(',').map((id) => parseInt(id.trim(), 10)),
UNCOV
23
          )
×
24
          .parse(thread_ids);
25
      } catch (e) {
26
        throw new InvalidInput('Invalid thread_ids format');
UNCOV
27
      }
×
28

29
      const threads = await models.Thread.findAll({
30
        where: {
UNCOV
31
          ...(community_id && { community_id }),
×
UNCOV
32
          id: { [Op.in]: parsedThreadIds },
×
33
        },
34

×
35
        include: [
36
          {
37
            model: models.Address,
38
            as: 'Address',
39
            include: [
40
              {
41
                model: models.User,
42
                as: 'User',
43
                required: true,
44
                attributes: ['id', 'profile'],
45
              },
46
            ],
47
          },
48
          {
49
            model: models.Address,
50
            as: 'collaborators',
51
            include: [
52
              {
53
                model: models.User,
54
                as: 'User',
55
                required: true,
56
                attributes: ['id', 'profile'],
57
              },
58
            ],
59
          },
60
          {
61
            model: models.Topic,
62
            as: 'topic',
63
            required: true,
64
          },
65
          {
66
            model: models.Reaction,
67
            as: 'reactions',
68
            include: [
69
              {
70
                model: models.Address,
71
                as: 'Address',
72
                required: true,
73
                include: [
74
                  {
75
                    model: models.User,
76
                    as: 'User',
77
                    required: true,
78
                    attributes: ['id', 'profile'],
79
                  },
80
                ],
81
              },
82
            ],
83
          },
84
          {
85
            model: models.ContestAction,
86
            where: {
87
              action: 'upvoted',
88
            },
89
            required: false,
90
            attributes: ['content_id', 'thread_id'],
91
            include: [
92
              {
93
                model: models.Contest,
94
                on: {
95
                  contest_id: sequelize.where(
96
                    sequelize.col('"ContestActions".contest_id'),
97
                    '=',
98
                    sequelize.col('"ContestActions->Contest".contest_id'),
99
                  ),
100
                  contest_address: sequelize.where(
101
                    sequelize.col('"ContestActions".contest_address'),
102
                    '=',
103
                    sequelize.col('"ContestActions->Contest".contest_address'),
104
                  ),
105
                },
106
                attributes: [
107
                  'contest_id',
108
                  'contest_address',
109
                  'score',
110
                  'start_time',
111
                  'end_time',
112
                ],
113
                include: [
114
                  {
115
                    model: models.ContestManager,
116
                    attributes: ['name', 'cancelled', 'interval'],
117
                  },
118
                ],
119
              },
120
            ],
121
          },
122
          {
123
            model: models.ThreadVersionHistory,
124
          },
125
        ],
126
      });
127

128
      return threads.map(
129
        (t) => t.toJSON() as z.infer<typeof schemas.ThreadView>,
130
      );
131
    },
132
  };
133
}
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