... | ... |
@@ -180,9 +180,13 @@ sub startup { |
180 | 180 |
{table => 'project', primary_key => ['user_id', 'name']}, |
181 | 181 |
{table => 'number', primary_key => 'key'}, |
182 | 182 |
{table => 'collaboration', primary_key => ['user_id', 'project_name', 'collaborator_id']}, |
183 |
- {table => 'pull_request'} |
|
183 |
+ { |
|
184 |
+ table => 'pull_request', |
|
185 |
+ join => ['left join user on pull_request.open_user = user.row_id'] |
|
186 |
+ } |
|
184 | 187 |
]; |
185 | 188 |
$dbi->create_model($_) for @$models; |
189 |
+ $dbi->setup_model; |
|
186 | 190 |
|
187 | 191 |
# Validator |
188 | 192 |
my $vc = Validator::Custom->new; |
... | ... |
@@ -601,7 +601,7 @@ EOS |
601 | 601 |
"title not null default ''", |
602 | 602 |
"message not null default ''", |
603 | 603 |
"open integer default 0", |
604 |
- "open_time integer default 0'", |
|
604 |
+ "open_time integer default 0", |
|
605 | 605 |
"open_user integer default 0" |
606 | 606 |
); |
607 | 607 |
for my $column (@pull_request_columns) { |
... | ... |
@@ -609,7 +609,7 @@ EOS |
609 | 609 |
} |
610 | 610 |
|
611 | 611 |
# Check pull_request table |
612 |
- eval { $dbi->select([qw/row_id project branch1 branch2 title message open/], table => 'pull_request') }; |
|
612 |
+ eval { $dbi->select([qw/row_id project branch1 branch2 title message open open_time open_user/], table => 'pull_request') }; |
|
613 | 613 |
if ($@) { |
614 | 614 |
my $error = "Can't create pull_request table properly: $@"; |
615 | 615 |
$self->app->log->error($error); |
... | ... |
@@ -38,13 +38,22 @@ |
38 | 38 |
return; |
39 | 39 |
} |
40 | 40 |
else { |
41 |
+ my $now_tm = Time::Moment->now_utc; |
|
42 |
+ my $now_epoch = $now_tm->epoch; |
|
43 |
+ my $user_row_id = app->dbi->model('user')->select( |
|
44 |
+ 'row_id', |
|
45 |
+ where => {id => $user} |
|
46 |
+ )->value; |
|
47 |
+ |
|
41 | 48 |
my $new_pull_request_params = { |
42 | 49 |
project => $project_row_id, |
43 | 50 |
branch1 => $from_rev, |
44 | 51 |
branch2 => $rev, |
45 | 52 |
title => $title, |
46 | 53 |
message => $message, |
47 |
- open => 1 |
|
54 |
+ open => 1, |
|
55 |
+ open_time => $now_epoch, |
|
56 |
+ open_user => $user_row_id |
|
48 | 57 |
}; |
49 | 58 |
|
50 | 59 |
app->dbi->model('pull_request')->insert($new_pull_request_params); |
... | ... |
@@ -10,7 +10,13 @@ |
10 | 10 |
my $git = $self->app->git; |
11 | 11 |
|
12 | 12 |
# Pull requests |
13 |
- my $pull_requests = app->dbi->model('pull_request')->select(where => {open => 1})->all; |
|
13 |
+ my $pull_requests = app->dbi->model('pull_request')->select( |
|
14 |
+ [ |
|
15 |
+ {__MY__ => '*'}, |
|
16 |
+ {user => ['id']} |
|
17 |
+ ], |
|
18 |
+ where => {open => 1} |
|
19 |
+ )->all; |
|
14 | 20 |
|
15 | 21 |
# Open count |
16 | 22 |
my $open_count = app->dbi->model('pull_request')->select('count(*)', where => {open => 1})->value; |
... | ... |
@@ -35,14 +41,21 @@ |
35 | 41 |
% if (@$pull_requests) { |
36 | 42 |
<ul> |
37 | 43 |
% for my $pull_request (@$pull_requests) { |
38 |
- % my $branch2 = $pull_request->{branch2}; |
|
39 |
- % my $commit = app->git->get_commit(app->rep_info($user, $project), $branch2); |
|
44 |
+ <% |
|
45 |
+ my $branch2 = $pull_request->{branch2}; |
|
46 |
+ my $commit = app->git->get_commit(app->rep_info($user, $project), $branch2); |
|
47 |
+ my $open_time = $pull_request->{open_time}; |
|
48 |
+ my $open_time_age = Time::Moment->now_utc->epoch - $open_time; |
|
49 |
+ my $open_time_age_string = $self->app->git->_age_string($open_time_age); |
|
50 |
+ %> |
|
40 | 51 |
<li> |
41 | 52 |
<div class="pulls-title"> |
42 | 53 |
<b><%= $pull_request->{title} %></b> |
43 | 54 |
</div> |
44 | 55 |
<div class="pulls-description"> |
45 | 56 |
#<%= $pull_request->{row_id} %> <%= $pull_request->{open} ? 'opened' : 'closed' %> |
57 |
+ <%= $open_time_age_string %> |
|
58 |
+ by <%= $pull_request->{'user.id'} %> |
|
46 | 59 |
</div> |
47 | 60 |
</li> |
48 | 61 |
% } |