-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add athena tables for affiliates/vaults. (#2636)
(cherry picked from commit f95f663)
- Loading branch information
1 parent
8909e2f
commit a439516
Showing
4 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_info.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
getAthenaTableCreationStatement, | ||
getExternalAthenaTableCreationStatement, | ||
castToDouble, | ||
} from '../../helpers/sql'; | ||
|
||
const TABLE_NAME: string = 'affiliate_info'; | ||
const RAW_TABLE_COLUMNS: string = ` | ||
\`address\` string, | ||
\`affiliateEarnings\` string, | ||
\`referredMakerTrades\` int, | ||
\`referredTakerTrades\` int, | ||
\`totalReferredUsers\` int, | ||
\`firstReferralBlockHeight\` bigint, | ||
\`referredTotalVolume\` string, | ||
\`totalReferredTakerFees\` string, | ||
\`totalReferredMakerFees\` string, | ||
\`totalReferredMakerRebates\` string | ||
`; | ||
const TABLE_COLUMNS: string = ` | ||
"address", | ||
${castToDouble('affiliateEarnings')}, | ||
"referredMakerTrades", | ||
"referredTakerTrades", | ||
"totalReferredUsers", | ||
"firstReferralBlockHeight", | ||
${castToDouble('referredTotalVolume')}, | ||
${castToDouble('totalReferredTakerFees')}, | ||
${castToDouble('totalReferredMakerFees')}, | ||
${castToDouble('totalReferredMakerRebates')} | ||
`; | ||
|
||
export function generateRawTable(tablePrefix: string, rdsExportIdentifier: string): string { | ||
return getExternalAthenaTableCreationStatement( | ||
tablePrefix, | ||
rdsExportIdentifier, | ||
TABLE_NAME, | ||
RAW_TABLE_COLUMNS, | ||
); | ||
} | ||
|
||
export function generateTable(tablePrefix: string): string { | ||
return getAthenaTableCreationStatement( | ||
tablePrefix, | ||
TABLE_NAME, | ||
TABLE_COLUMNS, | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_referred_users.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
getAthenaTableCreationStatement, | ||
getExternalAthenaTableCreationStatement, | ||
} from '../../helpers/sql'; | ||
|
||
const TABLE_NAME: string = 'affiliate_referred_users'; | ||
const RAW_TABLE_COLUMNS: string = ` | ||
\`referredAddress\` string, | ||
\`affiliateAddress\` string, | ||
\`referredAtBlock\` bigint | ||
`; | ||
const TABLE_COLUMNS: string = ` | ||
"referredAddress", | ||
"affiliateAddress", | ||
"referredAtBlock" | ||
`; | ||
|
||
export function generateRawTable(tablePrefix: string, rdsExportIdentifier: string): string { | ||
return getExternalAthenaTableCreationStatement( | ||
tablePrefix, | ||
rdsExportIdentifier, | ||
TABLE_NAME, | ||
RAW_TABLE_COLUMNS, | ||
); | ||
} | ||
|
||
export function generateTable(tablePrefix: string): string { | ||
return getAthenaTableCreationStatement( | ||
tablePrefix, | ||
TABLE_NAME, | ||
TABLE_COLUMNS, | ||
); | ||
} |
38 changes: 38 additions & 0 deletions
38
indexer/services/roundtable/src/lib/athena-ddl-tables/vaults.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
castToTimestamp, | ||
getAthenaTableCreationStatement, | ||
getExternalAthenaTableCreationStatement, | ||
} from '../../helpers/sql'; | ||
|
||
const TABLE_NAME: string = 'vaults'; | ||
const RAW_TABLE_COLUMNS: string = ` | ||
\`address\` string, | ||
\`clobPairId\` bigint, | ||
\`status\` string, | ||
\`createdAt\` string, | ||
\`updatedAt\` string | ||
`; | ||
const TABLE_COLUMNS: string = ` | ||
"address", | ||
"clobPairId", | ||
"status", | ||
${castToTimestamp('createdAt')}, | ||
${castToTimestamp('updatedAt')} | ||
`; | ||
|
||
export function generateRawTable(tablePrefix: string, rdsExportIdentifier: string): string { | ||
return getExternalAthenaTableCreationStatement( | ||
tablePrefix, | ||
rdsExportIdentifier, | ||
TABLE_NAME, | ||
RAW_TABLE_COLUMNS, | ||
); | ||
} | ||
|
||
export function generateTable(tablePrefix: string): string { | ||
return getAthenaTableCreationStatement( | ||
tablePrefix, | ||
TABLE_NAME, | ||
TABLE_COLUMNS, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters