Skip to content

Commit

Permalink
add creator wallet_address
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Apr 1, 2024
1 parent 15e8b87 commit 1723038
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ select_permissions:
- socials
- subcribers
- updated_at
- wallet_address
computed_fields:
- total_subscribers
filter: {}
Expand All @@ -52,6 +53,7 @@ select_permissions:
- socials
- subcribers
- updated_at
- wallet_address
computed_fields:
- total_subscribers
filter: {}
Expand Down
45 changes: 23 additions & 22 deletions hasura/metadata/query_collections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,28 +259,6 @@
affected_rows
}
}
- name: Admin - Query creators
query: |
query QueryCreators {
creators(order_by: {created_at:desc}) {
id
name
total_subscribers
manga_creators_aggregate {
aggregate {
count
}
}
created_at
socials
isActive
bio
avatar_url
dob
gender
pen_name
}
}
- name: Admin - Get manga detail
query: |
query GetMangaReadingDetail ($id: Int = 1) {
Expand Down Expand Up @@ -1125,3 +1103,26 @@
}
}
}
- name: Admin - Query creators
query: |
query QueryCreators {
creators(order_by: {created_at:desc}) {
id
name
total_subscribers
manga_creators_aggregate {
aggregate {
count
}
}
created_at
socials
isActive
bio
avatar_url
dob
gender
pen_name
wallet_address
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."creators" add column "wallet_address" text
-- null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."creators" add column "wallet_address" text
null;
27 changes: 14 additions & 13 deletions src/modules/creator/creator.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class CreatorGraphql {
constructor(
private configSvc: ConfigService,
private graphqlSvc: GraphqlService
) {}
) { }

queryCreatorByIdOrSlug(variables: any) {
return this.graphqlSvc.query(
Expand All @@ -26,6 +26,7 @@ export class CreatorGraphql {
socials
total_subscribers
isActive
wallet_address
created_at
manga_creators(where: {manga: {status: {_neq: "Removed"}}}) {
manga {
Expand Down Expand Up @@ -84,15 +85,15 @@ export class CreatorGraphql {
return this.graphqlSvc.query(
this.configSvc.get<string>('graphql.endpoint'),
token,
`mutation AddCreator($name: String, $bio: String, $socials: jsonb = null, $pen_name: String = "", $profile_picture: String = "", $gender: String = "", $dob: String = "", $avatar_url: String = "") {
insert_creators_one(object: {name: $name, bio: $bio, socials: $socials, pen_name: $pen_name, gender: $gender, dob: $dob, avatar_url: $avatar_url}) {
id
name
socials
created_at
bio
}
}`,
`mutation AddCreator($name: String, $bio: String, $socials: jsonb = null, $pen_name: String = "", $profile_picture: String = "", $gender: String = "", $dob: String = "", $avatar_url: String = "", $wallet_address: String = "") {
insert_creators_one(object: {name: $name, bio: $bio, socials: $socials, pen_name: $pen_name, gender: $gender, dob: $dob, avatar_url: $avatar_url, wallet_address: $wallet_address}) {
id
name
socials
created_at
bio
}
}`,
'AddCreator',
variables
);
Expand Down Expand Up @@ -134,8 +135,8 @@ export class CreatorGraphql {
return this.graphqlSvc.query(
this.configSvc.get<string>('graphql.endpoint'),
token,
`mutation UpdateCreator($name: String, $bio: String, $socials: jsonb = null, $pen_name: String = "", $gender: String = "", $dob: String = "", $avatar_url: String = "", $id: Int = 10) {
insert_creators_one(object: {name: $name, bio: $bio, socials: $socials, pen_name: $pen_name, gender: $gender, dob: $dob, avatar_url: $avatar_url, id: $id}, on_conflict: {constraint: creators_pkey, update_columns: [name, pen_name, bio, socials, gender, dob, avatar_url]}) {
`mutation UpdateCreator($name: String, $bio: String, $socials: jsonb = null, $pen_name: String = "", $gender: String = "", $dob: String = "", $avatar_url: String = "", $id: Int = 10, $wallet_address: String = "") {
insert_creators_one(object: {name: $name, bio: $bio, socials: $socials, pen_name: $pen_name, gender: $gender, dob: $dob, avatar_url: $avatar_url, id: $id, wallet_address: $wallet_address}, on_conflict: {constraint: creators_pkey, update_columns: [name, pen_name, bio, socials, gender, dob, avatar_url, wallet_address]}) {
id
name
pen_name
Expand All @@ -146,7 +147,7 @@ export class CreatorGraphql {
bio
avatar_url
}
}
}
`,
'UpdateCreator',
variables
Expand Down
6 changes: 4 additions & 2 deletions src/modules/creator/creator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class CreatorService {
) {
try {
const { token } = ContextProvider.getAuthUser();
const { name, bio, socials, pen_name, gender, dob } = data;
const { name, bio, socials, pen_name, gender, dob, wallet_address } = data;

// insert creator to DB
const result = await this.creatorGraphql.addCreator(token, {
Expand All @@ -44,6 +44,7 @@ export class CreatorService {
pen_name,
gender,
dob,
wallet_address
});

if (result.errors && result.errors.length > 0) {
Expand Down Expand Up @@ -86,7 +87,7 @@ export class CreatorService {
) {
try {
const { token } = ContextProvider.getAuthUser();
const { name, socials, pen_name, bio, gender, dob } = data;
const { name, socials, pen_name, bio, gender, dob, wallet_address } = data;

const result = await this.creatorGraphql.queryCreatorById(token, {
id: creatorId,
Expand Down Expand Up @@ -120,6 +121,7 @@ export class CreatorService {
gender,
dob,
avatar_url: avatarUrl,
wallet_address
});

return updateResult;
Expand Down
3 changes: 3 additions & 0 deletions src/modules/creator/dto/create-creator-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class CreateCreatorRequestDto {
@ApiProperty()
dob: string;

@ApiProperty()
wallet_address: string;

@ApiProperty({ type: 'string', format: 'binary' })
avatar: Express.Multer.File;
}
3 changes: 3 additions & 0 deletions src/modules/creator/dto/update-creator-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export class UpdateCreatorRequestDto {
@ApiPropertyOptional()
dob: string;

@ApiPropertyOptional()
wallet_address: string;

@ApiProperty({ type: 'string', format: 'binary' })
avatar: Express.Multer.File;
}
Expand Down

0 comments on commit 1723038

Please sign in to comment.