summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/checkpoints_controller.rb2
-rw-r--r--app/views/checkpoints/new.html.erb11
-rw-r--r--app/views/runs/show.html.erb11
-rw-r--r--db/migrate/20231102223203_remove_title_from_checkpoints.rb11
-rw-r--r--db/schema.rb5
-rw-r--r--test/fixtures/checkpoints.yml6
6 files changed, 26 insertions, 20 deletions
diff --git a/app/controllers/checkpoints_controller.rb b/app/controllers/checkpoints_controller.rb
index ef53a6b..07c1a5a 100644
--- a/app/controllers/checkpoints_controller.rb
+++ b/app/controllers/checkpoints_controller.rb
@@ -18,7 +18,7 @@ class CheckpointsController < ApplicationController
protected
def checkpoint_params
- params.require(:checkpoint).permit(:title, :description, :save_file, :kind)
+ params.require(:checkpoint).permit(:comment, :save_file, :kind)
end
def set_run
diff --git a/app/views/checkpoints/new.html.erb b/app/views/checkpoints/new.html.erb
index 712eae1..b11a9bc 100644
--- a/app/views/checkpoints/new.html.erb
+++ b/app/views/checkpoints/new.html.erb
@@ -5,17 +5,12 @@
<%= form_with model: [@run, @checkpoint], class: "space-y-4" do |f| %>
<div>
- <%= f.label :title %>
- <%= f.text_field :title %>
+ <div><%= f.label :comment %></div>
+ <%= f.text_area :comment %>
</div>
<div>
- <%= f.label :description %>
- <%= f.text_area :description %>
- </div>
-
- <div>
- <%= f.label :save_file %>
+ <div><%= f.label :save_file %></div>
<%= f.file_field :save_file %>
</div>
diff --git a/app/views/runs/show.html.erb b/app/views/runs/show.html.erb
index d7d65b6..55bef02 100644
--- a/app/views/runs/show.html.erb
+++ b/app/views/runs/show.html.erb
@@ -23,8 +23,8 @@
<h2 class="text-xl">Checkpoints</h2>
<%= link_to "New checkpoint", new_run_checkpoint_path(@run) %>
- <div class="border-l border-orange-900 p-2">
- <% @run.checkpoints.each do |checkpoint| %>
+ <% @run.checkpoints.order(:created_at).reverse.each do |checkpoint| %>
+ <div class="border-l border-orange-900 p-2">
<div class="flex flex-col">
<div>
<%= time_ago_in_words(checkpoint.created_at) %> ago by
@@ -38,7 +38,10 @@
<span>(No save file attached.)</span>
<% end %>
</div>
+ <% if checkpoint.comment %>
+ <div><%= checkpoint.comment %></div>
+ <% end %>
</div>
- <% end %>
- </div>
+ </div>
+ <% end %>
</div>
diff --git a/db/migrate/20231102223203_remove_title_from_checkpoints.rb b/db/migrate/20231102223203_remove_title_from_checkpoints.rb
new file mode 100644
index 0000000..92e54a0
--- /dev/null
+++ b/db/migrate/20231102223203_remove_title_from_checkpoints.rb
@@ -0,0 +1,11 @@
+class RemoveTitleFromCheckpoints < ActiveRecord::Migration[7.1]
+ def up
+ remove_column :checkpoints, :title
+ rename_column :checkpoints, :description, :comment
+ end
+
+ def down
+ rename_column :checkpoints, :comment, :description
+ add_column :checkpoints, :title, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b48737d..0982ec0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2023_10_31_053134) do
+ActiveRecord::Schema[7.1].define(version: 2023_11_02_223203) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -43,8 +43,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_31_053134) do
end
create_table "checkpoints", force: :cascade do |t|
- t.string "title"
- t.text "description"
+ t.text "comment"
t.bigint "run_id", null: false
t.bigint "user_id", null: false
t.datetime "created_at", null: false
diff --git a/test/fixtures/checkpoints.yml b/test/fixtures/checkpoints.yml
index bb83377..02bb57e 100644
--- a/test/fixtures/checkpoints.yml
+++ b/test/fixtures/checkpoints.yml
@@ -1,13 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
- title: MyString
- description: MyText
+ comment: MyText
run: one
user: one
two:
- title: MyString
- description: MyText
+ comment: MyText
run: two
user: two