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

hicommonwealth / commonwealth / 17754204432

16 Sep 2025 04:08AM UTC coverage: 37.656%. Remained the same
17754204432

push

github

web-flow
Integrated postcoin display with launchpad tokens display in explore page (#12992)

* integrated postcoin display with launchpad tokens display in explore page views

* fix

1949 of 5590 branches covered (34.87%)

Branch coverage included in aggregate %.

0 of 14 new or added lines in 2 files covered. (0.0%)

6 existing lines in 2 files now uncovered.

3438 of 8716 relevant lines covered (39.44%)

45.01 hits per line

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

0.0
/libs/model/src/aggregates/token/GetTokenStats.query.ts
1
import { type Query } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { QueryTypes } from 'sequelize';
4
import { models } from '../../database';
5

6
export function GetTokenStats(): Query<typeof schemas.GetTokenStats> {
7
  return {
×
8
    ...schemas.GetTokenStats,
9
    auth: [],
10
    secure: false,
11
    async body({ payload }) {
12
      const { token_address } = payload;
×
13

NEW
14
      const tokenTypeQuery = `
×
15
        SELECT 
16
          CASE 
17
            WHEN EXISTS(SELECT 1 FROM "LaunchpadTokens" WHERE token_address = :token_address) 
18
            THEN 'launchpad'
19
            WHEN EXISTS(SELECT 1 FROM "ThreadTokens" WHERE token_address = :token_address)
20
            THEN 'postcoin'
21
            ELSE 'unknown'
22
          END as token_type
23
      `;
24

NEW
25
      const [tokenTypeRow] = await models.sequelize.query<{
×
26
        token_type: string;
27
      }>(tokenTypeQuery, {
28
        replacements: { token_address },
29
        type: QueryTypes.SELECT,
30
      });
31

NEW
32
      const tokenType = tokenTypeRow?.token_type;
×
33

NEW
34
      if (tokenType === 'unknown') {
×
NEW
35
        return {
×
36
          holder_count: 0,
37
          volume_24h: 0,
38
        };
39
      }
40

41
      const sql =
NEW
42
        tokenType === 'launchpad'
×
43
          ? `
44
        SELECT
45
          COUNT(DISTINCT trader_address) AS holder_count,
46
          COALESCE(
47
            SUM(
48
              CASE 
49
                WHEN timestamp >= EXTRACT(EPOCH FROM CURRENT_TIMESTAMP - INTERVAL '24 hours')
50
                THEN price * community_token_amount 
51
                ELSE 0 
52
              END
53
            ),
54
            0
55
          ) AS volume_24h
56
        FROM "LaunchpadTrades" 
57
        WHERE token_address = :token_address
58
      `
59
          : `
60
        SELECT
61
          COUNT(DISTINCT trader_address) AS holder_count,
62
          COALESCE(
63
            SUM(
64
              CASE 
65
                WHEN timestamp >= EXTRACT(EPOCH FROM CURRENT_TIMESTAMP - INTERVAL '24 hours')
66
                THEN price * community_token_amount 
67
                ELSE 0 
68
              END
69
            ),
70
            0
71
          ) AS volume_24h
72
        FROM "ThreadTokenTrades" 
73
        WHERE token_address = :token_address
74
      `;
75

UNCOV
76
      const [row] = await models.sequelize.query<{
×
77
        holder_count: number;
78
        volume_24h: string;
79
      }>(sql, {
80
        replacements: { token_address },
81
        type: QueryTypes.SELECT,
82
      });
83

UNCOV
84
      return {
×
85
        holder_count: parseInt(row?.holder_count as unknown as string) || 0,
×
86
        volume_24h: parseFloat(row?.volume_24h || '0'),
×
87
      };
88
    },
89
  };
90
}
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