Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Make date range inclusive/exclusive #62

Merged
merged 3 commits into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bin/create-debits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -171,5 +173,3 @@ if (!program.yes) {
} else {
start();
}

const DOLLARS_PER_GB_BANDWIDTH = 0.05;
2 changes: 1 addition & 1 deletion lib/queries/generate-debits.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const calculateUserAmountOwedForBandwidth = function(billingPeriodStart, billing
.aggregate([
{
$match: {
timestamp: {$gte: billingPeriodStartIsoDate, $lte: billingPeriodEndIsoDate}
timestamp: {$gte: billingPeriodStartIsoDate, $lt: billingPeriodEndIsoDate}
}
},
{
Expand Down