Skip to content

Commit

Permalink
updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
tokuhirom committed May 24, 2013
1 parent a628f34 commit 8017132
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 24 deletions.
10 changes: 9 additions & 1 deletion lib/CPANasium/Model/Aggregator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Web::Query;
use Log::Minimal;
use File::Temp ();
use Module::CPANfile::Safe;
use Time::Piece qw(localtime gmtime);

my $URL = 'https://github.com/languages/Perl/updated';

Expand Down Expand Up @@ -68,6 +69,12 @@ sub get_repo_list {
$result;
}

# @args $time '2013-05-23T04:40:16Z'
sub parse_time {
my ($self, $time) = @_;
gmtime->strptime($time, '%Y-%m-%dT%H:%M:%SZ');
}

# @args $result: Pithub::Result
sub insert {
my ($self, $result) = @_;
Expand Down Expand Up @@ -98,7 +105,8 @@ sub insert {
'description' => $row->{description},
forks => $row->{forks},
owner_login => $row->{owner}->{login},
created_on => time,
updated_at => $self->parse_time($row->{updated_at})->epoch,
created_at => $self->parse_time($row->{created_at})->epoch,
};
my $cpanfile = sprintf 'https://raw.github.com/%s/master/cpanfile', $row->{full_name}, $row->{master_branch};
infof("Fetching cpanfile from %s", $cpanfile);
Expand Down
4 changes: 2 additions & 2 deletions lib/CPANasium/Web/Dispatcher.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ any '/' => sub {
)];
}
my @authors = $c->db->search_by_sql(q{SELECT owner_login, count(*) count FROM repos GROUP BY owner_login ORDER BY count(*) DESC});
my @recent_repos = $c->db->search_by_sql(q{select full_name, created_on from repos order by id desc limit 10;});
my @recent_repos = $c->db->search_by_sql(q{select full_name, created_at, updated_at from repos order by updated_at desc limit 10;});
return $c->render('index.tt', {
deps_ranking => \%deps_ranking,
authors => \@authors,
Expand Down Expand Up @@ -43,7 +43,7 @@ get '/user/:user' => sub {
my $user = $args->{user};

my @repos = $c->db->search_by_sql(
q{SELECT * FROM repos WHERE owner_login=?},
q{SELECT * FROM repos WHERE owner_login=? order by updated_at desc},
[$user],
);

Expand Down
4 changes: 3 additions & 1 deletion sql/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ CREATE TABLE repos (
forks integer,
data text,
cpanfile text,
created_on integer
updated_at integer,
created_at integer
);
create index repos_owner_login on repos (owner_login);
create unique index repos_full_name on repos (full_name);
create index repos_updated_at on repos (updated_at);


create table deps (
Expand Down
6 changes: 3 additions & 3 deletions static/bootstrap/css/bootstrap.min.css

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tmpl/include/layout.tt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="format-detection" content="telephone=no" />
<script src="[% uri_for('/static/js/jquery-1.9.1.min.js') %]"></script>
<link href="[% uri_for('/static/bootstrap/css/bootstrap.css') %]" rel="stylesheet" type="text/css" />
<script src="[% uri_for('/static/bootstrap/js/bootstrap.js') %]"></script>
<script src="[% uri_for('/static/js/es5-shim.min.js') %]"></script>
<script src="[% uri_for('/static/js/micro_template.js') %]"></script>
<script src="[% uri_for('/static/js/strftime.js') %]"></script>
<script src="[% uri_for('/static/js/sprintf-0.7-beta1.js') %]"></script>
<script src="[% uri_for('/static/js/micro-location.js') %]"></script>
<script src="[% uri_for('/static/js/micro_dispatcher.js') %]"></script>
<link href="//netdna.bootstrapcdn.com/bootswatch/2.3.1/flatly/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet">
<link href="[% static_file('/static/css/main.css') %]" rel="stylesheet" type="text/css" media="screen" />
<script src="[% static_file('/static/js/main.js') %]"></script>
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion tmpl/index.tt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div>
<table class="table">
[% FOR v IN recent_repos %]
<tr><td>[% loop.count %]</td><td><a href="/user/[% v.full_name %]">[% v.full_name %]</a></td><td>[% localtime(v.created_on).strftime('%Y-%m-%d %H:%M:%S') %]</td></li>
<tr><td>[% loop.count %]</td><td><a href="/user/[% v.full_name %]">[% v.full_name %]</a></td><td>[% localtime(v.updated_at).strftime('%Y-%m-%d %H:%M:%S') %]</td></li>
[% END %]
</table>
</div>
Expand Down
30 changes: 17 additions & 13 deletions tmpl/repo.tt
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
[% WRAPPER 'include/layout.tt' WITH title=repo.full_name _ ' - CPANasium' %]

<h1>[% repo.full_name %]</h1>
<div class="row">
<h1>[% repo.full_name %] <a target="_blank" href="[% repo.html_url %]"><i class="icon-github-sign"></i></a></h1>
<p>[% repo.description %]</p>

<a target="_blank" href="[% repo.html_url %]">goto &amp;github;</a>
<table class="table table-hover table-bordered">
[% FOR v IN deps %]
<tr>
<td>[% v.phase %]</td>
<td>[% v.relationship %]</td>
<td><a href="/module/[% v.module %]">[% v.module %]</a></td>
<td>[% v.version %]</td>
</tr>
[% END %]
</table>

<pre>[% repo.cpanfile %]</pre>
</div>

<table class="table table-hover table-bordered">
[% FOR v IN deps %]
<tr>
<td>[% v.phase %]</td>
<td>[% v.relationship %]</td>
<td><a href="/module/[% v.module %]">[% v.module %]</a></td>
<td>[% v.version %]</td>
</tr>
[% IF c().req.param('debug') %]
<pre>[% repo.data %]</pre>
[% END %]
</table>

<pre>[% repo.cpanfile %]</pre>

[% END %]
6 changes: 4 additions & 2 deletions tmpl/user.tt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[% WRAPPER 'include/layout.tt' WITH title=user _ ' - CPANasium' %]

<h1>[% user %]'s statistics.</h1>
<h1>[% user %]'s statistics. <a href="http://github.com/[% user %]/"><i class="icon-github"></i></a></h1>

<h2>[% user %] uses these modules:</h2>

Expand All @@ -27,7 +27,9 @@
<table class="table table-hover">
[% FOR repo IN repos %]
<tr>
<td><a href="/user/[% repo.full_name %]">[% repo.name %][% IF repo.description %] - [% repo.description %][% END %]</a></td>
<td><a href="/user/[% repo.full_name %]">[% repo.name %]</a></td>
<td>[% IF repo.description %][% repo.description %][% END %]</td>
<td>[% localtime(repo.updated_at).strftime('%Y-%m-%d %H:%M') %]</td>
</tr>
[% END %]
</table>
Expand Down

0 comments on commit 8017132

Please sign in to comment.