-
Notifications
You must be signed in to change notification settings - Fork 504
Replace duplicated raw export size calculations with a shared estimator #1686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stockingstocker
wants to merge
8
commits into
OpenEnergyDashboard:development
Choose a base branch
from
stockingstocker:issue-1684
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+67
−7
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bf0a327
add shared file for raw export file size estimation and its constants
stockingstocker 8d3c72d
test importing from shared file size estimator in client and server
stockingstocker dfbedc6
remove file size estimate comments from client and server, already pr…
stockingstocker bf43178
add test for file size estimator function
stockingstocker e231842
switch chai, expect, mocha imports to use shared file
stockingstocker 5784e5d
adjust test to use stricter bounds
stockingstocker 9ebef3a
remove extraneuous export, change estimate values to be in MB instead…
stockingstocker ecc7de4
formatting adjustment
stockingstocker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| /** | ||
| * Estimates the size of a raw export in MB based on the number of readings. | ||
| * Note that changing the language effects the size about +/- 8%. | ||
| * This is just a decent estimate for larger files. | ||
| * @param readingCount - The number of readings to estimate. | ||
| * @returns The estimated size in MB. | ||
| */ | ||
| export function estimateRawExportSizeMB(readingCount: number): number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| const ESTIMATED_MB_PER_RAW_READING = 8.2e-5; | ||
|
|
||
| /** | ||
| * Estimates the size of a raw export in MB based on the number of readings. | ||
| * Note that changing the language effects the size about +/- 8%. | ||
| * This is just a decent estimate for larger files. | ||
| * @param readingCount - The number of readings to estimate. | ||
| * @returns The estimated size in MB. | ||
| */ | ||
| function estimateRawExportSizeMB(readingCount) { | ||
| return readingCount * ESTIMATED_MB_PER_RAW_READING; | ||
| } | ||
|
|
||
| module.exports = { | ||
| estimateRawExportSizeMB | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| const { expect, mocha } = require('../common'); | ||
| const { estimateRawExportSizeMB } = require('../../../common/RawExportFileSize'); | ||
| const DELTA = 1e-15; | ||
|
|
||
| mocha.describe('Raw Export File Size Estimator', () => { | ||
| mocha.it('returns zero for zero readings', () => { | ||
| expect(estimateRawExportSizeMB(0)).to.be.closeTo(0, DELTA); | ||
| }); | ||
|
|
||
| mocha.it('returns 0.082 MB for 1000 readings', () => { | ||
| expect(estimateRawExportSizeMB(1000)).to.be.closeTo(0.082, DELTA); | ||
| }); | ||
|
|
||
| mocha.it('returns 0.11808 MB for 1440 readings', () => { | ||
| expect(estimateRawExportSizeMB(1440)).to.be.closeTo(0.11808, DELTA); | ||
| }); | ||
|
|
||
| mocha.it('returns 0.71832 MB for 8760 readings', () => { | ||
| expect(estimateRawExportSizeMB(8760)).to.be.closeTo(0.71832, DELTA); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a blank line before the JSDco.