Compare commits

..

No commits in common. "mostly-working-CRUD-but-a-mess" and "master" have entirely different histories.

5 changed files with 5 additions and 54 deletions

View file

@ -65,7 +65,7 @@ GEM
puma (6.6.1)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.2.1)
rack (3.2.0)
rack-test (2.2.0)
rack (>= 1.3)
rainbow (3.1.1)
@ -78,7 +78,7 @@ GEM
listen (~> 3.0)
roda (3.95.0)
rack
rubocop (1.80.1)
rubocop (1.80.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
@ -93,7 +93,7 @@ GEM
parser (>= 3.3.7.2)
prism (~> 1.4)
ruby-progressbar (1.13.0)
sequel (5.96.0)
sequel (5.95.1)
bigdecimal
sqlite3 (2.7.3-aarch64-linux-gnu)
sqlite3 (2.7.3-aarch64-linux-musl)

30
app.rb
View file

@ -11,7 +11,6 @@ require_relative 'models/assistant'
class App < Roda
plugin :render, escape: true
plugin :sessions, secret: ENV.delete('APP_SESSION_SECRET')
plugin :all_verbs
route do |r|
r.root do
@ -28,41 +27,14 @@ class App < Roda
@assistant = Assistant.new
view :edit
end
r.get ':id/edit' do |id|
@page_title = 'Edit Assistant'
@assistant = Assistant[id]
if @assistant.nil?
r.halt(404)
else
view :edit
end
end
r.post do
@assistant = Assistant.new(r.params)
if @assistant.save
r.redirect '/'
else
@page_title = 'Create New Assistant'
view :edit
end
end
r.put ':id' do |id|
@assistant = Assistant[id]
if @assistant && @assistant.update(r.params)
r.redirect '/'
r.redirect '/' # change to just r.redirect when get a host.org/assistants page up
else
r.halt(404)
end
end
r.delete ':id' do |id|
@assistant = Assistant[id]
@assistant.destroy if @assistant
r.redirect '/'
end
end
end
end

View file

@ -14,7 +14,6 @@ Sequel.migration do
String :capabilities
String :test_results
DateTime :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP
DateTime :updated_at
end
end
end

View file

@ -11,7 +11,6 @@ class Assistant < Sequel::Model
def validate
super
errors.add(:name, 'must be present') if name.nil? || name.empty?
errors.add(:run_command, 'must be present') if run_command.nil? || run_command.empty?
end
# Optional: Add custom methods for common operations
@ -19,16 +18,7 @@ class Assistant < Sequel::Model
where(name: name).first
end
def self.find_by_run_command(run_command)
where(run_command: run_command).first
end
def self.active
where(active: true)
end
# Helper to check if this is a new record
def new?
id.nil?
end
end

View file

@ -12,7 +12,6 @@
<th>Evaluation Rate</th>
<th>Capabilities</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@ -26,13 +25,6 @@
<td><%= assistant.eval_rate || 'N/A' %></td>
<td><%= assistant.capabilities || 'N/A' %></td>
<td><%= assistant.created_at.strftime('%Y-%m-%d %H:%M') if assistant.created_at %></td>
<td>
<a class="button is-small is-info" href="/assistants/<%= assistant.id %>/edit">Edit</a>
<form method="post" action="/assistants/<%= assistant.id %>" style="display:inline;">
<input type="hidden" name="_method" value="delete">
<button class="button is-small is-danger" type="submit" onclick="return confirm('Are you sure?')">Delete</button>
</form>
</td>
</tr>
<% end %>
</tbody>
@ -40,5 +32,3 @@
<% else %>
<p>No assistants found in the database.</p>
<% end %>
<p><a class="button is-primary" href="/assistants/new">Add New Assistant</a></p>