Permalink
Browse files

some misc changes, and a bootstrap theme

  • Loading branch information...
1 parent 527d4e8 commit 850b2ddd5979755f573639a90537e2d5db31c216 @KohaAloha committed Sep 26, 2012
Showing with 641 additions and 237 deletions.
  1. +2 −0 bin/dashboard.pl
  2. +17 −0 config.yml
  3. +96 −36 lib/KC/Dashboard.pm
  4. +46 −18 lib/KC/Data.pm
  5. +79 −0 public/d1.js
  6. BIN public/favicon.ico
  7. +6 −7 views/bug_status.tt
  8. +395 −0 views/index.tt
  9. +0 −7 views/needsignoff.tt
  10. +0 −169 views/show_entries.tt
View
@@ -1,6 +1,8 @@
#!/usr/bin/env perl
use Dancer;
+
use KC::Dashboard;
+
dance;
View
@@ -0,0 +1,17 @@
+appname: "dashboard"
+
+# extra dancer/plack debug stuff, very nice!
+#plack_middlewares:
+# -
+# - Debug
+# - panels
+# -
+# - Parameters
+# - Dancer::Version
+# - Dancer::Settings
+# - Dancer::Logger
+# - DBITrace
+# - Memory
+# - Timer
+#
+# yaml needs an empty line after this, dont delete...
View
@@ -2,83 +2,150 @@ package KC::Dashboard;
# Script to create dashboard.koha-community.org
# Copyright chris@bigballofwax.co.nz 2012
+# Copyright mtj@kohaaloha.com 2012
-our $VERSION = '0.1';
+our $VERSION = '0.2';
use Dancer;
use Dancer::Plugin::Database;
use Dancer::Plugin::Redis;
+
+use Dancer::Logger::File;
use KC::Data ':all';
use strict;
use warnings;
use DBI;
-use Template;
+use Date::Manip;
+use Dancer::Debug;
-my $username;
-my $password;
+#use Template;
+set template => 'template_toolkit';
+set charset => 'UTF-8';
set 'session' => 'Simple';
+#set logger => 'file';
+
+set logger => 'console';
+#set log => 'debug';
+
+#set 'show_errors' => 1;
+#set 'startup_info' => 1;
+#set 'warnings' => 1;
-set 'show_errors' => 1;
-set 'startup_info' => 1;
-set 'warnings' => 1;
+use Data::Dumper;
+set plugins => {
+ Database => {
+ driver => 'mysql',
+ database => "kc_bugs",
+ host => "miso",
+ username => "kc_bugs",
+ password => "kc_bugs", #woah, hardcoded passwd!
+ }
+};
+
+# -----------------------------
get '/' => sub {
- my $sql =
-"SELECT realname,bugs.bug_id,bug_when,short_desc
+
+ my $sql = "SELECT realname,bugs.bug_id,short_desc, bug_when
FROM bugs_activity,profiles,bugs WHERE bugs_activity.who=profiles.userid
- AND bugs.bug_id=bugs_activity.bug_id AND added='Signed Off'
+ AND bugs.bug_id=bugs_activity.bug_id AND added='Signed Off'
ORDER BY bug_when DESC LIMIT 5";
my $sth = database->prepare($sql) or die database->errstr;
+
$sth->execute or die $sth->errstr;
- my $entries = $sth->fetchall_arrayref;
- $sql =
-"SELECT realname,count(*) FROM bugs_activity,profiles,bugs WHERE bugs_activity.who=profiles.userid AND bugs.bug_id=bugs_activity.bug_id AND added='Signed Off' and bug_when >= '2012-07-01' AND bug_when < '2012-08-01' GROUP BY realname,added ORDER BY count(*) desc;";
+ my $new_signoff = $sth->fetchall_arrayref;
+
+ # -----------------------------
+
+ my $sql =
+
+ "SELECT realname, bugs.bug_id,short_desc FROM bugs
+join profiles on bugs.reporter=profiles.userid
+ WHERE bug_status ='Needs Signoff' ORDER by lastdiffed limit 5";
+
+ $sth = database->prepare($sql) or die database->errstr;
+ $sth->execute or die $sth->errstr;
+
+ my $oldest_needs_signoff = $sth->fetchall_arrayref;
+
+ #$oldest_needs_signoff->{widget_title} = 'moof';
+ $sth->fetchall_arrayref;
+
+ # -----------------------------
+
+ $sql = "SELECT realname,count(*) FROM bugs_activity,profiles,bugs
+WHERE bugs_activity.who=profiles.userid AND bugs.bug_id=bugs_activity.bug_id
+AND added='Signed Off' and bug_when >=
+
+
+ DATE_SUB(CURDATE(), interval 5 month)
+
+
+AND bug_when < last_day( CURDATE() ) GROUP BY realname,added ORDER BY count(*) desc
+limit 10";
+
$sth = database->prepare($sql) or die database->errstr;
$sth->execute or die $sth->errstr;
my $stats = $sth->fetchall_arrayref;
+
+ #debug Dumper $stats ;
+
$sql =
"SELECT count(*) as count ,subdate(current_date, 1) as day FROM bugs_activity WHERE date(bug_when) = subdate(current_date, 1);";
$sth = database->prepare($sql) or die database->errstr;
$sth->execute or die $sth->errstr;
my $yesterday = $sth->fetchrow_hashref();
+
$sql =
"SELECT count(*) as count, current_date as day FROM bugs_activity WHERE date(bug_when) = current_date;";
$sth = database->prepare($sql) or die database->errstr;
$sth->execute or die $sth->errstr;
my $today = $sth->fetchrow_hashref();
+
$sql =
"SELECT count(*) as count ,subdate(current_date, 2) as day FROM bugs_activity WHERE date(bug_when) = subdate(current_date, 2);";
$sth = database->prepare($sql) or die database->errstr;
$sth->execute or die $sth->errstr;
my $daybefore = $sth->fetchrow_hashref();
+
$sql =
"SELECT bugs.bug_id,short_desc,bug_when FROM bugs,bugs_activity WHERE bugs.bug_id = bugs_activity.bug_id
AND added = 'Pushed to Master' AND bug_severity = 'enhancement' ORDER BY bug_when desc LIMIT 5";
$sth = database->prepare($sql) or die database->errstr;
$sth->execute or die $sth->errstr;
my $enhancement = $sth->fetchall_arrayref;
my $dates = get_dates();
- my $devs = get_devs();
-# my $ohloh = redis->get('ohloh');
-
-# if ( !$ohloh ) {
-my $ohloh = ohloh_activity();
-# redis->set( 'ohloh' => $ohloh );
-# redis->expire( 'ohloh', 6000 );
-# }
- template 'show_entries.tt',
- {
- 'entries' => $entries,
+
+ # -----------------------------
+
+ #my $ohloh = redis->get('ohloh');
+ my $ohloh = ohloh_activity();
+ my $ohloh_devs = ohloh_devs();
+
+ my $bug_activity = [
+
+ [ $daybefore->{day}, $daybefore->{count} ],
+ [ $yesterday->{day}, $yesterday->{count} ],
+ [ $today->{day}, $today->{count} ],
+
+ ];
+
+ template 'index.tt', {
+ 'new_signoff' => $new_signoff,
'stats' => $stats,
'yesterday' => $yesterday,
'today' => $today,
'daybefore' => $daybefore,
'enhancments' => $enhancement,
'dates' => $dates,
- 'devs' => $devs,
- 'ohloh' => $ohloh,
- };
+ 'ohloh' => $ohloh,
+ 'ohloh_devs' => $ohloh_devs,
+ 'oldest_needs_signoff' => $oldest_needs_signoff,
+ #'dummy' => $dummy,
+ 'bug_activity' => $bug_activity,
+
+ };
};
get '/bug_status' => sub {
@@ -93,22 +160,15 @@ get '/bug_status' => sub {
get '/randombug' => sub {
my $sql =
-"SELECT * FROM (SELECT bug_id,short_desc FROM bugs WHERE bug_status NOT in
+ "SELECT * FROM (SELECT bug_id,short_desc FROM bugs WHERE bug_status NOT in
('CLOSED','RESOLVED','Pushed to Master','Pushed to Stable','VERIFIED', 'Signed Off', 'Passed QA') ) AS bugs2 ORDER BY rand() LIMIT 1";
my $sth = database->prepare($sql) or die database->errstr;
$sth->execute or die $sth->errstr;
template 'randombug.tt', { 'randombug' => $sth->fetchall_arrayref };
};
-get '/needsignoff' => sub {
- my $sql = "SELECT bugs.bug_id,short_desc FROM bugs
- WHERE bug_status ='Needs Signoff' ORDER by lastdiffed limit 5;";
- my $sth = database->prepare($sql) or die database->errstr;
- $sth->execute or die $sth->errstr;
- template 'needsignoff.tt', { 'needsignoff' => $sth->fetchall_arrayref };
-
-};
+#-------------------------------
true;
View
@@ -6,10 +6,17 @@ use warnings;
use LWP::Simple;
use XML::Simple;
+use Dancer::Debug;
+
use DateTime;
+use Data::Dumper;
+
require Exporter;
+#use Dancer;
+#set log => 'debug';
+
our @ISA = qw(Exporter);
# This allows declaration use KC::Data ':all';
@@ -18,18 +25,17 @@ our @ISA = qw(Exporter);
our %EXPORT_TAGS = (
'all' => [
qw(
- get_dates get_devs ohloh_activity
+ get_dates ohloh_activity ohloh_devs
)
]
);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
-
our @EXPORT = qw(
);
-our $VERSION = '0.01';
+our $VERSION = '0.02';
sub get_dates {
@@ -46,22 +52,9 @@ sub get_dates {
if ( $date gt $today ) {
push @dates, $daterow;
}
-
}
close $FH;
return \@dates;
-
-}
-
-sub get_devs {
- open( my $FH, '<', 'data/devs.txt' );
- my @devs;
- while ( my $line = <$FH> ) {
- my $devrow = { 'dev' => $line };
- push @devs, $devrow;
- }
- close $FH;
- return \@devs;
}
sub ohloh_activity {
@@ -75,8 +68,43 @@ sub ohloh_activity {
my $xml = eval { XMLin($response) } or return;
# was the request a success?
- return
- unless $xml->{status} eq 'success';
+ return unless $xml->{status} eq 'success';
return $xml;
}
+
+sub ohloh_devs {
+ my $url =
+"http://www.ohloh.net/p/koha/contributors.xml?api_key=ad98f4080e21c596b62c9315f6c7a4c8b08af082&sort=newest";
+
+ # get the url from the server
+ my $response = get $url or return;
+ # parse the XML response
+ my $xml = eval { XMLin($response) } or return;
+ # was the request a success?
+ return unless $xml->{status} eq 'success';
+
+ my @a1;
+ my $i = 0;
+ while ( $i <= 10 ) {
+
+ my $date =
+ $xml->{'result'}->{'contributor_fact'}->[$i]->{'first_commit_time'};
+ $date =~ s/T.*//;
+
+ my $o2 = {
+ 'name' => $xml->{'result'}->{'contributor_fact'}->[$i]
+ ->{'contributor_name'},
+ 'date' => $date,
+ 'id' =>
+ $xml->{'result'}->{'contributor_fact'}->[$i]->{'contributor_id'},
+ };
+ push @a1, $o2;
+ $i++;
+ }
+
+ #print Dumper $xml;
+ return \@a1;
+
+}
+
__END__
Oops, something went wrong.

0 comments on commit 850b2dd

Please sign in to comment.