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
7b6fc8c5
Commit
7b6fc8c5
authored
Mar 19, 2012
by
James Cropcho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added initial keys.js
parent
f1fbc06c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
keys.js
keys.js
+67
-0
No files found.
keys.js
0 → 100644
View file @
7b6fc8c5
use
popplet
;
canHaveChildren
=
function
(
v
)
{
var
isArray
=
(
v
&&
typeof
v
===
'object'
&&
typeof
v
.
length
===
'number'
&&
!
(
v
.
propertyIsEnumerable
(
'length'
)));
var
isObject
=
typeof
v
===
'object'
;
return
isArray
||
isObject
;
}
db
.
system
.
js
.
save
(
{
_id
:
"canHaveChildren"
,
value
:
canHaveChildren
}
);
mapRecursive
=
function
(
parentKey
,
keys
){
for
(
var
key
in
keys
)
{
var
value
=
keys
[
key
];
key
=
key
.
replace
(
/
\d
+/g
,
'XX'
);
emit
({
"key"
:
parentKey
+
"."
+
key
,
"typee"
:
typeof
value
},
{
occurrences
:
1
});
if
(
canHaveChildren
(
value
))
{
mapRecursive
(
parentKey
+
"."
+
key
,
value
);
}
}
}
db
.
system
.
js
.
save
({
_id
:
"mapRecursive"
,
value
:
mapRecursive
});
map
=
function
()
{
var
keys
=
this
;
for
(
var
key
in
keys
)
{
var
value
=
keys
[
key
];
key
=
key
.
replace
(
/
\d
+/g
,
'XX'
);
emit
({
"key"
:
key
,
"typee"
:
typeof
value
},
{
occurrences
:
1
});
if
(
canHaveChildren
(
value
))
{
mapRecursive
(
key
,
value
);
}
}
}
reduce
=
function
(
key
,
values
){
var
occurrences
=
0
;
values
.
forEach
(
function
(
value
)
{
occurrences
+=
value
.
occurrences
;
});
return
{
occurrences
:
occurrences
};
}
finalize
=
function
(
key
,
value
)
{
value
.
percentage
=
value
.
occurrences
/
1000
*
100.0
;
return
value
;
}
db
.
usersKeyNames
.
drop
();
db
.
users
.
mapReduce
(
map
,
reduce
,
{
finalize
:
finalize
,
out
:
'usersKeyNames'
,
verbose
:
true
,
limit
:
1000
,
sort
:
{
_id
:
-
1
}});
db
.
usersKeyNames
.
find
()
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