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

Support geo_point column and timestamp formatting #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
56 changes: 29 additions & 27 deletions dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,9 @@
for(var prop in spec) {
if(acx.isObject(spec[prop])) {
arguments.callee(path.concat(prop), spec[prop], row);
} else if(acx.isArray(spec[prop])) {
if(spec[prop].length) {
arguments.callee(path.concat(prop), spec[prop][0], row)
}
} else if(acx.isArray(spec[prop]) && !spec[prop].length) {
} else if(acx.isArray(spec[prop]) && spec[prop].length && acx.isObject(spec[prop][0])) {
arguments.callee(path.concat(prop), spec[prop][0], row)
} else {
var dpath = path.concat(prop).join(".");
if(! columns.contains(dpath)) {
Expand Down Expand Up @@ -1020,30 +1019,35 @@
_load_parents: function(query, res) {
query.loadParents(res, this.config.metadata);
},
_formatCell: function(metadata, value) {
if (metadata.type === "date") {
return new Date(value).toUTCString();
}
return (value === null ? "null" : value ).toString();
},
_getData: function(res, metadata) {
var metaColumns = ["_index", "_type", "_id", "_score"];
var columns = this.columns = [].concat(metaColumns);
var format = this._formatCell;

this.data = res.hits.hits.map(function(hit) {
var row = (function(path, spec, row) {
for(var prop in spec) {
if(acx.isObject(spec[prop])) {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
if(! columns.contains(field_name)) {
columns.push(field_name);
}
row[field_name] = format(metadata.paths[dpath], spec[prop]);
} else if(acx.isObject(spec[prop])) {
arguments.callee(path.concat(prop), spec[prop], row);
} else if(acx.isArray(spec[prop])) {
if(spec[prop].length) {
arguments.callee(path.concat(prop), spec[prop][0], row)
}
} else {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
if(! columns.contains(field_name)) {
columns.push(field_name);
}
row[field_name] = (spec[prop] === null ? "null" : spec[prop] ).toString();
} else {
// TODO: field not in metadata index
}
// TODO: field not in metadata index
}
}
return row;
Expand All @@ -1053,24 +1057,22 @@
if (typeof hit._parent!= "undefined") {
(function(prefix, path, spec, row) {
for(var prop in spec) {
if(acx.isObject(spec[prop])) {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
var column_name = prefix+"."+field_name;
if(! columns.contains(column_name)) {
columns.push(column_name);
}
row[column_name] = format(metadata.paths[dpath], spec[prop]);
} else if(acx.isObject(spec[prop])) {
arguments.callee(prefix, path.concat(prop), spec[prop], row);
} else if(acx.isArray(spec[prop])) {
if(spec[prop].length) {
arguments.callee(prefix, path.concat(prop), spec[prop][0], row)
}
} else {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
var column_name = prefix+"."+field_name;
if(! columns.contains(column_name)) {
columns.push(column_name);
}
row[column_name] = (spec[prop] === null ? "null" : spec[prop] ).toString();
} else {
// TODO: field not in metadata index
}
// TODO: field not in metadata index
}
}
})(hit._parent._type,[hit._parent._index, hit._parent._type], hit._parent._source, row);
Expand Down
49 changes: 26 additions & 23 deletions src/app/data/queryDataSourceInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,35 @@
_load_parents: function(query, res) {
query.loadParents(res, this.config.metadata);
},
_formatCell: function(metadata, value) {
if (metadata.type === "date") {
return new Date(value).toUTCString();
}
return (value === null ? "null" : value ).toString();
},
_getData: function(res, metadata) {
var metaColumns = ["_index", "_type", "_id", "_score"];
var columns = this.columns = [].concat(metaColumns);
var format = this._formatCell;

this.data = res.hits.hits.map(function(hit) {
var row = (function(path, spec, row) {
for(var prop in spec) {
if(acx.isObject(spec[prop])) {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
if(! columns.contains(field_name)) {
columns.push(field_name);
}
row[field_name] = format(metadata.paths[dpath], spec[prop]);
} else if(acx.isObject(spec[prop])) {
arguments.callee(path.concat(prop), spec[prop], row);
} else if(acx.isArray(spec[prop])) {
if(spec[prop].length) {
arguments.callee(path.concat(prop), spec[prop][0], row)
}
} else {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
if(! columns.contains(field_name)) {
columns.push(field_name);
}
row[field_name] = (spec[prop] === null ? "null" : spec[prop] ).toString();
} else {
// TODO: field not in metadata index
}
// TODO: field not in metadata index
}
}
return row;
Expand All @@ -57,24 +62,22 @@
if (typeof hit._parent!= "undefined") {
(function(prefix, path, spec, row) {
for(var prop in spec) {
if(acx.isObject(spec[prop])) {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
var column_name = prefix+"."+field_name;
if(! columns.contains(column_name)) {
columns.push(column_name);
}
row[column_name] = format(metadata.paths[dpath], spec[prop]);
} else if(acx.isObject(spec[prop])) {
arguments.callee(prefix, path.concat(prop), spec[prop], row);
} else if(acx.isArray(spec[prop])) {
if(spec[prop].length) {
arguments.callee(prefix, path.concat(prop), spec[prop][0], row)
}
} else {
var dpath = path.concat(prop).join(".");
if(metadata.paths[dpath]) {
var field_name = metadata.paths[dpath].field_name;
var column_name = prefix+"."+field_name;
if(! columns.contains(column_name)) {
columns.push(column_name);
}
row[column_name] = (spec[prop] === null ? "null" : spec[prop] ).toString();
} else {
// TODO: field not in metadata index
}
// TODO: field not in metadata index
}
}
})(hit._parent._type,[hit._parent._index, hit._parent._type], hit._parent._source, row);
Expand Down
7 changes: 3 additions & 4 deletions src/app/data/resultDataSourceInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
for(var prop in spec) {
if(acx.isObject(spec[prop])) {
arguments.callee(path.concat(prop), spec[prop], row);
} else if(acx.isArray(spec[prop])) {
if(spec[prop].length) {
arguments.callee(path.concat(prop), spec[prop][0], row)
}
} else if(acx.isArray(spec[prop]) && !spec[prop].length) {
} else if(acx.isArray(spec[prop]) && spec[prop].length && acx.isObject(spec[prop][0])) {
arguments.callee(path.concat(prop), spec[prop][0], row)
} else {
var dpath = path.concat(prop).join(".");
if(! columns.contains(dpath)) {
Expand Down