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
6d58bd8e
Commit
6d58bd8e
authored
May 25, 2012
by
Wes Freeman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add occurrence checking for arrays with nested objects.
parent
d025b62d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
variety.js
variety.js
+10
-9
No files found.
variety.js
View file @
6d58bd8e
...
...
@@ -136,16 +136,17 @@ resultsDB[resultsCollectionName].find({}).forEach(function(key) {
return
;
}
if
(
!
(
keyName
.
match
(
/
\.
XX/
)
&&
!
keyName
.
match
(
/
\.
XX$/
)))
{
// i.e. "Unless the key's value is an array which contains arrays" -JC
// ...we do not support totalOccurrences for these keys because it is
// a bit too tricky for a 'version 1'. Perhaps we'll support in the future. -JC
var
existsQuery
=
{};
existsQuery
[
keyName
]
=
{
$exists
:
true
};
key
.
totalOccurrences
=
db
[
collection
].
count
(
existsQuery
);
key
.
percentContaining
=
(
key
.
totalOccurrences
/
numDocuments
)
*
100
;
if
(
keyName
.
match
(
/
\.
XX/
))
{
// exists query checks for embedded values for an array
// ie. match {arr:[{x:1}]} with {"arr.x":{$exists:true}}
// just need to pull out .XX in this case
keyName
=
keyName
.
replace
(
/.XX/g
,
""
);
}
var
existsQuery
=
{};
existsQuery
[
keyName
]
=
{
$exists
:
true
};
key
.
totalOccurrences
=
db
[
collection
].
count
(
existsQuery
);
key
.
percentContaining
=
(
key
.
totalOccurrences
/
numDocuments
)
*
100
;
resultsDB
[
resultsCollectionName
].
save
(
key
);
});
...
...
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