Skip to content
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

feat(27): passion feed #82

Merged
merged 4 commits into from
May 15, 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
11 changes: 11 additions & 0 deletions src/server-extension/model/passion.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Field, ObjectType } from 'type-graphql';

@ObjectType()
export class PassionFeedEntity {
@Field(() => String)
id!: string

constructor(props: Partial<PassionFeedEntity>) {
Object.assign(this, props);
}
}
4 changes: 4 additions & 0 deletions src/server-extension/query/nft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const passionQuery = `SELECT DISTINCT ne.issuer as id
FROM nft_entity ne
WHERE ne.current_owner = $1
AND ne.current_owner != ne.issuer`
2 changes: 2 additions & 0 deletions src/server-extension/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SeriesResolver } from './series'
import { SpotlightResolver } from './spotlight'
import { CollectionChartResolver } from './collectionChart'
import { CollectionEventResolver } from './collectionEvent'
import { PassionFeedResolver } from "./passionFeed";

@ObjectType()
export class Hello {
Expand Down Expand Up @@ -35,4 +36,5 @@ export {
SeriesResolver,
SpotlightResolver,
CollectionEventResolver,
PassionFeedResolver,
}
20 changes: 20 additions & 0 deletions src/server-extension/resolvers/passionFeed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Arg, Field, ObjectType, Query, Resolver, FieldResolver, Root } from 'type-graphql'
import type { EntityManager } from 'typeorm'
import { NFTEntity } from '../../model/generated'
import { PassionFeedEntity } from '../model/passion.model'
import { passionQuery } from "../query/nft";
import { makeQuery } from "../utils";

@Resolver()
export class PassionFeedResolver {
constructor(private tx: () => Promise<EntityManager>) { }

@Query(() => [PassionFeedEntity])
async passionFeed(
@Arg('account', { nullable: false, }) account: string
): Promise<[PassionFeedEntity]> {
const result: [PassionFeedEntity] = await makeQuery(this.tx, NFTEntity, passionQuery, [account])

return result
}
}