Skip to content

Commit

Permalink
remove slack app from web-app
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-aurele-besner committed Nov 10, 2023
1 parent 39d76b4 commit 4794936
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 409 deletions.
3 changes: 2 additions & 1 deletion web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@emotion/styled": "^11.10.6",
"@rainbow-me/rainbowkit": "^1.0.11",
"@types/next-pwa": "^5.6.4",
"faunadb": "^4.8.0",
"jsonwebtoken": "^9.0.2",
"next": "13.2.4",
"next-auth": "^4.22.1",
Expand All @@ -53,7 +54,7 @@
"react-dom": "^18.2.0",
"react-icons": "^4.11.0",
"react-merge-refs": "^2.0.1",
"slack-utility": "^0.1.28",
"ethers": "5.7.2",
"styled-components": "^6.0.0",
"viem": "^1.10.14",
"wagmi": "^1.4.2"
Expand Down
22 changes: 2 additions & 20 deletions web-app/src/pages/api/requestTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Client, FaunaHttpErrorResponseContent, query as faunaQuery } from 'faun
import { NextApiRequest, NextApiResponse } from 'next'
import { contracts } from '../../constants/contracts'
import { networks } from '../../constants/networks'
import { buildSlackStatsMessage, createStats, findStats, sendSlackMessage, updateStats } from '../../utils'
import { createStats, findStats, updateStats } from '../../utils'

type AccountType = 'github' | 'discord'

Expand Down Expand Up @@ -69,27 +69,9 @@ const incrementFaucetRequestsCount = async (address: string, accountType: Accoun
const stats = await findStats(requestDate)
console.log('stats', stats)
if (!stats || stats === null || stats.length === 0) {
const slackMessageId = await sendSlackMessage(
'Current week evm-faucet requests',
buildSlackStatsMessage('update', 1, 1)
)
await createStats(address, accountType, slackMessageId, requestDate)
await createStats(address, accountType, requestDate)
} else {
const statsFound = stats[0].data
const isExistingAddresses = statsFound.addresses.find((a: string) => a === address)
await sendSlackMessage(
'Current week evm-faucet requests',
buildSlackStatsMessage(
'update',
statsFound.requests + 1,
isExistingAddresses ? statsFound.uniqueAddresses : statsFound.uniqueAddresses + 1,
{
...statsFound.requestsByType,
[accountType]: statsFound.requestsByType[accountType] ? statsFound.requestsByType[accountType] + 1 : 1
}
),
statsFound.slackMessageId
)
await updateStats(stats[0].ref, accountType, statsFound, address)
}
}
Expand Down
9 changes: 2 additions & 7 deletions web-app/src/utils/fauna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,7 @@ export const findStats = async (
return stats
}

export const createStats = async (
address: string,
accountType: string,
slackMessageId: string | undefined,
requestDate: string
) => {
export const createStats = async (address: string, accountType: string, requestDate: string) => {
await faunaDbClient
.query(
faunaQuery.Create(faunaQuery.Ref('classes/stats'), {
Expand All @@ -102,7 +97,7 @@ export const createStats = async (
[accountType]: 1
},
requestDate,
slackMessageId: slackMessageId || '',
slackMessageId: '',
createdAt: faunaQuery.Now()
}
})
Expand Down
1 change: 0 additions & 1 deletion web-app/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './fauna'
export * from './slack'
export * from './time'
78 changes: 0 additions & 78 deletions web-app/src/utils/slack.ts

This file was deleted.

Loading

0 comments on commit 4794936

Please sign in to comment.