Skip to content

Commit

Permalink
fix chart
Browse files Browse the repository at this point in the history
  • Loading branch information
alelliott committed Jun 14, 2024
1 parent 110a15f commit bb824e5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Nounspace Dashboard</title>
<title>$SPACE Fair Launch | Nounspace</title>

<noscript>
<style>
Expand All @@ -16,12 +16,12 @@
<meta name="theme-color" content="#ffffff">

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0">
<meta name="description" content="Nounspace Dashboard">
<meta property="og:title" content="Nounspace Dashboard">
<meta property="og:description" content="Nounspace Dashboard">
<meta name="description" content="Join Nounspace, the decentralized social network. Customize your space with fidgets and smart agents. Embrace user control and community building in Web3.">
<meta property="og:title" content="Nounspace">
<meta property="og:description" content="Join Nounspace, the decentralized social network. Customize your space with fidgets and smart agents. Embrace user control and community building in Web3.">
<meta property="og:url" content="https://space.nounspace.com/">
<meta property="og:image" content="/branding/og-image.png">
<meta property="og:locale" content="en_GB">
<meta property="og:locale" content="en_US">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">

Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const initNotifications = () => {
const init = async () => {
try {
document.title = config.NAME
document.title = '$SPACE Fair Launch | Nounspace'
initNotifications()
await web3ProvidersStore.init()
Expand Down
42 changes: 23 additions & 19 deletions src/common/InfoDashboard/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function getChartData(
poolStartedAt: BigNumber,
month: number,
): Promise<ChartData> {
type QueryData = Record<`r${number}`, { totalStaked: string }[]>
type QueryData = Record<`d${number}`, { totalStaked: string }[]>
const { data } = await config.apolloClient.query<QueryData>({
query: _generateTotalStakedPerDayGraphqlQuery(poolId, poolStartedAt, month),
})
Expand All @@ -28,11 +28,11 @@ function _generateTotalStakedPerDayGraphqlQuery(
poolStartedAt: BigNumber,
month: number,
) {
const REQUEST_PATTERN = `d{{date}}:
poolInteractions(
first: 1
orderDirection: desc
where: {timestamp_lte: "{{timestamp}}", pool: "${hexlify(poolId)}"}
const REQUEST_PATTERN = (date: number, timestamp: number) => `
d${date}: poolInteractions(
first: 1,
orderDirection: desc,
where: { timestamp_lte: ${timestamp}, pool: "${hexlify(poolId)}" },
orderBy: timestamp
) {
totalStaked
Expand All @@ -42,25 +42,29 @@ function _generateTotalStakedPerDayGraphqlQuery(
const currentTime = new Time()
const poolStartedAtTime = new Time(poolStartedAt.toNumber())

const startDate = monthTime.isSame(poolStartedAtTime, 'month')
? poolStartedAtTime.get('date')
: 1
let startDate: number
let endDate: number

const endDate = currentTime.isSame(monthTime, 'month')
? currentTime.get('date')
: monthTime.dayjs.daysInMonth()
if (currentTime.isBefore(poolStartedAtTime)) {
// If the current time is before the pool start date
startDate = monthTime.isSame(poolStartedAtTime, 'month') ? poolStartedAtTime.get('date') : 1
endDate = monthTime.isSame(poolStartedAtTime, 'month') ? poolStartedAtTime.get('date') : monthTime.dayjs.daysInMonth()
} else {
// If the pool has already started
startDate = monthTime.isSame(poolStartedAtTime, 'month') ? poolStartedAtTime.get('date') : 1
endDate = monthTime.isSame(currentTime, 'month') ? currentTime.get('date') : monthTime.dayjs.daysInMonth()
}

console.log('startDate:', startDate)
console.log('endDate:', endDate)

const requests = []
for (let date = startDate; date <= endDate; date++) {
const timestamp = monthTime.timestamp + date * ONE_DAY_TIMESTAMP

// eslint-disable-next-line prettier/prettier
const request = REQUEST_PATTERN
.replace('{{date}}', date.toString())
// eslint-disable-next-line prettier/prettier
.replace('{{timestamp}}', timestamp.toString())
const timestamp = monthTime.timestamp + (date - 1) * ONE_DAY_TIMESTAMP

const request = REQUEST_PATTERN(date, timestamp)
requests.push(request)
console.log('Request added:', request)
}

return gql`
Expand Down

0 comments on commit bb824e5

Please sign in to comment.