Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,42 @@ jobs:
rustc --version
cargo --version

- restore_cache:
keys:
- v1-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}
- v1-cargo-

- run:
name: Build widget renderer (Rust)
command: |
source $HOME/.cargo/env
cargo build --release --manifest-path ext/widget_renderer/Cargo.toml

- run:
name: Verify Rust native library linkage
command: |
set -euo pipefail
LIB=ext/widget_renderer/target/release/libwidget_renderer.so
if [ -f "$LIB" ]; then
echo "Found built rust library; verifying linkage..."
if ldd "$LIB" 2>&1 | grep -q "not found"; then
echo "ERROR: Rust library has unresolved dependencies (ldd shows 'not found')."
ldd "$LIB" || true
exit 1
else
echo "Rust library linkage looks good"
fi
else
echo "No Rust library built - skipping linkage verification"
fi

- save_cache:
paths:
- ext/widget_renderer/target
- ~/.cargo/registry
- ~/.cargo/git
key: v1-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}

# Download and cache dependencies
- restore_cache:
keys:
Expand Down
7 changes: 5 additions & 2 deletions app/models/cx_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def duplicate!(new_user:)
end

def self.to_csv
collections = all.includes(:organization, :service_provider, :service, :user).references(:organization).order(:fiscal_year, :quarter, 'organizations.name')
collections = all
.includes(:organization, :service, :user, :cx_collection_details, service_provider: :organization)
.references(:organization)
.order(:fiscal_year, :quarter, 'organizations.name')

attributes = %i[
id
Expand Down Expand Up @@ -118,7 +121,7 @@ def self.to_csv
csv << attributes

collections.each do |collection|
csv << attributes = [
csv << [
collection.id,
collection.name,
collection.organization_id,
Expand Down
4 changes: 3 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class User < ApplicationRecord

def cx_collections
user_org = organization
user_parent_org = user_org&.parent
return CxCollection.none if user_org.nil?

user_parent_org = user_org.parent

CxCollection.where(cx_collections: { organization_id: [user_org.id, user_parent_org&.id].compact })
end
Comment on lines 20 to 27
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix for the nil organization handling looks correct and addresses the production bug. However, this critical method now lacks test coverage. Consider adding tests to verify:

  1. The method returns an empty collection when the user has no organization
  2. The method correctly queries collections when the user has an organization
  3. The method correctly includes parent organization collections when applicable

The user_spec.rb file has comprehensive test coverage for other User methods, so adding tests here would maintain consistency.

Copilot uses AI. Check for mistakes.
Expand Down
16 changes: 16 additions & 0 deletions db/migrate/20251210192727_add_indexes_to_cx_collections.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class AddIndexesToCxCollections < ActiveRecord::Migration[8.0]
def change
# cx_collections table - missing all FK indexes
add_index :cx_collections, :organization_id
add_index :cx_collections, :user_id
add_index :cx_collections, :service_provider_id
add_index :cx_collections, :service_id

# cx_collection_details table - missing FK index
add_index :cx_collection_details, :cx_collection_id

# cx_responses table - missing FK indexes
add_index :cx_responses, :cx_collection_detail_id
add_index :cx_responses, :cx_collection_detail_upload_id
end
end
9 changes: 8 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2025_07_17_034402) do
ActiveRecord::Schema[8.0].define(version: 2025_12_10_192727) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"

Expand Down Expand Up @@ -97,6 +97,7 @@
t.text "trust_question_text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["cx_collection_id"], name: "index_cx_collection_details_on_cx_collection_id"
end

create_table "cx_collections", force: :cascade do |t|
Expand Down Expand Up @@ -124,6 +125,10 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "submitted_at"
t.index ["organization_id"], name: "index_cx_collections_on_organization_id"
t.index ["service_id"], name: "index_cx_collections_on_service_id"
t.index ["service_provider_id"], name: "index_cx_collections_on_service_provider_id"
t.index ["user_id"], name: "index_cx_collections_on_user_id"
end

create_table "cx_responses", force: :cascade do |t|
Expand All @@ -149,6 +154,8 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "external_id"
t.index ["cx_collection_detail_id"], name: "index_cx_responses_on_cx_collection_detail_id"
t.index ["cx_collection_detail_upload_id"], name: "index_cx_responses_on_cx_collection_detail_upload_id"
end

create_table "digital_product_versions", force: :cascade do |t|
Expand Down
Loading