diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-12-06 04:27:32 +0800 |
---|---|---|
committer | Fred Carlsen <fred@sjelfull.no> | 2018-12-06 19:06:35 +0800 |
commit | ef1e5eacbdeed353ae98a532d10014df06741b41 (patch) | |
tree | 5bd608006fea2ed4a8e716ad37ad76585b97427a | |
parent | 7ba47c47bb33f9b7569a744600169d0cec2fee18 (diff) | |
download | dexon-sol-tools-ef1e5eacbdeed353ae98a532d10014df06741b41.tar.gz dexon-sol-tools-ef1e5eacbdeed353ae98a532d10014df06741b41.tar.zst dexon-sol-tools-ef1e5eacbdeed353ae98a532d10014df06741b41.zip |
Fix RadarRelay timestamps (#1391)
* Fixing rr timestamps
* Apply prettier
-rw-r--r-- | packages/pipeline/src/entities/sra_order_observed_timestamp.ts | 7 | ||||
-rw-r--r-- | packages/pipeline/src/scripts/pull_radar_relay_orders.ts | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/packages/pipeline/src/entities/sra_order_observed_timestamp.ts b/packages/pipeline/src/entities/sra_order_observed_timestamp.ts index cd2d41397..cbec1c6d0 100644 --- a/packages/pipeline/src/entities/sra_order_observed_timestamp.ts +++ b/packages/pipeline/src/entities/sra_order_observed_timestamp.ts @@ -22,11 +22,14 @@ export class SraOrdersObservedTimeStamp { * current time. * @param order The order to generate a timestamp for. */ -export function createObservedTimestampForOrder(order: SraOrder): SraOrdersObservedTimeStamp { +export function createObservedTimestampForOrder( + order: SraOrder, + observedTimestamp: number, +): SraOrdersObservedTimeStamp { const observed = new SraOrdersObservedTimeStamp(); observed.exchangeAddress = order.exchangeAddress; observed.orderHashHex = order.orderHashHex; observed.sourceUrl = order.sourceUrl; - observed.observedTimestamp = Date.now(); + observed.observedTimestamp = observedTimestamp; return observed; } diff --git a/packages/pipeline/src/scripts/pull_radar_relay_orders.ts b/packages/pipeline/src/scripts/pull_radar_relay_orders.ts index 6c18bcaef..40bb6fc97 100644 --- a/packages/pipeline/src/scripts/pull_radar_relay_orders.ts +++ b/packages/pipeline/src/scripts/pull_radar_relay_orders.ts @@ -33,11 +33,12 @@ async function getOrderbookAsync(): Promise<void> { // Save all the orders and update the observed time stamps in a single // transaction. console.log('Saving orders and updating timestamps...'); + const observedTimestamp = Date.now(); await connection.transaction(async (manager: EntityManager): Promise<void> => { for (const order of orders) { await manager.save(SraOrder, order); - const observedTimestamp = createObservedTimestampForOrder(order); - await manager.save(observedTimestamp); + const orderObservation = createObservedTimestampForOrder(order, observedTimestamp); + await manager.save(orderObservation); } }); } |