Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
variety
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
variety
Commits
e549b011
Commit
e549b011
authored
Jan 31, 2015
by
Tomas Dvorak
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #65 from todvora/master
Removed Object.keys call
parents
5a9fc8b4
f88768a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
variety.js
variety.js
+5
-6
No files found.
variety.js
View file @
e549b011
...
...
@@ -165,13 +165,12 @@ db[collection].find(query).sort(sort).limit(limit).forEach(function(obj) {
var
valueType
=
varietyTypeOf
(
value
);
if
(
!
(
key
in
interimResults
)){
//if it's a new key we haven't seen yet
//for the moment, store 'types' as a dictionary. An easy way to prevent duplicates
var
newEntry
=
{
'types'
:{},
'totalOccurrences'
:
1
};
newEntry
[
'types'
][
valueType
]
=
true
;
interimResults
[
key
]
=
newEntry
;
interimResults
[
key
]
=
{
'types'
:[
valueType
],
'totalOccurrences'
:
1
};
}
else
{
//we've seen this key before
interimResults
[
key
][
'types'
][
valueType
]
=
true
;
if
(
interimResults
[
key
][
'types'
].
indexOf
(
valueType
)
==
-
1
)
{
interimResults
[
key
][
'types'
].
push
(
valueType
);
}
interimResults
[
key
][
'totalOccurrences'
]
++
;
}
}
...
...
@@ -184,7 +183,7 @@ for(var key in interimResults){
var
entry
=
interimResults
[
key
];
var
newEntry
=
{};
newEntry
[
'_id'
]
=
{
'key'
:
key
};
newEntry
[
'value'
]
=
{
'types'
:
Object
.
keys
(
entry
[
'types'
])
};
newEntry
[
'value'
]
=
{
'types'
:
entry
[
'types'
]
};
newEntry
[
'totalOccurrences'
]
=
entry
[
'totalOccurrences'
];
newEntry
[
'percentContaining'
]
=
entry
[
'totalOccurrences'
]
*
100
/
limit
;
varietyResults
.
push
(
newEntry
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment