Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
melezhik committed Jan 9, 2024
1 parent 3f72ca5 commit c329760
Showing 1 changed file with 10 additions and 62 deletions.
72 changes: 10 additions & 62 deletions bin/sparky-web.raku
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class MyBasicAuth does Cro::HTTP::Auth::Basic[MyUser, "username"] {

sub create-cro-app ($pool) {

my $chat = Supplier.new;
my $application = route {

before MyBasicAuth.new;
Expand All @@ -40,18 +39,16 @@ sub create-cro-app ($pool) {
supply {
my $last_e = 0;
whenever $incoming -> $message {
#$chat.emit(await $message.body-text);
my $done = False;
while True {
my @data = "$reports-dir/$project/build-$build_id.txt".IO.lines;
for @data[$last_e .. *] -> $l {
say("ws: send data to client: $l");
#my $msg = Cro::WebSocket::Message.new(
# :!fragmented,
# :body($l)
#);
#$chat.emit($l);
emit($l);
my $msg = "{$l}";
if sparky-api-token() {
$msg.=subst(sparky-api-token(),"*******",:g);
}
emit($msg);
}
$last_e = @data.elems;
#$done = True;
Expand Down Expand Up @@ -99,8 +96,12 @@ sub create-cro-app ($pool) {
#not-found();
}
}
done if $done;

if $done {
emit "================";
emit ">>> FINISHED <<<";
done
}
}
}
}
Expand Down Expand Up @@ -488,59 +489,6 @@ sub create-cro-app ($pool) {

}

get -> 'report2', $project, $build_id {

if "$reports-dir/$project/build-$build_id.txt".IO ~~ :f {

my $dbh = $pool ?? $pool.get-connection() !! get-dbh();

my $sth = $dbh.prepare("SELECT state, description, dt, job_id FROM builds where id = {$build_id}");

$sth.execute();

my @r = $sth.allrows(:array-of-hash);

my $state = @r[0]<state>;

my $dt = @r[0]<dt>;

my $description = @r[0]<description>;

my $key = @r[0]<job_id>;

$sth.finish;

$dbh.dispose;

my $data = "$reports-dir/$project/build-$build_id.txt".IO.slurp;

if sparky-api-token() {

$data.=subst(sparky-api-token(),"*******",:g);

}

template 'templates/report2.crotmp', {
css => css(),
navbar => navbar(),
http-root => sparky-http-root(),
sparky-host => "10.7.98.245", # fix me
sparky-tcp-port => sparky-tcp-port(),
project => $project,
build_id => $build_id,
job_id => "{$key}",
dt => $dt,
description => $description,
data => $data
}

} else {
not-found();
}

}


get -> 'status', $project, $key {

if trigger-exists($root,$project,$key) {
Expand Down

0 comments on commit c329760

Please sign in to comment.