-
Notifications
You must be signed in to change notification settings - Fork 18
/
team.ejs
41 lines (29 loc) · 906 Bytes
/
team.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<%
function findMember(name) {
return data.find(item => item.name === name);
}
function countMember(posts, type) {
const data = { };
posts.forEach(post => {
for (let name of (post[type] || '')) {
const member = findMember( name );
if (! member) continue;
data[name] = data[name] || Object.assign({ }, member);
data[name].count = data[name].count ? ++data[name].count : 1;
(data[name].posts = data[name].posts || [ ]).push( post );
}
});
return Object.values( data ).sort((A, B) => B.count - A.count);
}
%>
<% for (let type in keyMap) if (count || post[type]) { %>
<h3><%= keyMap[type] %></h3>
<%-
partial('widget/members', {
list: count ?
countMember(posts, type) :
Array.from(new Set( post[type] ), name => findMember(name))
.filter( Boolean )
})
%>
<% } %>