Skip to content

Commit e970a5f

Browse files
Merge pull request #7 from KingsGambitLab/scaler/fixing_logs
fixing the redirection path for the logs
2 parents 0887657 + 55bf071 commit e970a5f

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

app/controllers/rake_ui/rake_task_logs_controller.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module RakeUi
44
class RakeTaskLogsController < ApplicationController
5+
include RakeUi::S3Client
6+
57
RAKE_TASK_LOG_ATTRS = [:id,
68
:name,
79
:args,
@@ -25,17 +27,16 @@ def index
2527
end
2628

2729
def show
28-
@rake_task_log = RakeUi::RakeTaskLog.find_by_id(params[:id])
29-
30-
@rake_task_log_content = @rake_task_log.file_contents.gsub("\n", "<br />")
31-
@rake_task_log_content_url = rake_task_log_path(@rake_task_log.id, format: :json)
32-
@is_rake_task_log_finished = @rake_task_log.finished?
30+
key_name = "#{params[:id]}.txt"
31+
@file_contents_from_s3 = RakeUi::S3Client.get_object_from_s3(bucket: S3_BUCKET, key: key_name)
32+
@rake_task_log_content = @file_contents_from_s3.gsub("\n", '<br />')
33+
@rake_task_log_content_url = rake_task_log_path(params[:id], format: :json)
34+
@is_rake_task_log_finished = @file_contents_from_s3.include?(RakeUi::RakeTaskLog::FINISHED_STRING)
3335

3436
respond_to do |format|
3537
format.html
3638
format.json do
3739
render json: {
38-
rake_task_log: rake_task_log_as_json(@rake_task_log),
3940
rake_task_log_content: @rake_task_log_content,
4041
rake_task_log_content_url: @rake_task_log_content_url,
4142
is_rake_task_log_finished: @is_rake_task_log_finished

app/models/rake_ui/rake_task.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# frozen_string_literal: true
22

33
module RakeUi
4-
S3_BUCKET = Rails.env.production? ? 'rakeuilogs'.freeze : 'rakeuilogstest'.freeze
54
class RakeTask
5+
include RakeUi::S3Client
6+
67
def self.to_safe_identifier(id)
78
CGI.escape(id)
89
end
@@ -127,7 +128,7 @@ def build_rake_command(args: nil, environment: nil)
127128
command += "#{environment} "
128129
end
129130

130-
command += "rake #{name}"
131+
command += "bundle exec rake #{name}"
131132

132133
if args
133134
command += "[#{args}]"

app/modules/rake_ui/s3_client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module RakeUi
22
module S3Client
3+
4+
S3_BUCKET = Rails.env.production? ? 'rakeuilogs'.freeze : 'rakeuilogstest'.freeze
35
class << self
46

57
def s3_client

0 commit comments

Comments
 (0)