Skip to content

Commit

Permalink
fix watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Nov 25, 2024
1 parent 10dd578 commit 6cf7bac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
6 changes: 2 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,7 @@ export const main = async (argv: any, version?: string) => {
roundSpan,
);
} catch {
// eslint-disable-next-line no-console
console.log("bad1");
/**/
}
try {
await handleRemoveOrderbookOwnersProfileMap(
Expand All @@ -837,8 +836,7 @@ export const main = async (argv: any, version?: string) => {
roundSpan,
);
} catch {
// eslint-disable-next-line no-console
console.log("bad2");
/**/
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions src/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ export async function handleRemoveOrderbookOwnersProfileMap(
ordersDetails: SgOrder[],
span?: Span,
) {
// eslint-disable-next-line no-console
console.log("bruh");
const changes: Record<string, string[]> = {};
for (let i = 0; i < ordersDetails.length; i++) {
const orderDetails = ordersDetails[i];
Expand All @@ -231,20 +229,14 @@ export async function handleRemoveOrderbookOwnersProfileMap(
}
const orderbookOwnerProfileItem = orderbooksOwnersProfileMap.get(orderbook);
if (orderbookOwnerProfileItem) {
// eslint-disable-next-line no-console
console.log("aa1");
const ownerProfile = orderbookOwnerProfileItem.get(orderStruct.owner.toLowerCase());
if (ownerProfile) {
const x = ownerProfile.orders.delete(orderDetails.orderHash.toLowerCase());
// eslint-disable-next-line no-console
console.log("aa2", x);
ownerProfile.orders.delete(orderDetails.orderHash.toLowerCase());
}
}
}
if (span) {
for (const orderbook in changes) {
// eslint-disable-next-line no-console
console.log("aa3");
span.setAttribute(`orderbooksChanges.${orderbook}.removedOrders`, changes[orderbook]);
}
}
Expand Down
16 changes: 4 additions & 12 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ export const statusCheckQuery = `{
export const getTxsQuery = (start: number, skip: number) => {
return `{transactions(
orderBy: timestamp
orderDirection: desc
orderDirection: asc
first: 100
skip: ${skip}
where: {timestamp_gt: "${start.toString()}"}
where: { timestamp_gt: "${start}" }
) {
events {
__typename
Expand Down Expand Up @@ -292,23 +292,17 @@ export async function getOrderChanges(
if (event.__typename === "AddOrder") {
if (typeof event?.order?.active === "boolean" && event.order.active) {
if (!addOrders.find((e) => e.order.id === event.order.id)) {
addOrders.unshift({
addOrders.push({
order: event.order as SgOrder,
timestamp: Number(tx.timestamp),
});
}
}
}
if (event.__typename === "RemoveOrder") {
// eslint-disable-next-line no-console
console.log("abcd");
if (typeof event?.order?.active === "boolean" && !event.order.active) {
// eslint-disable-next-line no-console
console.log("abcd1");
if (!removeOrders.find((e) => e.order.id === event.order.id)) {
// eslint-disable-next-line no-console
console.log("abcd2");
removeOrders.unshift({
removeOrders.push({
order: event.order as SgOrder,
timestamp: Number(tx.timestamp),
});
Expand All @@ -318,7 +312,5 @@ export async function getOrderChanges(
});
}
});
// eslint-disable-next-line no-console
console.log(removeOrders);
return { addOrders, removeOrders, count };
}

0 comments on commit 6cf7bac

Please sign in to comment.