Skip to content

Commit

Permalink
Merge branch 'main' into 3586-add-unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
petersopko authored Aug 8, 2022
2 parents 3516ba9 + 80cd71e commit 0bb667a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 26 deletions.
34 changes: 17 additions & 17 deletions components/rmrk/Gallery/CollectionActivity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ import {
Interaction,
CollectionEventsStats,
} from '@/components/rmrk/service/scheme'
import { after, getVolume, pairListBuyEvent } from '@/utils/math'
import { after, getVolume } from '@/utils/math'
import { subDays } from 'date-fns'
import PrefixMixin from '~/utils/mixins/prefixMixin'
import collectionStatsById from '@/queries/collectionStatsById.graphql'
import collectionStatsById from '@/queries/subsquid/rmrk/collectionStatsById.graphql'
import collectionBuyEventStatsById from '@/queries/rmrk/subsquid/collectionBuyEventStatsById.graphql'
import { notificationTypes, showNotification } from '@/utils/notification'
Expand Down Expand Up @@ -104,11 +104,9 @@ export default class CollectionActivity extends mixins(PrefixMixin) {
totalPurchases = 0
highestBuyPrice = 0
public created(): void {
// this.fetchBuyEvents()
}
async fetch() {
this.fetchBuyEvents()
if (!this.id) {
this.$consola.warn('CollectionActivity: id is not defined')
return
Expand All @@ -117,7 +115,7 @@ export default class CollectionActivity extends mixins(PrefixMixin) {
const { data } = await this.$apollo
.query({
query: collectionStatsById,
client: this.urlPrefix,
client: this.client,
variables: {
id: this.id,
},
Expand All @@ -131,18 +129,20 @@ export default class CollectionActivity extends mixins(PrefixMixin) {
this.$consola.log('stats is null')
return
}
const {
stats: { listed, base, sales },
} = data
this.stats = {
listedCount: data.stats.listed.count,
collectionLength: data.stats.base.count,
collectionFloorPrice: data.stats.listed.aggregates.floor.value,
uniqueOwnerCount: data.stats.base.aggregates.distinctCount.currentOwner,
differentOwnerCount: data.stats.base.nfts.filter(this.differentOwner)
listedCount: data.stats.listed.length,
collectionLength: data.stats.base.length,
collectionFloorPrice: Math.min(
...listed.map((item) => parseInt(item.price))
),
uniqueOwnerCount: [...new Set(base.map((item) => item.currentOwner))]
.length,
saleEvents: data.stats.base.nfts
.map((nft) => nft.events)
.map(pairListBuyEvent)
.flat(),
differentOwnerCount: base.filter(this.differentOwner).length,
saleEvents: sales.map((nft) => nft.events).flat(),
}
}
Expand Down Expand Up @@ -188,7 +188,7 @@ export default class CollectionActivity extends mixins(PrefixMixin) {
stats: CollectionEventsStats[]
}>({
query: collectionBuyEventStatsById,
client: 'subsquid',
client: this.client,
variables: {
id: this.id,
},
Expand Down
7 changes: 2 additions & 5 deletions components/rmrk/Gallery/CollectionDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<script lang="ts">
import { Component, Prop, Vue } from 'nuxt-property-decorator'
import { Interaction, NFT } from '@/components/rmrk/service/scheme'
import { getVolume, pairListBuyEvent } from '@/utils/math'
import { getVolume } from '@/utils/math'
const components = {
Money: () => import('@/components/shared/format/Money.vue'),
Expand All @@ -64,10 +64,7 @@ export default class CollectionDetail extends Vue {
@Prop() public name!: string
get saleEvents(): Interaction[] {
return this.nfts
.map((nft) => nft.events)
.map(pairListBuyEvent)
.flat()
return this.nfts.map((nft) => nft.events).flat()
}
get collectionLength(): number {
Expand Down
6 changes: 4 additions & 2 deletions components/rmrk/Gallery/CollectionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
</div>
</div>

<!-- <div v-if="id" class="column is-6-tablet is-7-desktop is-8-widescreen">
<div
v-if="id && urlPrefix === 'rmrk'"
class="column is-6-tablet is-7-desktop is-8-widescreen">
<CollectionActivity :id="id" />
</div> -->
</div>

<div class="column has-text-right">
<Sharing
Expand Down
5 changes: 3 additions & 2 deletions components/shared/format/Money.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import ChainMixin from '@/utils/mixins/chainMixin'
limit: number,
disableFilter: boolean
) {
const number = Number(value.replace(/,/g, ''))
if (disableFilter) {
return parseFloat(value)
return parseFloat(number.toString())
}
const number = Number(value.replace(/,/g, ''))
const hasDecimals = number % 1 !== 0
// `undefined` params in toLocaleString() means use host default language
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#using_options
Expand Down
3 changes: 3 additions & 0 deletions queries/subsquid/general/collectionListWithSearch.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ query collectionListWithSearch(
price
burned
currentOwner
events(where: { interaction_eq: BUY }) {
meta
}
}
}
stats: collectionEntitiesConnection(
Expand Down
20 changes: 20 additions & 0 deletions queries/subsquid/rmrk/collectionStatsById.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
query collectionStatsById($id: ID!) {
stats: collectionEntityById(id: $id) {
id
base: nfts {
currentOwner
issuer
}
listed: nfts(where: { price_gt: "0"}) {
id
price
}
sales: nfts(where: { events_some: { interaction_eq: BUY} }) {
id
events(where: { interaction_eq: BUY}) {
id,
meta
}
}
}
}

0 comments on commit 0bb667a

Please sign in to comment.