Skip to content
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

Modularize Data Download #654

Merged
merged 10 commits into from
Jan 9, 2018
Merged

Conversation

Benjaki2
Copy link
Collaborator

@Benjaki2 Benjaki2 commented Jan 8, 2018

Changes in this pull request:

  • Modularize data download code
  • Adjust naming of map function exports to match universal styling
  • Modularize EDSC files
  • Include data download tests

Benjamin King added 7 commits January 8, 2018 14:21
* export as `dataHelper` instead of `L`
* all functions that were part of wv global are now exported
* export reuseable constants `export const examples ='something'`
@ghost ghost assigned Benjaki2 Jan 8, 2018
@ghost ghost added the under development label Jan 8, 2018
@localjo localjo changed the title data-download module loaders Modularize Data Download Jan 8, 2018
Copy link
Contributor

@ZachTRice ZachTRice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Tested locally and didn't find any errors. I do agree that the L naming is not named well / intuitive when looking at the code.

var L = {};
edsc.L = L;

Copy link
Contributor

@localjo localjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job modularizing a very complex section of code! I left a few comments about variable names that I think are confusing. My main point is that we should be choosing variable names that are consistent and clearly communicate what the code is doing with minimal mental overhead. I'm not asking for any changes, unless you agree with my comments or see an easy way to make things clearer.

@@ -0,0 +1,15 @@
export function dataParser(state, errors, config) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about naming this file parser.js?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A number of the 'parser' files in other features have other methods in them.

import {dataHelper} from '../edsc';
import {
CRS_WGS_84,
mapIsPolygonValid,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between prefixing all of these with map and prefixing all of the Worldview JavaScript files with wv.? Does the extra prefix provide some value? Or are we being more verbose than we need to be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say we essentially got rid of thewv in wv.map.something and are left with the map.something as camel case. The prefix stands for the folder in which something is in. We can't just call a method parser, we need dataParser if we want to export unique names across the board. mapIsPolygonValid would be fine as isPolygonValid but I'm just trying to stick with a convention.

import loEach from 'lodash/each';
import {dataCmrRoundTime, dataCmrGeometry} from './cmr';
import util from '../util/util';
import {dataHelper} from '../edsc';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not rename the whole edsc directory to web/data/helpers or something and eliminate the edsc name completely?

@@ -1,9 +1,14 @@
import edscArc from './edsc/arc';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the value of the edsc prefix? Didn't we agree that edsc isn't really relevant to this code anymore?

@@ -269,7 +283,7 @@ wv.data.results.dateTimeLabel = function (time) {
return self;
};

wv.data.results.densify = function () {
export function dataResultsDensify() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between prefixing all of the data functions with data and prefixing all of the Worldview JavaScript files with wv.? Does the extra prefix provide some value? Or are we being more verbose than we need to be?

wv.data.cmr.client = wv.data.cmr.client || function (spec) {
import $ from 'jquery';
import util from '../util/util';
import OlPolygon from 'ol/geom/polygon';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be OlGeomPolygon for consistency with the other places you imported it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

'No results received yet. This may be due to a ' +
'connectivity issue. Please try again later.'
);
};

var updateSelection = function () {
var $button = $('#wv-data-download-button');
var selected = _.size(model.selectedGranules);
var selected = loSize(model.selectedGranules);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think loSize is a very confusing function name to find in a context like this. Wouldn't someone's first intuition here be to think that we're selecting the granule with the lowest size from the model? I think @ZachTRice and I are in favor of spelling out the whole prefix for lodash functions; lodashSize, since lo can be kind of ambiguous.

Copy link
Contributor

@localjo localjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return granule;
};

return self;
};

wv.data.results.extentFilter = function (projection, extent) {
export function dataResultsExtentFilter(projection, extent) {
var self = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a non-geographic projection is selected, it looks like this function gets called with extent being undefined.

@@ -4,6 +4,10 @@ import loIsUndefined from 'lodash/isUndefined';
import loFind from 'lodash/find';
import OlGeomPolygon from 'ol/geom/polygon';

export const CRS_WGS_84 = 'EPSG:4326';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where was this constant defined before? I suspect that maybe the bug we're seeing is related to this constant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Benjaki2
Copy link
Collaborator Author

Benjaki2 commented Jan 9, 2018

@localjo @ZachTRice
I believe c4d3a68 addresses the error with polar views.

@localjo
Copy link
Contributor

localjo commented Jan 9, 2018

Looks good! Let's merge!

@Benjaki2 Benjaki2 merged commit 72f4104 into module-loaders Jan 9, 2018
@Benjaki2 Benjaki2 deleted the module-loaders-data-download branch January 9, 2018 15:49
@ghost ghost removed the ready for review label Jan 9, 2018
@Benjaki2 Benjaki2 mentioned this pull request Jan 9, 2018
58 tasks
@localjo localjo added this to the Module Loaders Release (v2.0) milestone Jan 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants