feat: remove graph and graph data (#308)

This commit is contained in:
Vojtech Simetka 2023-03-31 22:55:02 +02:00 committed by GitHub
parent bc0cdd97ec
commit b328e4c67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 103 deletions

View File

@ -15,7 +15,7 @@ import {
VOTE_GO_PRICE,
VOTE_REP_WIN,
} from '$lib/constants'
import { tokens, type TokenData } from '$lib/stores/tokens'
import { tokens } from '$lib/stores/tokens'
import { posts, type Post } from '$lib/stores/post'
import { transaction, type TransactionRecord } from '$lib/stores/transaction'
@ -200,42 +200,6 @@ export class InMemoryAndIPFS implements Adapter {
transaction.set({ transactions: storedTransactions })
tokens.set(storedTokens)
this.subscriptions.push(
tokens.subscribe((state) => {
let newState: TokenData | undefined = undefined
if (
state.goHistoricalValues.length === 0 ||
state.go !== state.goHistoricalValues[state.goHistoricalValues.length - 1].value
) {
newState = { ...state }
newState.goHistoricalValues.push({ timestamp: Date.now(), value: state.go })
}
if (
state.repStakedHistoricalValues.length === 0 ||
state.repStaked !==
state.repStakedHistoricalValues[state.repStakedHistoricalValues.length - 1].value
) {
if (newState === undefined) {
newState = { ...state }
}
newState.repStakedHistoricalValues.push({ timestamp: Date.now(), value: state.repStaked })
}
if (
state.repTotalHistoricalValues.length === 0 ||
state.repTotal !==
state.repTotalHistoricalValues[state.repTotalHistoricalValues.length - 1].value
) {
if (newState === undefined) {
newState = { ...state }
}
newState.repTotalHistoricalValues.push({ timestamp: Date.now(), value: state.repTotal })
}
if (newState !== undefined) {
tokens.update(() => state)
saveToLocalStorage('tokens', state)
}
}),
)
this.subscriptions.push(
transaction.subscribe(({ transactions }) => {

View File

@ -1,24 +0,0 @@
<script lang="ts">
let cls: string | undefined = undefined
export { cls as class }
interface GraphRecord {
timestamp: number
value: number
}
export let minX: number
export let maxX: number
export let minY = 0
export let maxY: number
export let values: GraphRecord[]
</script>
<div class={`root ${cls}`}>
x axis scale: {minX} - {maxX}
y axis scale: {minY} - {maxY}
values length: {values.length}
</div>
<style lang="scss">
</style>

View File

@ -1,19 +1,11 @@
import { DEFAULT_GO_AMOUNT } from '$lib/constants'
import { writable, type Writable } from 'svelte/store'
interface TokenValues {
timestamp: number
value: number
}
export interface TokenData {
go: number
repTotal: number
repStaked: number
loading: boolean
goHistoricalValues: TokenValues[]
repStakedHistoricalValues: TokenValues[]
repTotalHistoricalValues: TokenValues[]
epochDuration: number
timeToEpoch: number
}
@ -27,9 +19,6 @@ function createTokenStore(): TokenStore {
repTotal: 55,
repStaked: 0,
loading: false,
goHistoricalValues: [],
repStakedHistoricalValues: [],
repTotalHistoricalValues: [],
epochDuration,
timeToEpoch: epochDuration - (Date.now() % epochDuration),
})

View File

@ -11,7 +11,6 @@
import Select from '$lib/components/select.svelte'
import { saveToLocalStorage } from '$lib/utils'
import { startNewEpoch } from '$lib/adapters/in-memory-and-ipfs'
import { formatDateAndTime } from '$lib/utils/format'
let goTokenValue = $tokens.go.toFixed()
let repTokenValue = $tokens.repTotal.toFixed()
@ -59,35 +58,6 @@
<Button label="Update" on:click={updateTokens} />
</section>
<Divider />
<section>
<h2>GO historical values</h2>
{#each $tokens.goHistoricalValues as transaction}
<section>
{formatDateAndTime(transaction.timestamp)} |
{transaction.value} GO
</section>
{/each}
</section>
<Divider />
<section>
<h2>REP staked historical values</h2>
{#each $tokens.repStakedHistoricalValues as transaction}
<section>
{formatDateAndTime(transaction.timestamp)} |
{transaction.value} REP
</section>
{/each}
</section>
<Divider />
<section>
<h2>REP total historical values</h2>
{#each $tokens.repTotalHistoricalValues as transaction}
<section>
{formatDateAndTime(transaction.timestamp)} |
{transaction.value} REP
</section>
{/each}
</section>
{/if}
</Container>

View File

@ -20,7 +20,6 @@
import { personas } from '$lib/stores/persona'
import ProgressCircular from '$lib/components/progress-circular.svelte'
import ProgressLinear from '$lib/components/progress-linear.svelte'
import Graph from '$lib/components/graph.svelte'
import SingleColumn from '$lib/components/single-column.svelte'
import Spacer from '$lib/components/spacer.svelte'