Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

add collection in lastEvent #64

Merged
merged 1 commit into from
Sep 20, 2022
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
10 changes: 8 additions & 2 deletions src/server-extension/model/event.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LastEventEntity>) {
Object.assign(this, props);
Expand Down
9 changes: 6 additions & 3 deletions src/server-extension/query/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;