From 0a70334490ff69750008a8e0b6a4ee4436d63eb0 Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Fri, 9 Sep 2022 21:55:49 +0700 Subject: [PATCH] add collection in lastEvent --- src/server-extension/model/event.model.ts | 10 ++++++++-- src/server-extension/query/event.ts | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/server-extension/model/event.model.ts b/src/server-extension/model/event.model.ts index d44af16..af9bf3d 100644 --- a/src/server-extension/model/event.model.ts +++ b/src/server-extension/model/event.model.ts @@ -26,8 +26,14 @@ export class LastEventEntity { @Field(() => String, { nullable: true }) image!: string; - @Field(() => String, {nullable: true, name: 'animationUrl'}) - animation_url!: string | undefined | null + @Field(() => String, { nullable: true, name: 'animationUrl' }) + animation_url!: string | undefined | null; + + @Field(() => String, { nullable: false, name: 'collectionId' }) + collection_id!: string; + + @Field(() => String, { nullable: false, name: 'collectionName' }) + collection_name!: string; constructor(props: Partial) { Object.assign(this, props); diff --git a/src/server-extension/query/event.ts b/src/server-extension/query/event.ts index b0773c2..e04d0b2 100644 --- a/src/server-extension/query/event.ts +++ b/src/server-extension/query/event.ts @@ -7,14 +7,17 @@ export const lastEventQuery = `SELECT me.image as image, me.animation_url, MAX(e.timestamp) as timestamp, - MAX(e.meta) as value + MAX(e.meta) as value, + ne.collection_id as collection_id, + ce.name as collection_name FROM event e JOIN nft_entity ne on e.nft_id = ne.id LEFT join metadata_entity me on me.id = ne.metadata + LEFT JOIN collection_entity ce on ne.collection_id = ce.id WHERE e.interaction = $1 AND ne.burned = false -GROUP BY ne.id, me.id, e.current_owner, me.image +GROUP BY ne.id, me.id, e.current_owner, me.image, ce.name ORDER BY MAX(e.timestamp) DESC -LIMIT $2 OFFSET $3` +LIMIT $2 OFFSET $3`;