Skip to content

Commit

Permalink
Update marketplace data
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Sep 21, 2023
1 parent 0e72dab commit 712c1f6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
9 changes: 7 additions & 2 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ input AddLikeArgs {
type AnalyticsAggregateValue {
avg: Float
count: Float
marketplacesData: [KeyValueType]
marketplacesData: [MarketplaceData]
max: Float
min: Float
series: String
Expand Down Expand Up @@ -823,7 +823,7 @@ input IssueCollectionArgs {
}

type KeyValueType {
key: String
key: String!
value: String
}

Expand All @@ -840,6 +840,11 @@ type Marketplace {
url: String!
}

type MarketplaceData {
key: String!
value: Float
}

type MarketplaceEdge {
cursor: String
node: Marketplace
Expand Down
37 changes: 24 additions & 13 deletions src/modules/analytics/models/analytics-aggregate-value.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, Float, ObjectType } from '@nestjs/graphql';
import { Field, Float, Int, ObjectType } from '@nestjs/graphql';
import * as moment from 'moment';
import { KeyValueType } from 'src/modules/assets/models';

Expand All @@ -24,8 +24,8 @@ export class AnalyticsAggregateValue {

@Field(() => Float, { nullable: true })
avg?: number;
@Field(() => [KeyValueType], { nullable: 'itemsAndList' })
marketplacesData: KeyValueType[];
@Field(() => [MarketplaceData], { nullable: 'itemsAndList' })
marketplacesData: MarketplaceData[];

constructor(init?: Partial<AnalyticsAggregateValue>) {
Object.assign(this, init);
Expand Down Expand Up @@ -58,21 +58,32 @@ export class AnalyticsAggregateValue {
time: moment.utc(row.timestamp ?? row.time).format('yyyy-MM-DD HH:mm:ss'),
value: row.value ?? 0,
marketplacesData: [
new KeyValueType({ key: rowProperties.xoxno, value: row.xoxno }),
new KeyValueType({ key: rowProperties.frameit, value: row.frameit }),
new KeyValueType({ key: rowProperties.deadrare, value: row.deadrare }),
new KeyValueType({ key: rowProperties.elrondapes, value: row.elrondapes }),
new KeyValueType({ key: rowProperties.elrondnftswap, value: row.elrondnftswap }),
new KeyValueType({ key: rowProperties.eneftor, value: row.eneftor }),
new KeyValueType({ key: rowProperties.hoghomies, value: row.hoghomies }),
new KeyValueType({ key: rowProperties.holoride, value: row.holoride }),
new KeyValueType({ key: rowProperties.aquaverse, value: row.aquaverse }),
new KeyValueType({ key: rowProperties.ici, value: row.ici }),
new MarketplaceData({ key: rowProperties.xoxno, value: row.xoxno }),
new MarketplaceData({ key: rowProperties.frameit, value: row.frameit }),
new MarketplaceData({ key: rowProperties.deadrare, value: row.deadrare }),
new MarketplaceData({ key: rowProperties.elrondapes, value: row.elrondapes }),
new MarketplaceData({ key: rowProperties.elrondnftswap, value: row.elrondnftswap }),
new MarketplaceData({ key: rowProperties.eneftor, value: row.eneftor }),
new MarketplaceData({ key: rowProperties.hoghomies, value: row.hoghomies }),
new MarketplaceData({ key: rowProperties.holoride, value: row.holoride }),
new MarketplaceData({ key: rowProperties.aquaverse, value: row.aquaverse }),
new MarketplaceData({ key: rowProperties.ici, value: row.ici }),
],
});
}
}

@ObjectType()
export class MarketplaceData {
@Field()
key: String;
@Field(() => Float, { nullable: true })
value: number;
constructor(init?: Partial<MarketplaceData>) {
Object.assign(this, init);
}
}

export function proxiedPropertiesOf<TObj>(obj?: TObj) {
return new Proxy(
{},
Expand Down
2 changes: 1 addition & 1 deletion src/modules/assets/models/Metadata.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class AttributeType {

@ObjectType()
export class KeyValueType {
@Field({ nullable: true })
@Field()
key: String;
@Field({ nullable: true })
value: String;
Expand Down

0 comments on commit 712c1f6

Please sign in to comment.