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

decentraland / marketplace / 9604252205

20 Jun 2024 08:55PM UTC coverage: 66.593% (+0.09%) from 66.499%
9604252205

push

github

web-flow
fix location error (#2263)

2606 of 5072 branches covered (51.38%)

Branch coverage included in aggregate %.

30 of 40 new or added lines in 7 files covered. (75.0%)

1 existing line in 1 file now uncovered.

7606 of 10263 relevant lines covered (74.11%)

77.63 hits per line

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

97.96
/webapp/src/modules/account/selectors.ts
1
import { createMatchSelector } from 'connected-react-router'
35✔
2
import { createSelector } from 'reselect'
35✔
3
import { Network } from '@dcl/schemas'
35✔
4
import { RootState } from '../reducer'
5
import { locations } from '../routing/locations'
35✔
6
import { AccountMetrics } from './types'
7
import { sumAccountMetrics } from './utils'
35✔
8

9
export const getState = (state: RootState) => state.account
35✔
10
export const getData = (state: RootState) => getState(state).data
35✔
11
export const getCreators = (state: RootState) => getState(state).creators.accounts
35✔
12
export const getCreatorsSearchQuery = (state: RootState) => getState(state).creators.search
35✔
13
export const getMetricsByNetworkByAddress = (state: RootState) => getState(state).metrics
35✔
14
export const getLoading = (state: RootState) => getState(state).loading
35✔
15
export const getError = (state: RootState) => getState(state).error
35✔
16

17
const accountMatchSelector = createMatchSelector<RootState, { address: string }>(locations.account(':address'))
35✔
18

19
export const getAddress = createSelector<RootState, ReturnType<typeof accountMatchSelector>, string | undefined>(
35✔
20
  accountMatchSelector,
NEW
21
  match => match?.params.address?.toLowerCase()
×
22
)
23

24
export const getMetricsByAddressByNetwork = createSelector(getMetricsByNetworkByAddress, metrics => {
35✔
25
  const addresses = new Set([...Object.keys(metrics.ETHEREUM), ...Object.keys(metrics.MATIC)])
1✔
26

27
  const res: Record<string, { [Network.ETHEREUM]: AccountMetrics; [Network.MATIC]: AccountMetrics }> = {}
1✔
28

29
  for (const address of addresses) {
1✔
30
    res[address] = {
3✔
31
      [Network.ETHEREUM]: metrics[Network.ETHEREUM][address],
32
      [Network.MATIC]: metrics[Network.MATIC][address]
33
    }
34
  }
35

36
  return res
1✔
37
})
38

39
export const getAggregatedMetricsByAddress = createSelector(getMetricsByAddressByNetwork, metrics => {
35✔
40
  const addresses = Object.keys(metrics)
1✔
41
  const res: Record<string, AccountMetrics> = {}
1✔
42

43
  for (const address of addresses) {
1✔
44
    const eth = metrics[address].ETHEREUM
3✔
45
    const mat = metrics[address].MATIC
3✔
46

47
    if (eth && !mat) {
3✔
48
      res[address] = eth
1✔
49
    } else if (!eth && mat) {
2✔
50
      res[address] = mat
1✔
51
    } else if (eth && mat) {
1✔
52
      res[address] = sumAccountMetrics(eth, mat)
1✔
53
    }
54
  }
55

56
  return res
1✔
57
})
58

59
export const getMetricsByAddress = createSelector(
35✔
60
  getMetricsByAddressByNetwork,
61
  getAggregatedMetricsByAddress,
62
  (metrics, aggregatedMetrics) =>
63
    Object.keys(metrics).reduce(
1✔
64
      (acc, address) => {
65
        acc[address] = {
3✔
66
          ...metrics[address],
67
          aggregated: aggregatedMetrics[address]
68
        }
69
        return acc
3✔
70
      },
71
      {} as Record<
72
        string,
73
        {
74
          [Network.ETHEREUM]: AccountMetrics
75
          [Network.MATIC]: AccountMetrics
76
          aggregated: AccountMetrics
77
        }
78
      >
79
    )
80
)
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

© 2025 Coveralls, Inc