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
e1aafb33
Commit
e1aafb33
authored
Oct 14, 2014
by
Tomas Dvorak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed total counts and percents when limit or query applied
parent
d86c32c2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
12 deletions
+8
-12
LimitResultsAnalysisTest.java
...ava/com/github/variety/test/LimitResultsAnalysisTest.java
+1
-2
QueryLimitedAnalysisTest.java
...ava/com/github/variety/test/QueryLimitedAnalysisTest.java
+3
-3
SortedAnalysisTest.java
...test/java/com/github/variety/test/SortedAnalysisTest.java
+3
-6
variety.js
variety.js
+1
-1
No files found.
test/src/test/java/com/github/variety/test/LimitResultsAnalysisTest.java
View file @
e1aafb33
...
@@ -32,7 +32,6 @@ public class LimitResultsAnalysisTest {
...
@@ -32,7 +32,6 @@ public class LimitResultsAnalysisTest {
analysis
.
verifyResult
(
"_id"
,
5
,
100
,
"ObjectId"
);
analysis
.
verifyResult
(
"_id"
,
5
,
100
,
"ObjectId"
);
analysis
.
verifyResult
(
"name"
,
5
,
100
,
"String"
);
analysis
.
verifyResult
(
"name"
,
5
,
100
,
"String"
);
// TODO: there is only one document with 'someBinData'. Why variety returns 5/100% instead of 1/20% ?
analysis
.
verifyResult
(
"someBinData"
,
1
,
20
,
"BinData-old"
);
// FIXME: analysis.verifyResult("someBinData", 1, 20, "BinData-old");
}
}
}
}
test/src/test/java/com/github/variety/test/QueryLimitedAnalysisTest.java
View file @
e1aafb33
...
@@ -27,9 +27,9 @@ public class QueryLimitedAnalysisTest {
...
@@ -27,9 +27,9 @@ public class QueryLimitedAnalysisTest {
final
VarietyAnalysis
analysis
=
variety
.
withQuery
(
"{someBinData:{$exists: true}}"
).
runAnalysis
();
final
VarietyAnalysis
analysis
=
variety
.
withQuery
(
"{someBinData:{$exists: true}}"
).
runAnalysis
();
Assert
.
assertEquals
(
3
,
analysis
.
getResultsCollection
().
count
());
Assert
.
assertEquals
(
3
,
analysis
.
getResultsCollection
().
count
());
//
TODO: are those percentContaining numbers correct? Should percents be limited to all data or query data?
//
we analyzed only the keys of objects defined by query. But total counts and percents are computed from the complete collection
analysis
.
verifyResult
(
"_id"
,
1
,
2
0
,
"ObjectId"
);
analysis
.
verifyResult
(
"_id"
,
5
,
10
0
,
"ObjectId"
);
analysis
.
verifyResult
(
"name"
,
1
,
2
0
,
"String"
);
analysis
.
verifyResult
(
"name"
,
5
,
10
0
,
"String"
);
analysis
.
verifyResult
(
"someBinData"
,
1
,
20
,
"BinData-old"
);
analysis
.
verifyResult
(
"someBinData"
,
1
,
20
,
"BinData-old"
);
}
}
...
...
test/src/test/java/com/github/variety/test/SortedAnalysisTest.java
View file @
e1aafb33
...
@@ -49,14 +49,11 @@ public class SortedAnalysisTest {
...
@@ -49,14 +49,11 @@ public class SortedAnalysisTest {
Assert
.
assertEquals
(
5
,
analysis
.
getResultsCollection
().
count
());
Assert
.
assertEquals
(
5
,
analysis
.
getResultsCollection
().
count
());
// TODO: are those percentContaining numbers correct? Should percents be limited to all data or query data?
// Why total counts are always 5, when 'someWeirdLegacyKey' has only one object?
// Keys and types are correct, total count and percents seems not right.
analysis
.
verifyResult
(
"_id"
,
5
,
100
,
"ObjectId"
);
analysis
.
verifyResult
(
"_id"
,
5
,
100
,
"ObjectId"
);
analysis
.
verifyResult
(
"name"
,
5
,
100
,
"String"
);
analysis
.
verifyResult
(
"name"
,
5
,
100
,
"String"
);
analysis
.
verifyResult
(
"bio"
,
5
,
10
0
,
"String"
);
analysis
.
verifyResult
(
"bio"
,
3
,
6
0
,
"String"
);
analysis
.
verifyResult
(
"pets"
,
5
,
10
0
,
"Array"
);
analysis
.
verifyResult
(
"pets"
,
2
,
4
0
,
"Array"
);
analysis
.
verifyResult
(
"someWeirdLegacyKey"
,
5
,
10
0
,
"String"
);
analysis
.
verifyResult
(
"someWeirdLegacyKey"
,
1
,
2
0
,
"String"
);
}
}
}
}
variety.js
View file @
e1aafb33
...
@@ -209,7 +209,7 @@ resultsDB[resultsCollectionName].find({}).forEach(function(key) {
...
@@ -209,7 +209,7 @@ resultsDB[resultsCollectionName].find({}).forEach(function(key) {
if
(
limit
<
numDocuments
)
{
if
(
limit
<
numDocuments
)
{
var
existsQuery
=
{};
var
existsQuery
=
{};
existsQuery
[
keyName
]
=
{
$exists
:
true
};
existsQuery
[
keyName
]
=
{
$exists
:
true
};
key
.
totalOccurrences
=
db
[
collection
].
find
(
query
).
count
(
existsQuery
);
key
.
totalOccurrences
=
db
[
collection
].
count
(
existsQuery
);
}
}
key
.
percentContaining
=
(
key
.
totalOccurrences
/
numDocuments
)
*
100.0
;
key
.
percentContaining
=
(
key
.
totalOccurrences
/
numDocuments
)
*
100.0
;
resultsDB
[
resultsCollectionName
].
save
(
key
);
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