Skip to content

Are these numbers correct? #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"apollo-boost": "^0.4.9",
"axios": "^0.21.1",
"buefy": "^0.9.10",
"date-fns": "^2.25.0",
"echarts": "^5.2.1",
"emoji-unicode": "^2.0.1",
"file-saver": "^2.0.5",
Expand Down
62 changes: 23 additions & 39 deletions src/components/rmrk/Gallery/CollectionActivity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,24 @@

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { NFT } from '@/components/rmrk/service/scheme'
import { Interaction, NFT } from '@/components/rmrk/service/scheme'
import { after, getVolume, pairListBuyEvent } from '@/utils/math'
import { subDays } from 'date-fns'

const components = {
Money: () => import('@/components/shared/format/Money.vue'),
Money: () => import('@/components/shared/format/Money.vue')
}

@Component({components})
@Component({ components })
export default class extends Vue {
@Prop() public nfts!: NFT[];
public yesterdayDate: Date = new Date(Date.now() - 86400000);
public yesterdayDate: Date = subDays(Date.now(), 1);

get nftsEvents() {
return this.nfts.map(nft => nft.events)
get saleEvents(): Interaction[] {
return this.nfts
.map(nft => nft.events)
.map(pairListBuyEvent)
.flat()
}

get collectionLength() {
Expand All @@ -64,52 +69,31 @@ export default class extends Vue {

get collectionFloorPrice() {
return Math.min(
...this.nfts
.map(nft => Number(nft.price))
.filter(price => price > 0)
...this.nfts.map(nft => Number(nft.price)).filter(price => price > 0)
)
}

get collectionSoldedNFT() {
return this.nfts
.map(nft => nft.price)
.filter(price => price === '0').length
return this.nfts.map(nft => nft.price).filter(price => price === '0')
.length
}

get collectionTradedVol() {
return this.nfts
.map(nft => nft.events.filter((e: { interaction: string; }) => e.interaction === 'BUY'))
.map(nft =>
nft.events.filter(
(e: { interaction: string }) => e.interaction === 'BUY'
)
)
.filter(arr => arr.length).length
}

get collectionTradedVolumeNumber() {
const sum = this.nftsEvents
.map(event => event.filter((e: { interaction: string; }) => e.interaction === 'BUY'))
.map((item, key) => {
return (
item.length &&
this.nftsEvents[key].find((e: { interaction: string; }) => e.interaction === 'LIST').meta
)
})
.reduce((a, b) => Number(a) + Number(b), 0)
return sum
get collectionTradedVolumeNumber(): bigint {
return getVolume(this.saleEvents)
}

get collectionDailyTradedVolumeNumber() {
const sum = this.nftsEvents
.map(event => event.filter((e: { interaction: string; timestamp: Date }) => {
return (
e.interaction === 'BUY' && new Date(e.timestamp) >= this.yesterdayDate
)
}))
.map((item, key) => {
return (
item.length &&
this.nftsEvents[key].find((e: { interaction: string; }) => e.interaction === 'LIST').meta
)
})
.reduce((a, b) => Number(a) + Number(b), 0)
return sum
get collectionDailyTradedVolumeNumber(): bigint {
return getVolume(this.saleEvents.filter(after(this.yesterdayDate)))
}
}
</script>
Loading