about summary refs log tree commit diff
path: root/lib/jitterbug/Task.pm
blob: b435de3560590ed1d8c8bbda0992bcca4cfe47d4 (plain) (blame)
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
package jitterbug::Task;

use Dancer ':syntax';
use Dancer::Plugin::DBIC;
use jitterbug::Plugin::Template;

get '/:task_id' => sub {
    my $task_id = params->{task_id};

    my $task = schema->resultset('Task')->find($task_id);
    my $commit =
      schema->resultset('Commit')->find( { sha256 => $task->sha256 } );

    if (!$task) {
        send_error("task does not exist!", 404);
    }

    if (!$commit){
        render_error("commit doesn't exists", 404);
    }

    my $content = from_json($commit->content);
    template 'task/index', {task => $task, commit => $content };
};

1;