Skip to content

Commit

Permalink
Fix some list warnings for Netlify build
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcorbalan committed Jan 4, 2021
1 parent 059d592 commit 458c6ea
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 35 deletions.
6 changes: 0 additions & 6 deletions src/components/PollDetails/data.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { request } from 'graphql-request'
import { BigNumber } from 'bignumber.js'
import { getPollVotersRegistries, getStakedByPoll, stakedByAddress, msToSeconds, getVotersSnapshots } from '../../utils'

const GOVERNANCE_API_URI = process.env.REACT_APP_GRAPH_HTTP
const MKR_API_URI = process.env.REACT_APP_MKR_GRAPH_HTTP

const fetchQuery = (url, query, variables) => request(url, query, variables)

export const getPollVotersPerOption = poll => {
return poll.votes.reduce((acum, el) => {
const option = acum[el.option] || []
Expand Down
25 changes: 1 addition & 24 deletions src/containers/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react'
import HomeDetail from '../../components/Home/HomeDetail'

import { DEFAULT_FETCH_ROWS } from '../../constants'
import { FullLoading } from '../../components/common'
import { useQuery } from '@apollo/react-hooks'
import { GOVERNANCE_INFO_QUERY } from './queries'
Expand All @@ -11,28 +10,6 @@ import useAsyncMemo from '../../hooks/useAsyncMemo'
import useHomeData from '../../hooks/useHomeData'
import BigNumber from 'bignumber.js'

const getHomeVariables = data => {
const governance = data.governanceInfo
return {
voters: Number(governance.countProxies) + Number(governance.countAddresses) || DEFAULT_FETCH_ROWS,
}
}

const getPages = gData => {
if (!gData) {
return {
pollPages: 2,
executivesPages: 2,
}
}

const { governanceInfo } = gData
return {
pollPages: Math.ceil(Number(governanceInfo.countPolls) / 1000),
executivesPages: Math.ceil(Number(governanceInfo.countSpells) / 1000),
}
}

const Error = () => <div>ERROR: There was an error trying to fetch the data.</div>

function MakerGovernanceInfo() {
Expand Down Expand Up @@ -65,7 +42,7 @@ function MakerGovernanceInfo() {
return <FullLoading />
}

if (error || gResult.error) {
if (error || gResult.error || mkrError) {
return <Error />
}

Expand Down
2 changes: 1 addition & 1 deletion src/containers/VotingHistory/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react'
import React from 'react'
import { useQuery } from '@apollo/react-hooks'
import { PageTitle, FullLoading } from '../../components/common'
import { DEFAULT_FETCH_ROWS } from '../../constants'
Expand Down
6 changes: 2 additions & 4 deletions src/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ import {
differenceInMinutes,
differenceInHours,
differenceInDays,
differenceInWeeks,
differenceInMonths,
differenceInYears,
addHours,
addMinutes,
isBefore,
} from 'date-fns'
import { LAST_YEAR, LAST_MONTH, LAST_WEEK, LAST_DAY } from '../constants'
import store, { setCache, getCache } from './cache'
import { setCache, getCache } from './cache'

export * from './mkr-registry'

Expand Down Expand Up @@ -181,7 +180,7 @@ export const getVotersSnapshots = async voters => {
const snapshotsCache = (await getCache('accounts-snapshots-cache')) || {}

const requiredVoters = voters.reduce((acc, voter) => {
const { lastUpdate, data } = snapshotsCache[voter] || {}
const { lastUpdate } = snapshotsCache[voter] || {}
// Do not update for 1/2 hour
if (!lastUpdate || getUnixTime(addMinutes(fromUnixTime(lastUpdate), 30)) < endDate) {
return [...acc, { voter, endDate }]
Expand Down Expand Up @@ -488,7 +487,6 @@ export const getPollData = async (poll, balancesLookup) => {

// TODO - improve function naming (snapshots of acctual voting addresses)
export const getPollsBalances = async polls => {
const now = new Date()
const allVoters = Array.from(
new Set(polls.flatMap(poll => poll.votes.reduce((voters, v) => [...voters, v.voter], []))),
)
Expand Down

0 comments on commit 458c6ea

Please sign in to comment.