Skip to content

Commit

Permalink
Merge pull request DefiLlama#3656 from DefiLlama/phux
Browse files Browse the repository at this point in the history
DB timestamps
  • Loading branch information
waynebruce0x authored Jul 7, 2023
2 parents 2a1574b + 9bb009a commit 7a3f890
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
14 changes: 13 additions & 1 deletion coins/src/adapters/utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "./dbInterfaces";
import { contracts } from "../other/distressedAssets";
import { sendMessage } from "./../../../../defi/src/utils/discord";

import { batchWrite2, translateItems } from "../../../coins2";
const confidenceThreshold: number = 0.3;

export async function getTokenAndRedirectData(
Expand Down Expand Up @@ -74,6 +74,7 @@ export function addToDBWritesList(
: {}),
adapter,
confidence: Number(confidence),
timestamp,
},
],
);
Expand Down Expand Up @@ -325,6 +326,17 @@ export async function batchWriteWithAlerts(
);
await batchWrite(filteredItems, failOnError);
}
// export async function batchWrite2WithAlerts(
// items: AWS.DynamoDB.DocumentClient.PutItemInputAttributeMap[],
// ) {
// const previousItems: DbEntry[] = await readPreviousValues(items);
// const filteredItems: AWS.DynamoDB.DocumentClient.PutItemInputAttributeMap[] = await checkMovement(
// items,
// previousItems,
// );

// await batchWrite2(await translateItems(filteredItems));
// }
async function readPreviousValues(
items: AWS.DynamoDB.DocumentClient.PutItemInputAttributeMap[],
): Promise<DbEntry[]> {
Expand Down
20 changes: 14 additions & 6 deletions coins/src/storeCoins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require("dotenv").config();
import adapters from "./adapters/index";
import { batchWriteWithAlerts } from "./adapters/utils/database";
import {
batchWriteWithAlerts,
// batchWrite2WithAlerts,
} from "./adapters/utils/database";
import { filterWritesWithLowConfidence } from "./adapters/utils/database";
import { sendMessage } from "./../../defi/src/utils/discord";

Expand All @@ -27,10 +30,15 @@ export default async function handler(event: any) {
results.flat(),
);
for (let i = 0; i < resultsWithoutDuplicates.length; i += step) {
await batchWriteWithAlerts(
resultsWithoutDuplicates.slice(i, i + step),
true,
);
await Promise.all([
batchWriteWithAlerts(
resultsWithoutDuplicates.slice(i, i + step),
true,
),
// await batchWrite2WithAlerts(
// resultsWithoutDuplicates.slice(i, i + step),
// ),
]);
}
console.log(`${a[i][0]} done`);
} catch (e) {
Expand All @@ -50,7 +58,7 @@ export default async function handler(event: any) {
);
}

// ts-node coins/src/storeCoins.ts
// ts-node src/storeCoins.ts
async function main() {
let a = {
protocolIndexes: [0],
Expand Down

0 comments on commit 7a3f890

Please sign in to comment.