Skip to content

Commit

Permalink
Merge branch 'dev' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Sep 23, 2024
2 parents 7c79327 + 3a37579 commit 4d8f301
Show file tree
Hide file tree
Showing 17 changed files with 315 additions and 91 deletions.
3 changes: 1 addition & 2 deletions docker-compose-hasura.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.6'
services:
postgres:
image: postgres:15
Expand Down Expand Up @@ -29,7 +28,7 @@ services:
## uncomment next line to set an admin secret
HASURA_GRAPHQL_ADMIN_SECRET: z6KTncr37daLn5Vq
HASURA_GRAPHQL_METADATA_DEFAULTS: '{"backend_configs":{"dataconnector":{"athena":{"uri":"http://data-connector-agent:8081/api/v1/athena"},"mariadb":{"uri":"http://data-connector-agent:8081/api/v1/mariadb"},"mysql8":{"uri":"http://data-connector-agent:8081/api/v1/mysql"},"oracle":{"uri":"http://data-connector-agent:8081/api/v1/oracle"},"snowflake":{"uri":"http://data-connector-agent:8081/api/v1/snowflake"}}}}'
HASURA_GRAPHQL_JWT_SECRET: '{"type": "RS256", "key": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAu4H5cKl1P1wnZB9mUgLjUAtyA7kmlzlJwXwUBwPIInxP3kKWJIF8\no4oW4EO5d75qeRjUueYPVh6WCe0OHrOyoFNcd0VsTkuYVMyXlPYlQM1HmBA64b5r\nC7nmr+mk4xlBE6i3EPx1kQAUJTR147WqeFvS3PeWaQVwocffb1KZjfVks3+3WOYA\nNkxoYiDmxGwi+MShzOSyvYizxBHPFm8WgTUhHWPiBCHkX+CRXlz3R7k2nDVxnD7s\nnDDJ8ITxxeY3DJVH4qvARNE+cbFyLbQsmnw72zzsBQmuTt7qLXdQlEmYxxgBZceE\nilkPJOtV11LM/S/CzZOkYZg+Df2F9+PggwIDAQAB\n-----END RSA PUBLIC KEY-----"}'
HASURA_GRAPHQL_JWT_SECRET: '{"type": "RS256", "key": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAs4q6OBeCTUhVWUTGa3+uw7d2lWbPrIKjU2hvSlvOQE1SIK0AtUP+\nTagi2xIQpNj05j+yb8hh2fX0SqcWmTBGkZksMecesThpYd+YQ30yDHGoI8F70l8D\nRbytmO6habfPqjx1qvXYUscyWycDZyEM0KIxvgQhhR/Nf1CfReIMHmFQtgmTIRnZ\n6nwHXVrHBbVN5LtUYuY4QNpILgwDH0mJAQ0//Fasr0vq5WwkEHlJ5Grzv1jkl6Y8\nERvaNhfvh4vm2lSiS6RkwgWB6wvdNKy2j1AxKmHl2Xdt9aoGsqC5G8nvrmICeEgL\nFTMpJ+nswMIpDqSmYhoraMmnUqoAvNegNwIDAQAB\n-----END RSA PUBLIC KEY-----"}'
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: 'anonymous'
ACTION_API_DOMAIN: 'http://172.27.10.137:3000'
# HASURA_GRAPHQL_ENABLED_APIS: graphql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ select_permissions:
- revoked_timestamp
- roles
- signup_methods
- ton_wallet_address
- updated_at
- wallet_address
computed_fields:
Expand All @@ -109,6 +110,7 @@ update_permissions:
- gender
- nickname
- picture
- ton_wallet_address
- wallet_address
filter:
id:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: top_creator_donate
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: top_user_donate
schema: public
129 changes: 65 additions & 64 deletions hasura/metadata/query_collections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,70 +1077,6 @@
}
}
}
- name: User - Get Profile
query: |
query GetUserProfile {
authorizer_users(limit: 1) {
id
email
email_verified_at
bio
birthdate
gender
active_wallet_address: active_evm_address
wallet_address
nickname
picture
signup_methods
levels {
xp
level
user_level_chain {
id
name
punkga_config
}
}
authorizer_users_user_wallet {
address
}
user_quests_aggregate {
aggregate {
count
}
}
user_quests(order_by: {created_at:desc}, limit: 20) {
created_at
status
user_quest_rewards {
tx_hash
}
quest {
id
name
quests_campaign {
campaign_chain {
punkga_config
}
}
quests_i18n {
id
quest_id
language_id
data
i18n_language {
id
description
icon
is_main
symbol
}
}
reward
}
}
}
}
- name: Public - query artwork by creator
query: |
query artworks ($creator_id: Int!, $limit: Int = 10, $offset: Int = 0) {
Expand Down Expand Up @@ -1469,3 +1405,68 @@
}
}
}
- name: User - Get Profile
query: |
query GetUserProfile {
authorizer_users(limit: 1) {
id
email
email_verified_at
bio
birthdate
gender
active_wallet_address: active_evm_address
wallet_address
ton_wallet_address
nickname
picture
signup_methods
levels {
xp
level
user_level_chain {
id
name
punkga_config
}
}
authorizer_users_user_wallet {
address
}
user_quests_aggregate {
aggregate {
count
}
}
user_quests(order_by: {created_at:desc}, limit: 20) {
created_at
status
user_quest_rewards {
tx_hash
}
quest {
id
name
quests_campaign {
campaign_chain {
punkga_config
}
}
quests_i18n {
id
quest_id
language_id
data
i18n_language {
id
description
icon
is_main
symbol
}
}
reward
}
}
}
}
12 changes: 12 additions & 0 deletions hasura/migrations/punkga-pg/1726730858341_top_user_donate/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE VIEW "public"."top_user_donate" AS
-- SELECT
-- telegram_users.username,
-- telegram_users.user_id,
-- donate_history.telegram_id,
-- sum(donate_history.value) AS value
-- FROM donate_history
-- INNER JOIN telegram_users on telegram_users.telegram_id = donate_history.telegram_id
-- GROUP BY telegram_users.username,telegram_users.user_id,donate_history.telegram_id
-- LIMIT 10;
10 changes: 10 additions & 0 deletions hasura/migrations/punkga-pg/1726730858341_top_user_donate/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE OR REPLACE VIEW "public"."top_user_donate" AS
SELECT
telegram_users.username,
telegram_users.user_id,
donate_history.telegram_id,
sum(donate_history.value) AS value
FROM donate_history
INNER JOIN telegram_users on telegram_users.telegram_id = donate_history.telegram_id
GROUP BY telegram_users.username,telegram_users.user_id,donate_history.telegram_id
LIMIT 10;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE
-- OR REPLACE VIEW "public"."top_creator_donate" AS
-- SELECT
-- creators.id,
-- creators.email,
-- creators.name,
-- creators.avatar_url,
-- sum(donate_history.value) AS value
-- FROM
-- (
-- donate_history
-- JOIN creators ON (
-- (
-- creators.id = donate_history.creator_id
-- )
-- )
-- )
-- GROUP BY
-- creators.id,
-- creators.email,
-- creators.name,
-- creators.avatar_url
-- LIMIT
-- 10;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE
OR REPLACE VIEW "public"."top_creator_donate" AS
SELECT
creators.id,
creators.email,
creators.name,
creators.avatar_url,
sum(donate_history.value) AS value
FROM
(
donate_history
JOIN creators ON (
(
creators.id = donate_history.creator_id
)
)
)
GROUP BY
creators.id,
creators.email,
creators.name,
creators.avatar_url
LIMIT
10;
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"."authorizer_users" add column "ton_wallet_address" text
-- null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."authorizer_users" add column "ton_wallet_address" text
null;
20 changes: 20 additions & 0 deletions src/modules/telegram/telegram.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,24 @@ export class TelegramController {
createAndLink() {
return this.telegramSvc.createAndLink();
}

@UseGuards(AuthGuard, RolesGuard)
@ApiBearerAuth()
@Roles(Role.TelegramUser)
@Post('get-top-donate')
@UseInterceptors(AuthUserInterceptor)
@ApiOperation({ summary: '' })
getTopDonate() {
return this.telegramSvc.getTopDonate();
}

@UseGuards(AuthGuard, RolesGuard)
@ApiBearerAuth()
@Roles(Role.TelegramUser)
@Post('get-top-creator-donate')
@UseInterceptors(AuthUserInterceptor)
@ApiOperation({ summary: '' })
getTopCreatorDonate() {
return this.telegramSvc.getTopCreatorDonate();
}
}
51 changes: 49 additions & 2 deletions src/modules/telegram/telegram.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class TelegramGraphql {
this.configSvc.get<string>('graphql.endpoint'),
'',
`query telegram_quests($telegram_user_id: Int!) {
telegram_quests {
telegram_quests(where: {activated: {_eq: true}, deleted: {_eq: false}}) {
id
quest_name
quest_url
Expand Down Expand Up @@ -205,7 +205,7 @@ export class TelegramGraphql {
this.configSvc.get<string>('graphql.endpoint'),
'',
`query telegram_quests($id: bigint!, $telegram_user_id: Int!) {
telegram_quests(where: {id: {_eq: $id}}) {
telegram_quests(where: {id: {_eq: $id},activated: {_eq: true}, deleted: {_eq: false}}) {
id
quest_name
quest_url
Expand Down Expand Up @@ -343,4 +343,51 @@ export class TelegramGraphql {
headers
);
}
getTopDonate() {
const headers = {
'x-hasura-admin-secret': this.configSvc.get<string>(
'graphql.adminSecret'
),
};

return this.graphqlSvc.query(
this.configSvc.get<string>('graphql.endpoint'),
'',
`query top_user_donate {
top_user_donate(limit: 10) {
user_id
telegram_id
username
value
}
}`,
'top_user_donate',
{},
headers
);
}
getTopCreatorDonate() {
const headers = {
'x-hasura-admin-secret': this.configSvc.get<string>(
'graphql.adminSecret'
),
};

return this.graphqlSvc.query(
this.configSvc.get<string>('graphql.endpoint'),
'',
`query top_creator_donate {
top_creator_donate(limit: 10) {
id
name
email
avatar_url
value
}
}`,
'top_creator_donate',
{},
headers
);
}
}
Loading

0 comments on commit 4d8f301

Please sign in to comment.