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

hicommonwealth / commonwealth / 13727641600

07 Mar 2025 07:13PM UTC coverage: 45.197% (-0.6%) from 45.755%
13727641600

Pull #11259

github

web-flow
Merge 865a0bd6a into a53d0f274
Pull Request #11259: Added in async count cache

1313 of 3223 branches covered (40.74%)

Branch coverage included in aggregate %.

4 of 13 new or added lines in 4 files covered. (30.77%)

151 existing lines in 13 files now uncovered.

2517 of 5251 relevant lines covered (47.93%)

38.24 hits per line

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

2.63
/libs/model/src/contest/UpdateContestManagerFrameHashes.command.ts
1
import { Command } from '@hicommonwealth/core';
2
import { config, models } from '@hicommonwealth/model';
3
import * as schemas from '@hicommonwealth/schemas';
4
import { NeynarAPIClient } from '@neynar/nodejs-sdk';
5
import { Mutex } from 'async-mutex';
6
import _ from 'lodash';
7
import { Op } from 'sequelize';
8
import { mustExist } from '../middleware/guards';
9

10
const neynarMutex = new Mutex();
30✔
11

12
export function UpdateContestManagerFrameHashes(): Command<
13
  typeof schemas.UpdateContestManagerFrameHashes
14
> {
15
  return {
×
16
    ...schemas.UpdateContestManagerFrameHashes,
17
    auth: [],
18
    body: async ({ payload }) => {
19
      await neynarMutex.runExclusive(async () => {
×
20
        const contestManager = await models.ContestManager.findOne({
×
21
          where: {
22
            contest_address: payload.contest_address,
23
            cancelled: {
24
              [Op.not]: true,
25
            },
26
            ended: {
27
              [Op.not]: true,
28
            },
29
          },
30
        });
31
        mustExist('Contest Manager', contestManager);
×
32

33
        // find webhook by ID
34
        const client = new NeynarAPIClient(config.CONTESTS.NEYNAR_API_KEY!);
×
35
        const { webhook: existingCastWebhook } = await client.lookupWebhook(
×
36
          config.CONTESTS.NEYNAR_CAST_WEBHOOK_ID!,
37
        );
38
        mustExist('Neynar Webhook', existingCastWebhook);
×
39

40
        // remove and add hashes to subscription
41
        const allParentHashes = _.uniq([
×
42
          ...(existingCastWebhook?.subscription?.filters['cast.created']
×
43
            ?.parent_hashes || []),
44
          ...(existingCastWebhook?.subscription?.filters['cast.deleted']
×
45
            ?.parent_hashes || []),
46
        ])
47
          .filter((hash) => {
48
            return !(payload.frames_to_remove || []).includes(hash);
×
49
          })
50
          .concat(payload.frames_to_add || []);
×
51

52
        const subscription = {
×
53
          ...(existingCastWebhook.subscription?.filters || {}),
×
54
          // reply cast created on parent
55
          'cast.created': {
56
            ...(existingCastWebhook.subscription?.filters['cast.created'] ||
×
57
              {}),
58
            parent_hashes: allParentHashes,
59
          },
60
          // reply cast deleted on parent
61
          'cast.deleted': {
62
            ...(existingCastWebhook.subscription?.filters['cast.deleted'] ||
×
63
              {}),
64
            parent_hashes: allParentHashes,
65
          },
66
        };
67

68
        await client.updateWebhook(
×
69
          existingCastWebhook.webhook_id,
70
          existingCastWebhook.title,
71
          existingCastWebhook.target_url,
72
          {
73
            subscription,
74
          },
75
        );
76

77
        if (!payload.webhooks_only) {
×
78
          // update contest manager frame hashes
79
          contestManager.farcaster_frame_hashes = (
×
80
            contestManager.farcaster_frame_hashes || []
×
81
          )
82
            .filter((hash) => {
UNCOV
83
              return !(payload.frames_to_remove || []).includes(hash);
×
84
            })
85
            .concat(payload.frames_to_add || []);
×
UNCOV
86
          await contestManager.save();
×
87
        }
88
      });
89
    },
90
  };
91
}
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