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
4c6c5045
Commit
4c6c5045
authored
Jan 31, 2015
by
Tomas Dvorak
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #63 from jamesdelonay/master
parents
a1a10a63
5a718f13
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
variety.js
variety.js
+4
-7
No files found.
variety.js
View file @
4c6c5045
...
@@ -152,6 +152,7 @@ function serializeDoc(doc, maxDepth){
...
@@ -152,6 +152,7 @@ function serializeDoc(doc, maxDepth){
var
interimResults
=
{};
//hold results here until converted to final format
var
interimResults
=
{};
//hold results here until converted to final format
// main cursor
// main cursor
var
numDocuments
=
0
;
db
[
collection
].
find
(
query
).
sort
(
sort
).
limit
(
limit
).
forEach
(
function
(
obj
)
{
db
[
collection
].
find
(
query
).
sort
(
sort
).
limit
(
limit
).
forEach
(
function
(
obj
)
{
//printjson(obj)
//printjson(obj)
flattened
=
serializeDoc
(
obj
,
maxDepth
);
flattened
=
serializeDoc
(
obj
,
maxDepth
);
...
@@ -174,9 +175,9 @@ db[collection].find(query).sort(sort).limit(limit).forEach(function(obj) {
...
@@ -174,9 +175,9 @@ db[collection].find(query).sort(sort).limit(limit).forEach(function(obj) {
interimResults
[
key
][
'totalOccurrences'
]
++
;
interimResults
[
key
][
'totalOccurrences'
]
++
;
}
}
}
}
numDocuments
++
;
});
});
var
varietyResults
=
[];
var
varietyResults
=
[];
//now convert the interimResults into the proper format
//now convert the interimResults into the proper format
for
(
var
key
in
interimResults
){
for
(
var
key
in
interimResults
){
...
@@ -185,12 +186,10 @@ for(var key in interimResults){
...
@@ -185,12 +186,10 @@ for(var key in interimResults){
newEntry
[
'_id'
]
=
{
'key'
:
key
};
newEntry
[
'_id'
]
=
{
'key'
:
key
};
newEntry
[
'value'
]
=
{
'types'
:
Object
.
keys
(
entry
[
'types'
])};
newEntry
[
'value'
]
=
{
'types'
:
Object
.
keys
(
entry
[
'types'
])};
newEntry
[
'totalOccurrences'
]
=
entry
[
'totalOccurrences'
];
newEntry
[
'totalOccurrences'
]
=
entry
[
'totalOccurrences'
];
newEntry
[
'percentContaining'
]
=
entry
[
'totalOccurrences'
]
*
100
/
limit
;
newEntry
[
'percentContaining'
]
=
entry
[
'totalOccurrences'
]
*
100
/
limit
;
varietyResults
.
push
(
newEntry
);
varietyResults
.
push
(
newEntry
);
}
}
var
numDocuments
=
db
[
collection
].
count
();
// We throw away keys which end in an array index, since they are not useful
// We throw away keys which end in an array index, since they are not useful
// for our analysis. (We still keep the key of their parent array, though.) -JC
// for our analysis. (We still keep the key of their parent array, though.) -JC
var
filter
=
function
(
item
)
{
var
filter
=
function
(
item
)
{
...
@@ -207,9 +206,7 @@ var map = function(item) {
...
@@ -207,9 +206,7 @@ var map = function(item) {
}
}
// we don't need to set it if limit isn't being used. (it's set above.)
// we don't need to set it if limit isn't being used. (it's set above.)
if
(
limit
<
numDocuments
)
{
if
(
limit
<
numDocuments
)
{
var
existsQuery
=
{};
item
.
totalOccurrences
=
db
[
collection
].
count
(
query
);
existsQuery
[
keyName
]
=
{
$exists
:
true
};
item
.
totalOccurrences
=
db
[
collection
].
count
(
existsQuery
);
}
}
item
.
percentContaining
=
(
item
.
totalOccurrences
/
numDocuments
)
*
100.0
;
item
.
percentContaining
=
(
item
.
totalOccurrences
/
numDocuments
)
*
100.0
;
return
item
;
return
item
;
...
...
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