Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 8204f05

Browse files
committed
pass user info
1 parent 5d95ed0 commit 8204f05

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

app/controllers/discourse_ai/ai_bot/artifact_key_values_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ def index
3737
).as_json,
3838
has_more: has_more,
3939
total_count: total_count,
40+
users:
41+
key_values
42+
.map { |kv| kv.user }
43+
.uniq
44+
.map { |u| BasicUserSerializer.new(u, root: nil).as_json },
4045
}
4146
end
4247

app/serializers/ai_artifact_key_value_serializer.rb

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

33
class AiArtifactKeyValueSerializer < ApplicationSerializer
4-
attributes :id, :key, :value, :public, :created_at, :updated_at
5-
6-
has_one :user, serializer: BasicUserSerializer
4+
attributes :id, :key, :value, :public, :user_id, :created_at, :updated_at
75

86
def include_value?
97
!options[:keys_only]

spec/requests/ai_bot/artifact_key_values_controller_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
)
6464
expect(json["has_more"]).to eq(false)
6565
expect(json["total_count"]).to eq(2)
66+
67+
expect(json["key_values"].map { |kv| kv["user_id"] }).to contain_exactly(
68+
user.id,
69+
other_user.id,
70+
)
71+
expect(json["users"].map { |u| u["id"] }).to contain_exactly(user.id, other_user.id)
6672
end
6773

6874
it "returns 404 for private artifact" do

0 commit comments

Comments
 (0)