From 23a7fa6db6d5c92c991d687949645e6edf16e529 Mon Sep 17 00:00:00 2001 From: Patrick Gerbes Date: Wed, 26 Apr 2017 15:44:44 -0400 Subject: [PATCH 1/2] Make date range inclusive/exclusive --- lib/queries/generate-debits.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/queries/generate-debits.js b/lib/queries/generate-debits.js index c8a6e38..9b5bd94 100644 --- a/lib/queries/generate-debits.js +++ b/lib/queries/generate-debits.js @@ -166,7 +166,7 @@ const calculateUserAmountOwedForBandwidth = function(billingPeriodStart, billing .aggregate([ { $match: { - timestamp: {$gte: billingPeriodStartIsoDate, $lte: billingPeriodEndIsoDate} + timestamp: {$gte: billingPeriodStartIsoDate, $lt: billingPeriodEndIsoDate} } }, { From 24d17ec3ec8742bd88c57c52396dacbdcfd97da1 Mon Sep 17 00:00:00 2001 From: Patrick Gerbes Date: Thu, 27 Apr 2017 15:23:43 -0400 Subject: [PATCH 2/2] Update to use cent based units --- bin/create-debits.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/create-debits.js b/bin/create-debits.js index e0a576f..36f4086 100644 --- a/bin/create-debits.js +++ b/bin/create-debits.js @@ -6,6 +6,8 @@ const program = require('commander'); const rl = require('readline'); const Storage = require('storj-service-storage-models'); const BillingClient = require('../lib/utils/billing-client'); +const CENTS_PER_GB_BANDWIDTH = 5.0; +const CENTS_PER_GB_HOUR_STORAGE = 0.002054795; program .version('0.0.1') @@ -109,10 +111,10 @@ function start() { logger.debug("Starting to create debits for date range %s", timestampRange); const bandwidthDebitPromise = generateDebits - .forBandwidth(beginTimestamp, endTimestamp, DOLLARS_PER_GB_BANDWIDTH) + .forBandwidth(beginTimestamp, endTimestamp, CENTS_PER_GB_BANDWIDTH) .then(() => logger.debug(`... ${timestampRange} forBandwidth done!`)); const storageDebitPromise = generateDebits - .forStorage(beginTimestamp, endTimestamp, DOLLARS_PER_GB_HOUR_STORAGE) + .forStorage(beginTimestamp, endTimestamp, CENTS_PER_GB_HOUR_STORAGE) .then(() => logger.debug(`... ${timestampRange} forStorage done!`)); logger.debug(`Kicking off debit calculation for ${timestampRange}`); @@ -171,5 +173,3 @@ if (!program.yes) { } else { start(); } - -const DOLLARS_PER_GB_BANDWIDTH = 0.05;