Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding weekly totals and fixing closed counters #18

Open
wants to merge 9 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<header>
<div class="info">
<h1 class="title"><strong>Ubersicht</strong></h1>
<h6>Made by <a href="http://hood.ie">team Hoodie</a> with love. <a href="https://www.gittip.com/hoodiehq/">Leave a tip</a> or <a href="https://github.com/espy/ubersicht">fork this</a>.</h6>
<h6>Made by <a href="http://hood.ie">team Hoodie</a> with love. <a href="https://www.gittip.com/hoodiehq/">Leave a tip</a> or <a href="https://github.com/hasadna/ubersicht">fork this</a>.</h6>
</div>
<div class="statusIndicators"></div>
</header>
Expand Down Expand Up @@ -49,6 +49,10 @@ <h6>Made by <a href="http://hood.ie">team Hoodie</a> with love. <a href="https:/
<input type="checkbox" id="last24Hours" class="grey">
<label for="last24Hours">Last 24 hours only</label>
</li>
<li>
<input type="checkbox" id="lastWeek" class="grey">
<label for="lastWeek">Last week only</label>
</li>
</ul>
</div>
</div>
Expand Down
94 changes: 85 additions & 9 deletions script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ $(function () {
open: 0,
closed: 0,
newOpen: 0,
openedLastWeek: 0,
closedLastWeek: 0,
newClosed: 0,
repos: [],
labels: [],
Expand Down Expand Up @@ -133,6 +135,22 @@ $(function () {
$('#showCommented').iCheck('check');
$('#showUncommented').iCheck('check');
$('#last24Hours').iCheck('check');
$('#lastWeek').iCheck('uncheck');
$("#repos").val("").trigger("change");
$("#labels").val("").trigger("change");
$("#milestones").val("").trigger("change");
$("#usernames").val("").trigger("change");
});

// A helper to only show closed issues from the last week
$('header').on('click', '.showClosedLastWeek a', function(event){
event.preventDefault();
$('#showOpen').iCheck('uncheck');
$('#showClosed').iCheck('check');
$('#showCommented').iCheck('check');
$('#showUncommented').iCheck('check');
$('#last24Hours').iCheck('uncheck');
$('#lastWeek').iCheck('check');
$("#repos").val("").trigger("change");
$("#labels").val("").trigger("change");
$("#milestones").val("").trigger("change");
Expand All @@ -147,6 +165,22 @@ $(function () {
$('#showCommented').iCheck('check');
$('#showUncommented').iCheck('check');
$('#last24Hours').iCheck('check');
$('#lastWeek').iCheck('uncheck');
$("#repos").val("").trigger("change");
$("#labels").val("").trigger("change");
$("#milestones").val("").trigger("change");
$("#usernames").val("").trigger("change");
});

// A helper to only show new issues from the last 24 hours.
$('header').on('click', '.showOpenedLastWeek a', function(event){
event.preventDefault();
$('#showOpen').iCheck('check');
$('#showClosed').iCheck('uncheck');
$('#showCommented').iCheck('check');
$('#showUncommented').iCheck('check');
$('#last24Hours').iCheck('uncheck');
$('#lastWeek').iCheck('check');
$("#repos").val("").trigger("change");
$("#labels").val("").trigger("change");
$("#milestones").val("").trigger("change");
Expand Down Expand Up @@ -243,20 +277,29 @@ $(function () {
// Crawl the issues for some metadata we need for the filters
function getMetadata (issues) {
var yesterday = new Date();
var dayOfMonth = yesterday.getDate();
yesterday.setDate(dayOfMonth - 1);
var today = yesterday.getDate();
yesterday.setDate(today - 1);
metadata.yesterdayISO = yesterday.toISOString();
var oneWeekAgo = new Date();
oneWeekAgo.setDate(today - 7);
metadata.aWeekAgoISO = oneWeekAgo.toISOString();
issues.forEach(function(issue){
// Count how many open and closed issues we loaded
if(issue.state === 'open'){
if(issue.created_at > metadata.yesterdayISO){
metadata.newOpen++;
}
if(issue.created_at > metadata.aWeekAgoISO){
metadata.openedLastWeek++;
}
metadata.open++;
} else {
if(issue.closed_at > metadata.yesterdayISO){
metadata.newClosed++;
}
if(issue.closed_at > metadata.aWeekAgoISO){
metadata.closedLastWeek++;
}
metadata.closed++;
}
// collect all repos and count how many issues they have
Expand Down Expand Up @@ -352,6 +395,7 @@ $(function () {
var showCommented = $('#showCommented').is(':checked');
var showUncommented = $('#showUncommented').is(':checked');
var onlyLast24Hours = $('#last24Hours').is(':checked');
var onlyLastWeek = $('#lastWeek').is(':checked');

// Do the actual filtering
$('.issues > li').each(function(){
Expand All @@ -373,7 +417,7 @@ $(function () {
if($this.find('.comments').length === 0 && !showUncommented){
hide++;
}
// Show created in last 24 hours
// Show issues from last 24 hours
if(onlyLast24Hours){
if($this.hasClass('closed') && $this.data('closedat') < metadata.yesterdayISO){
hide++
Expand All @@ -382,6 +426,15 @@ $(function () {
hide++
}
}
// Show created in last 24 hours
if(onlyLastWeek){
if($this.hasClass('closed') && $this.data('closedat') < metadata.aWeekAgoISO){
hide++
}
if($this.hasClass('open') && $this.data('createdat') < metadata.aWeekAgoISO){
hide++
}
}
// Filter by repos
if(repos && repos.indexOf($this.attr('data-repo')) === -1){
hide++;
Expand Down Expand Up @@ -416,6 +469,7 @@ $(function () {
'showCommented=' + showCommented,
'showUncommented=' + showUncommented,
'last24Hours=' + onlyLast24Hours,
'lastWeek=' + onlyLastWeek,
'repos=' + repos,
'labels=' + labels,
'milestones=' + milestones,
Expand All @@ -441,22 +495,44 @@ $(function () {
var usernamesSelectorHTML = ich.usernamesSelector({usernames: metadata.usernames});
$('.controls').append(usernamesSelectorHTML);
$("select").select2();
// add weekle total
var openData = {
action: "showNewOpen",
action: "showOpenedLastWeek",
url: "#",
data: metadata.newOpen,
info: "New issues in the past 24h"
data: metadata.openedLastWeek,
info: "New issues in the last week"
}
var openStatusHTML = ich.status(openData);
$('.statusIndicators').append(openStatusHTML);
var closedData = {
action: "showNewClosed",
action: "showClosedLastWeek",
url: "#",
data: metadata.newClosed,
info: "Closed issues in the past 24h"
data: metadata.closedLastWeek,
info: "Issues done the last week"
}
// add daily totals - if they are not zero
var closedStatusHTML = ich.status(closedData);
$('.statusIndicators').append(closedStatusHTML);
if (metadata.newOpen > 0) {
openData = {
action: "showNewOpen",
url: "#",
data: metadata.newOpen,
info: "New issues in the past 24h"
}
openStatusHTML = ich.status(openData);
$('.statusIndicators').append(openStatusHTML);
}
if (metadata.newClosed > 0) {
closedData = {
action: "showNewClosed",
url: "#",
data: metadata.newClosed,
info: "Issues done in the past 24h"
}
closedStatusHTML = ich.status(closedData);
$('.statusIndicators').append(closedStatusHTML);
}
}

// Render the whole thing
Expand Down
2 changes: 1 addition & 1 deletion style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ h6 a:hover {
text-align: center;
}

@media (max-width: 640px) {
@media (max-width: 860px) {
header {
border-bottom: none;
height: auto;
Expand Down