Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
2f09c23c
Commit
2f09c23c
authored
Feb 23, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor stat_graph_contributors_util to es6 module syntax
parent
c2497d8b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
137 deletions
+135
-137
app/assets/javascripts/graphs/graphs_bundle.js
app/assets/javascripts/graphs/graphs_bundle.js
+0
-1
app/assets/javascripts/graphs/stat_graph_contributors.js
app/assets/javascripts/graphs/stat_graph_contributors.js
+2
-1
app/assets/javascripts/graphs/stat_graph_contributors_util.js
...assets/javascripts/graphs/stat_graph_contributors_util.js
+132
-133
spec/javascripts/graphs/stat_graph_contributors_util_spec.js
spec/javascripts/graphs/stat_graph_contributors_util_spec.js
+1
-2
No files found.
app/assets/javascripts/graphs/graphs_bundle.js
View file @
2f09c23c
require
(
'
./stat_graph_contributors_graph
'
);
require
(
'
./stat_graph_contributors_graph
'
);
require
(
'
./stat_graph_contributors_util
'
);
require
(
'
./stat_graph_contributors
'
);
require
(
'
./stat_graph_contributors
'
);
app/assets/javascripts/graphs/stat_graph_contributors.js
View file @
2f09c23c
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
/* global ContributorsGraph */
/* global ContributorsGraph */
/* global ContributorsAuthorGraph */
/* global ContributorsAuthorGraph */
/* global ContributorsMasterGraph */
/* global ContributorsMasterGraph */
/* global ContributorsStatGraphUtil */
import
ContributorsStatGraphUtil
from
'
./stat_graph_contributors_util
'
;
/* global d3 */
/* global d3 */
window
.
d3
=
require
(
'
d3
'
);
window
.
d3
=
require
(
'
d3
'
);
...
...
app/assets/javascripts/graphs/stat_graph_contributors_util.js
View file @
2f09c23c
/* eslint-disable func-names, space-before-function-paren, object-shorthand, no-var, one-var, camelcase, one-var-declaration-per-line, comma-dangle, no-param-reassign, no-return-assign, quotes, prefer-arrow-callback, wrap-iife, consistent-return, no-unused-vars, max-len, no-cond-assign, no-else-return, max-len */
/* eslint-disable func-names, space-before-function-paren, object-shorthand, no-var, one-var, camelcase, one-var-declaration-per-line, comma-dangle, no-param-reassign, no-return-assign, quotes, prefer-arrow-callback, wrap-iife, consistent-return, no-unused-vars, max-len, no-cond-assign, no-else-return, max-len */
(
function
()
{
window
.
ContributorsStatGraphUtil
=
{
export
default
{
parse_log
:
function
(
log
)
{
parse_log
:
function
(
log
)
{
var
by_author
,
by_email
,
data
,
entry
,
i
,
len
,
total
,
normalized_email
;
var
by_author
,
by_email
,
data
,
entry
,
i
,
len
,
total
,
normalized_email
;
total
=
{};
total
=
{};
by_author
=
{};
by_author
=
{};
by_email
=
{};
by_email
=
{};
for
(
i
=
0
,
len
=
log
.
length
;
i
<
len
;
i
+=
1
)
{
for
(
i
=
0
,
len
=
log
.
length
;
i
<
len
;
i
+=
1
)
{
entry
=
log
[
i
];
entry
=
log
[
i
];
if
(
total
[
entry
.
date
]
==
null
)
{
if
(
total
[
entry
.
date
]
==
null
)
{
this
.
add_date
(
entry
.
date
,
total
);
this
.
add_date
(
entry
.
date
,
total
);
}
normalized_email
=
entry
.
author_email
.
toLowerCase
();
data
=
by_author
[
entry
.
author_name
]
||
by_email
[
normalized_email
];
if
(
data
==
null
)
{
data
=
this
.
add_author
(
entry
,
by_author
,
by_email
);
}
if
(
!
data
[
entry
.
date
])
{
this
.
add_date
(
entry
.
date
,
data
);
}
this
.
store_data
(
entry
,
total
[
entry
.
date
],
data
[
entry
.
date
]);
}
total
=
_
.
toArray
(
total
);
by_author
=
_
.
toArray
(
by_author
);
return
{
total
:
total
,
by_author
:
by_author
};
},
add_date
:
function
(
date
,
collection
)
{
collection
[
date
]
=
{};
return
collection
[
date
].
date
=
date
;
},
add_author
:
function
(
author
,
by_author
,
by_email
)
{
var
data
,
normalized_email
;
data
=
{};
data
.
author_name
=
author
.
author_name
;
data
.
author_email
=
author
.
author_email
;
normalized_email
=
author
.
author_email
.
toLowerCase
();
by_author
[
author
.
author_name
]
=
data
;
by_email
[
normalized_email
]
=
data
;
return
data
;
},
store_data
:
function
(
entry
,
total
,
by_author
)
{
this
.
store_commits
(
total
,
by_author
);
this
.
store_additions
(
entry
,
total
,
by_author
);
return
this
.
store_deletions
(
entry
,
total
,
by_author
);
},
store_commits
:
function
(
total
,
by_author
)
{
this
.
add
(
total
,
"
commits
"
,
1
);
return
this
.
add
(
by_author
,
"
commits
"
,
1
);
},
add
:
function
(
collection
,
field
,
value
)
{
if
(
collection
[
field
]
==
null
)
{
collection
[
field
]
=
0
;
}
return
collection
[
field
]
+=
value
;
},
store_additions
:
function
(
entry
,
total
,
by_author
)
{
if
(
entry
.
additions
==
null
)
{
entry
.
additions
=
0
;
}
}
this
.
add
(
total
,
"
additions
"
,
entry
.
additions
);
normalized_email
=
entry
.
author_email
.
toLowerCase
();
return
this
.
add
(
by_author
,
"
additions
"
,
entry
.
additions
);
data
=
by_author
[
entry
.
author_name
]
||
by_email
[
normalized_email
];
},
if
(
data
==
null
)
{
store_deletions
:
function
(
entry
,
total
,
by_author
)
{
data
=
this
.
add_author
(
entry
,
by_author
,
by_email
);
if
(
entry
.
deletions
==
null
)
{
entry
.
deletions
=
0
;
}
}
this
.
add
(
total
,
"
deletions
"
,
entry
.
deletions
);
if
(
!
data
[
entry
.
date
])
{
return
this
.
add
(
by_author
,
"
deletions
"
,
entry
.
deletions
);
this
.
add_date
(
entry
.
date
,
data
);
},
get_total_data
:
function
(
parsed_log
,
field
)
{
var
log
,
total_data
;
log
=
parsed_log
.
total
;
total_data
=
this
.
pick_field
(
log
,
field
);
return
_
.
sortBy
(
total_data
,
function
(
d
)
{
return
d
.
date
;
});
},
pick_field
:
function
(
log
,
field
)
{
var
total_data
;
total_data
=
[];
_
.
each
(
log
,
function
(
d
)
{
return
total_data
.
push
(
_
.
pick
(
d
,
[
field
,
'
date
'
]));
});
return
total_data
;
},
get_author_data
:
function
(
parsed_log
,
field
,
date_range
)
{
var
author_data
,
log
;
if
(
date_range
==
null
)
{
date_range
=
null
;
}
log
=
parsed_log
.
by_author
;
author_data
=
[];
_
.
each
(
log
,
(
function
(
_this
)
{
return
function
(
log_entry
)
{
var
parsed_log_entry
;
parsed_log_entry
=
_this
.
parse_log_entry
(
log_entry
,
field
,
date_range
);
if
(
!
_
.
isEmpty
(
parsed_log_entry
.
dates
))
{
return
author_data
.
push
(
parsed_log_entry
);
}
};
})(
this
));
return
_
.
sortBy
(
author_data
,
function
(
d
)
{
return
d
[
field
];
}).
reverse
();
},
parse_log_entry
:
function
(
log_entry
,
field
,
date_range
)
{
var
parsed_entry
;
parsed_entry
=
{};
parsed_entry
.
author_name
=
log_entry
.
author_name
;
parsed_entry
.
author_email
=
log_entry
.
author_email
;
parsed_entry
.
dates
=
{};
parsed_entry
.
commits
=
parsed_entry
.
additions
=
parsed_entry
.
deletions
=
0
;
_
.
each
(
_
.
omit
(
log_entry
,
'
author_name
'
,
'
author_email
'
),
(
function
(
_this
)
{
return
function
(
value
,
key
)
{
if
(
_this
.
in_range
(
value
.
date
,
date_range
))
{
parsed_entry
.
dates
[
value
.
date
]
=
value
[
field
];
parsed_entry
.
commits
+=
value
.
commits
;
parsed_entry
.
additions
+=
value
.
additions
;
return
parsed_entry
.
deletions
+=
value
.
deletions
;
}
};
})(
this
));
return
parsed_entry
;
},
in_range
:
function
(
date
,
date_range
)
{
var
ref
;
if
(
date_range
===
null
||
(
date_range
[
0
]
<=
(
ref
=
new
Date
(
date
))
&&
ref
<=
date_range
[
1
]))
{
return
true
;
}
else
{
return
false
;
}
}
this
.
store_data
(
entry
,
total
[
entry
.
date
],
data
[
entry
.
date
]);
}
total
=
_
.
toArray
(
total
);
by_author
=
_
.
toArray
(
by_author
);
return
{
total
:
total
,
by_author
:
by_author
};
},
add_date
:
function
(
date
,
collection
)
{
collection
[
date
]
=
{};
return
collection
[
date
].
date
=
date
;
},
add_author
:
function
(
author
,
by_author
,
by_email
)
{
var
data
,
normalized_email
;
data
=
{};
data
.
author_name
=
author
.
author_name
;
data
.
author_email
=
author
.
author_email
;
normalized_email
=
author
.
author_email
.
toLowerCase
();
by_author
[
author
.
author_name
]
=
data
;
by_email
[
normalized_email
]
=
data
;
return
data
;
},
store_data
:
function
(
entry
,
total
,
by_author
)
{
this
.
store_commits
(
total
,
by_author
);
this
.
store_additions
(
entry
,
total
,
by_author
);
return
this
.
store_deletions
(
entry
,
total
,
by_author
);
},
store_commits
:
function
(
total
,
by_author
)
{
this
.
add
(
total
,
"
commits
"
,
1
);
return
this
.
add
(
by_author
,
"
commits
"
,
1
);
},
add
:
function
(
collection
,
field
,
value
)
{
if
(
collection
[
field
]
==
null
)
{
collection
[
field
]
=
0
;
}
return
collection
[
field
]
+=
value
;
},
store_additions
:
function
(
entry
,
total
,
by_author
)
{
if
(
entry
.
additions
==
null
)
{
entry
.
additions
=
0
;
}
this
.
add
(
total
,
"
additions
"
,
entry
.
additions
);
return
this
.
add
(
by_author
,
"
additions
"
,
entry
.
additions
);
},
store_deletions
:
function
(
entry
,
total
,
by_author
)
{
if
(
entry
.
deletions
==
null
)
{
entry
.
deletions
=
0
;
}
this
.
add
(
total
,
"
deletions
"
,
entry
.
deletions
);
return
this
.
add
(
by_author
,
"
deletions
"
,
entry
.
deletions
);
},
get_total_data
:
function
(
parsed_log
,
field
)
{
var
log
,
total_data
;
log
=
parsed_log
.
total
;
total_data
=
this
.
pick_field
(
log
,
field
);
return
_
.
sortBy
(
total_data
,
function
(
d
)
{
return
d
.
date
;
});
},
pick_field
:
function
(
log
,
field
)
{
var
total_data
;
total_data
=
[];
_
.
each
(
log
,
function
(
d
)
{
return
total_data
.
push
(
_
.
pick
(
d
,
[
field
,
'
date
'
]));
});
return
total_data
;
},
get_author_data
:
function
(
parsed_log
,
field
,
date_range
)
{
var
author_data
,
log
;
if
(
date_range
==
null
)
{
date_range
=
null
;
}
log
=
parsed_log
.
by_author
;
author_data
=
[];
_
.
each
(
log
,
(
function
(
_this
)
{
return
function
(
log_entry
)
{
var
parsed_log_entry
;
parsed_log_entry
=
_this
.
parse_log_entry
(
log_entry
,
field
,
date_range
);
if
(
!
_
.
isEmpty
(
parsed_log_entry
.
dates
))
{
return
author_data
.
push
(
parsed_log_entry
);
}
};
})(
this
));
return
_
.
sortBy
(
author_data
,
function
(
d
)
{
return
d
[
field
];
}).
reverse
();
},
parse_log_entry
:
function
(
log_entry
,
field
,
date_range
)
{
var
parsed_entry
;
parsed_entry
=
{};
parsed_entry
.
author_name
=
log_entry
.
author_name
;
parsed_entry
.
author_email
=
log_entry
.
author_email
;
parsed_entry
.
dates
=
{};
parsed_entry
.
commits
=
parsed_entry
.
additions
=
parsed_entry
.
deletions
=
0
;
_
.
each
(
_
.
omit
(
log_entry
,
'
author_name
'
,
'
author_email
'
),
(
function
(
_this
)
{
return
function
(
value
,
key
)
{
if
(
_this
.
in_range
(
value
.
date
,
date_range
))
{
parsed_entry
.
dates
[
value
.
date
]
=
value
[
field
];
parsed_entry
.
commits
+=
value
.
commits
;
parsed_entry
.
additions
+=
value
.
additions
;
return
parsed_entry
.
deletions
+=
value
.
deletions
;
}
};
})(
this
));
return
parsed_entry
;
},
in_range
:
function
(
date
,
date_range
)
{
var
ref
;
if
(
date_range
===
null
||
(
date_range
[
0
]
<=
(
ref
=
new
Date
(
date
))
&&
ref
<=
date_range
[
1
]))
{
return
true
;
}
else
{
return
false
;
}
}
}
;
}
}
).
call
(
window
)
;
};
spec/javascripts/graphs/stat_graph_contributors_util_spec.js
View file @
2f09c23c
/* eslint-disable quotes, no-var, camelcase, object-property-newline, comma-dangle, max-len, vars-on-top, quote-props */
/* eslint-disable quotes, no-var, camelcase, object-property-newline, comma-dangle, max-len, vars-on-top, quote-props */
/* global ContributorsStatGraphUtil */
require
(
'
~/graphs/stat_graph_contributors_util
'
)
;
import
ContributorsStatGraphUtil
from
'
~/graphs/stat_graph_contributors_util
'
;
describe
(
"
ContributorsStatGraphUtil
"
,
function
()
{
describe
(
"
ContributorsStatGraphUtil
"
,
function
()
{
describe
(
"
#parse_log
"
,
function
()
{
describe
(
"
#parse_log
"
,
function
()
{
...
...
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