Skip to content

Commit 19574e3

Browse files
authored
Merge branch 'main' into 231-add-job-pages
2 parents 4d93fef + b02cba5 commit 19574e3

File tree

21 files changed

+351
-31
lines changed

21 files changed

+351
-31
lines changed

.circleci/config.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,20 @@ jobs:
249249
command: |
250250
gem install bundler -v "$(grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1 | xargs)"
251251
bundle _$(grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1 | xargs)_ install
252+
- attach_workspace:
253+
at: /tmp
254+
- run:
255+
name: Load Docker image from build-image
256+
command: |
257+
if [ -f /tmp/docker-image.tar ]; then
258+
docker load -i /tmp/docker-image.tar
259+
else
260+
echo "No persisted image found; falling back to local build"
261+
docker-compose -f docker-compose.yml build
262+
fi
252263
- run:
253-
name: Build and run containers
254-
command: docker-compose -f docker-compose.yml build && docker-compose -f docker-compose.yml up --force-recreate -d
264+
name: Start services (no-build when image available)
265+
command: docker-compose -f docker-compose.yml up --force-recreate -d --no-build
255266
- run:
256267
name: Wait for mysql to be ready
257268
command: docker-compose exec web bash ./wait_for_db.sh
@@ -284,11 +295,7 @@ workflows:
284295
name: build-image
285296
context:
286297
- org-global
287-
filters:
288-
branches:
289-
only:
290-
- main
291-
- /preview\/.*/
298+
292299
- deploy-application:
293300
name: deploy-application
294301
context:
@@ -329,8 +336,6 @@ workflows:
329336
name: test-application
330337
context:
331338
- org-global
332-
filters:
333-
branches:
334-
only:
335-
- main
336-
- /preview\/.*/
339+
requires:
340+
- build-image
341+

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ inherit_gem:
44
Metrics/BlockLength:
55
Exclude:
66
- 'config/environments/development.rb'
7+
- 'app/models/api_user.rb'
8+
- 'app/models/job.rb'
9+
- 'config/routes.rb'
710

811
Metrics/CyclomaticComplexity:
912
Exclude:
@@ -23,6 +26,10 @@ RSpec/MultipleMemoizedHelpers:
2326
RSpec/NestedGroups:
2427
Enabled: false
2528

29+
Layout/LineLength:
30+
Exclude:
31+
- 'spec/models/unit_spec.rb'
32+
2633
# Rubocop doesn't seem to understand the rswag DSL.
2734
# Exclude the rswag spec file spec/requests/api/v1/api-docs/jobs_spec.rb
2835
# from RSpec/EmptyExampleGroup. Without this, autocorrect will delete

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM harbor.k8s.libraries.psu.edu/library/ruby-3.4.1-node-22:20250825 AS base
1+
FROM harbor.k8s.libraries.psu.edu/library/ruby-3.4.1-node-22:20260202 AS base
22
ARG UID=3000
33

44
USER root

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ gem 'rails', '~> 7.2.2', '>= 7.2.2.1'
99

1010
gem 'shakapacker'
1111
# Use mysql as the database for Active Record
12-
gem 'mysql2'
12+
gem 'mysql2', '~> 0.5.7'
1313
# Use the Puma web server [https://github.com/puma/puma]
1414
gem 'puma', '>= 5.0'
1515
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
@@ -78,6 +78,8 @@ group :test do
7878
gem 'shoulda-matchers'
7979
end
8080

81+
gem 'rails_admin'
8182
gem 'rails_warden', '~> 0.6.0'
8283

8384
gem 'bugsnag', '~> 6.28'
85+
gem 'sassc-rails'

Gemfile.lock

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ GEM
5050
globalid (>= 0.3.6)
5151
activemodel (7.2.2.2)
5252
activesupport (= 7.2.2.2)
53+
activemodel-serializers-xml (1.0.3)
54+
activemodel (>= 5.0.0.a)
55+
activesupport (>= 5.0.0.a)
56+
builder (~> 3.1)
5357
activerecord (7.2.2.2)
5458
activemodel (= 7.2.2.2)
5559
activesupport (= 7.2.2.2)
@@ -131,6 +135,7 @@ GEM
131135
concurrent-ruby (1.3.5)
132136
connection_pool (2.5.4)
133137
crass (1.0.6)
138+
csv (3.3.5)
134139
date (3.4.1)
135140
debug (1.11.0)
136141
irb (~> 1.10)
@@ -185,6 +190,18 @@ GEM
185190
json-schema (5.2.2)
186191
addressable (~> 2.8)
187192
bigdecimal (~> 3.1)
193+
kaminari (1.2.2)
194+
activesupport (>= 4.1.0)
195+
kaminari-actionview (= 1.2.2)
196+
kaminari-activerecord (= 1.2.2)
197+
kaminari-core (= 1.2.2)
198+
kaminari-actionview (1.2.2)
199+
actionview
200+
kaminari-core (= 1.2.2)
201+
kaminari-activerecord (1.2.2)
202+
activerecord
203+
kaminari-core (= 1.2.2)
204+
kaminari-core (1.2.2)
188205
language_server-protocol (3.17.0.5)
189206
lint_roller (1.1.0)
190207
logger (1.7.0)
@@ -203,7 +220,9 @@ GEM
203220
mini_mime (1.1.5)
204221
minitest (5.25.5)
205222
msgpack (1.8.0)
206-
mysql2 (0.5.6)
223+
mysql2 (0.5.7)
224+
bigdecimal
225+
nested_form (0.3.2)
207226
net-http (0.6.0)
208227
uri
209228
net-imap (0.5.10)
@@ -282,6 +301,13 @@ GEM
282301
rails-html-sanitizer (1.6.2)
283302
loofah (~> 2.21)
284303
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
304+
rails_admin (3.3.0)
305+
activemodel-serializers-xml (>= 1.0)
306+
csv
307+
kaminari (>= 0.14, < 2.0)
308+
nested_form (~> 0.3)
309+
rails (>= 6.0, < 9)
310+
turbo-rails (>= 1.0, < 3)
285311
rails_warden (0.6.0)
286312
warden (>= 1.2.0)
287313
railties (7.2.2.2)
@@ -387,6 +413,14 @@ GEM
387413
sass-listen (4.0.0)
388414
rb-fsevent (~> 0.9, >= 0.9.4)
389415
rb-inotify (~> 0.9, >= 0.9.7)
416+
sassc (2.4.0)
417+
ffi (~> 1.9)
418+
sassc-rails (2.1.2)
419+
railties (>= 4.0.0)
420+
sassc (>= 2.0)
421+
sprockets (> 3.0)
422+
sprockets-rails
423+
tilt
390424
scss_lint (0.60.0)
391425
sass (~> 3.5, >= 3.5.5)
392426
securerandom (0.4.1)
@@ -412,11 +446,23 @@ GEM
412446
rack (>= 3.1.0)
413447
redis-client (>= 0.23.2)
414448
smart_properties (1.17.0)
449+
sprockets (4.2.2)
450+
concurrent-ruby (~> 1.0)
451+
logger
452+
rack (>= 2.2.4, < 4)
453+
sprockets-rails (3.5.2)
454+
actionpack (>= 6.1)
455+
activesupport (>= 6.1)
456+
sprockets (>= 3.0.0)
415457
stimulus-rails (1.3.4)
416458
railties (>= 6.0.0)
417459
stringio (3.1.7)
418460
thor (1.4.0)
461+
tilt (2.7.0)
419462
timeout (0.4.3)
463+
turbo-rails (2.0.23)
464+
actionpack (>= 7.1.0)
465+
railties (>= 7.1.0)
420466
tzinfo (2.0.6)
421467
concurrent-ruby (~> 1.0)
422468
unicode-display_width (3.2.0)
@@ -443,6 +489,7 @@ GEM
443489
PLATFORMS
444490
aarch64-linux
445491
arm64-darwin-24
492+
arm64-darwin-25
446493
x86_64-darwin-24
447494
x86_64-linux
448495

@@ -460,17 +507,19 @@ DEPENDENCIES
460507
faraday
461508
image_processing
462509
jbuilder
463-
mysql2
510+
mysql2 (~> 0.5.7)
464511
niftany
465512
puma (>= 5.0)
466513
rails (~> 7.2.2, >= 7.2.2.1)
514+
rails_admin
467515
rails_warden (~> 0.6.0)
468516
redis (>= 4.0.1)
469517
rspec-rails
470518
rswag-api
471519
rswag-specs
472520
rswag-ui
473521
rubocop-rails-omakase
522+
sassc-rails
474523
selenium-webdriver
475524
shakapacker
476525
shoulda-matchers

app/assets/config/manifest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
//= link_tree ../images
2-
//= link_directory ../stylesheets .css
1+
// No additional asset directories to link

app/models/api_user.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
class APIUser < ApplicationRecord
4+
belongs_to :unit, optional: true
5+
46
has_many :jobs, as: :owner, dependent: :restrict_with_exception
57
has_many :pdf_jobs, as: :owner, dependent: :restrict_with_exception
68

@@ -9,6 +11,54 @@ class APIUser < ApplicationRecord
911
validates :webhook_endpoint, presence: true
1012
validates :webhook_endpoint, format: { with: URI::RFC2396_PARSER.make_regexp('https') }
1113

14+
RailsAdmin.config do |config|
15+
config.model 'ApiUser' do
16+
list do
17+
field :id
18+
field :name
19+
field :email
20+
field :created_at
21+
field :updated_at
22+
end
23+
24+
show do
25+
field :id
26+
field :name
27+
field :email
28+
field :api_key
29+
field :webhook_key
30+
field :webhook_endpoint
31+
field :created_at
32+
field :updated_at
33+
end
34+
35+
edit do
36+
field :name
37+
field :email
38+
39+
field :api_key do
40+
read_only true
41+
help 'API keys are generated automatically'
42+
end
43+
44+
field :webhook_key do
45+
read_only true
46+
help 'Webhook keys are generated automatically'
47+
end
48+
49+
field :webhook_endpoint
50+
51+
field :created_at do
52+
read_only true
53+
end
54+
55+
field :updated_at do
56+
read_only true
57+
end
58+
end
59+
end
60+
end
61+
1262
private
1363

1464
def set_keys

app/models/gui_user.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
# frozen_string_literal: true
22

33
class GUIUser < ApplicationRecord
4+
belongs_to :unit, optional: true
5+
46
has_many :jobs, as: :owner, dependent: :restrict_with_exception
57
has_many :pdf_jobs, as: :owner, dependent: :restrict_with_exception
68
has_many :image_jobs, as: :owner, dependent: :restrict_with_exception
9+
10+
RailsAdmin.config do |config|
11+
config.model 'GuiUser' do
12+
list do
13+
field :id
14+
field :email
15+
field :created_at
16+
end
17+
18+
edit do
19+
field :email
20+
field :created_at do
21+
read_only true
22+
end
23+
field :updated_at do
24+
read_only true
25+
end
26+
end
27+
end
28+
end
729
end

app/models/job.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,39 @@ def completed?
1515
status == 'completed'
1616
end
1717

18+
RailsAdmin.config do |config|
19+
config.model 'Job' do
20+
list do
21+
field :uuid
22+
field :type
23+
field :status
24+
field :owner_type
25+
field :owner_id
26+
field :created_at
27+
field :finished_at
28+
end
29+
30+
show do
31+
field :uuid
32+
field :type
33+
field :status
34+
field :llm_model
35+
field :prompt
36+
field :alt_text
37+
field :source_url
38+
field :output_url
39+
field :output_object_key
40+
field :output_url_expires_at
41+
field :processing_error_message
42+
field :owner_type
43+
field :owner_id
44+
field :created_at
45+
field :updated_at
46+
field :finished_at
47+
end
48+
end
49+
end
50+
1851
private
1952

2053
def broadcast_to_job_channel

app/models/rails_admin.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
RailsAdmin.config do |config|
4+
config.included_models = [
5+
'GuiUser',
6+
'ApiUser',
7+
'Job'
8+
]
9+
end

0 commit comments

Comments
 (0)