Skip to content

Commit

Permalink
Updating per NP feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
deasydoesit committed Oct 23, 2023
1 parent 892ff03 commit 61e029e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,10 @@
{ "type": "RecipientV0", "table": "recipients", "schema": "public" }
]
}
],
"indexConfigs": [
"CREATE UNIQUE INDEX IF NOT EXISTS key_to_asset_asset_index ON key_to_assets(asset);",
"CREATE UNIQUE INDEX IF NOT EXISTS iot_hotspot_infos_asset_index ON iot_hotspot_infos(asset);",
"CREATE UNIQUE INDEX IF NOT EXISTS mobile_hotspot_infos_asset_index ON mobile_hotspot_infos(asset);"
]
}
2 changes: 0 additions & 2 deletions packages/account-postgres-sink-service/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export const PROGRAM_ACCOUNT_CONFIGS =
process.env.PROGRAM_ACCOUNT_CONFIGS ||
`${__dirname}/../program_account_configs_example.json`;

export const INDEX_CONFIGS = process.env.INDEX_CONFIGS;

export const HELIUS_AUTH_SECRET = process.env.HELIUS_AUTH_SECRET;

export const RUN_JOBS_AT_STARTUP = process.env.RUN_JOBS_AT_STARTUP === 'true';
19 changes: 6 additions & 13 deletions packages/account-postgres-sink-service/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { PublicKey } from "@solana/web3.js";
import {
HELIUS_AUTH_SECRET,
PROGRAM_ACCOUNT_CONFIGS,
INDEX_CONFIGS,
RUN_JOBS_AT_STARTUP,
} from "./env";
import database from "./utils/database";
Expand All @@ -26,22 +25,16 @@ if (!HELIUS_AUTH_SECRET) {
}

(async () => {
const configs = (() => {
const accountConfigs: null | {
const { configs, indexConfigs } = (() => {
const dbConfigs: null | {
configs: IConfig[];
indexConfigs?: string[]
} = JSON.parse(fs.readFileSync(PROGRAM_ACCOUNT_CONFIGS, "utf8"));

return accountConfigs ? accountConfigs.configs : [];
})();

const indexConfigs = (() => {
let configs: null | { configs: string[] } = null;

if (INDEX_CONFIGS) {
configs = JSON.parse(fs.readFileSync(INDEX_CONFIGS, "utf8"));
return {
configs: dbConfigs && dbConfigs.configs ? dbConfigs.configs : [],
indexConfigs: dbConfigs && dbConfigs.indexConfigs ? dbConfigs.indexConfigs : [],
}

return configs ? configs.configs : [];
})();

const customJobs = configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export const createPgIndexes = async ({
sequelize: Sequelize;
}) => {
try {
if (indexConfigs.length === 0) {
console.log("createPgIndexes: No indexes created!");
return;
}

const indexPromises = indexConfigs.map((config) => {
return sequelize.query(config);
});
Expand Down

0 comments on commit 61e029e

Please sign in to comment.