Skip to content

Commit

Permalink
refactor data select
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Sep 20, 2016
1 parent 19d37ff commit 2777c53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/cli/helpers/abe-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export default class Sql {

static whereEquals(where, value, compare, json) {
var shouldAdd = true
if(where.left === 'template') {
if(where.left === 'template' || where.left === 'abe_meta.template') {
if(value.indexOf('/') > -1 && value !== compare) {
shouldAdd = false
}else if(value.indexOf('/') === -1 && compare.indexOf(value) === -1) {
Expand All @@ -504,7 +504,7 @@ export default class Sql {
if(value.includes(compare)) {
foundOne = true
}
}else if(value == compare) { // only none is Array
}else if(value === compare) { // only none is Array
foundOne = true
}

Expand Down Expand Up @@ -627,7 +627,7 @@ export default class Sql {
var value
var compare

if(where.left === 'template') {
if(where.left === 'template' || where.left === 'abe_meta.template') {
value = FileParser.getTemplate(json[meta].template)
}else {
value = Sql.deep_value_array(json, where.left)
Expand All @@ -647,13 +647,13 @@ export default class Sql {
if(typeof value !== 'undefined' && value !== null) {
switch(where.compare) {
case '=':
shouldAdd = Sql.whereEquals(where, value, compare, json)
shouldAdd = Sql.whereEquals(where, value, compare, shouldAdd)
break;
case '!=':
shouldAdd = Sql.whereNotEquals(where, value, compare, json)
shouldAdd = Sql.whereNotEquals(where, value, compare, shouldAdd)
break;
case 'LIKE':
shouldAdd = Sql.whereLike(where, value, compare, json)
shouldAdd = Sql.whereLike(where, value, compare, shouldAdd)
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/helpers/abe-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default class Utils {
}
}

log.duration(type + " > " + logTime, ((new Date().getTime() - dateStart.getTime()) / 1000))
console.log(type + "(found " + data.length + ") > " + logTime, ((new Date().getTime() - dateStart.getTime()) / 1000), "\n")

resolveSource()
})
Expand Down
5 changes: 4 additions & 1 deletion src/cli/helpers/file-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,10 @@ export default class FileParser {
Array.prototype.forEach.call(withKeys, (key) => {
// console.log('* * * * * * * * * * * * * * * * * * * * * * * * * * * * *')
// console.log(key, key.split('.').reduce((o,i)=>o[i], json))
set_deep_value(cleanFile, key, key.split('.').reduce((o,i)=>o[i], json))
if(typeof json !== 'undefined' && json !== null
&& typeof json[key.split('.')[0]] !== 'undefined' && json[key.split('.')[0]] !== null) {
set_deep_value(cleanFile, key, key.split('.').reduce((o,i)=>o[i], json))
}
// if(typeof json[key] !== 'undefined' && json[key] !== null) {
// cleanFile[key] = json[key]
// }
Expand Down

0 comments on commit 2777c53

Please sign in to comment.