labimotion 2.2.0.rc2 → 2.2.0.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/labimotion/apis/mtt_api.rb +113 -0
- data/lib/labimotion/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7cc7c70f57932c158e55ee04ec5abe32ea9991468bc6efcd82a8409ed19cedb2
|
|
4
|
+
data.tar.gz: 12afc9b342dab9003162ca09a4fb50211b5dea1a978f1390761233d299ec09f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 31c66a67385d571938cc3b343b89336c38d724f58c71230884e6fa134ee9da8693b83985dc1f8633a7b2a8054e02fff70d537da9476e2e50a486bcb7c98ff483
|
|
7
|
+
data.tar.gz: c155b3eebba77d5899bd25f84656008c263fefdf351a2e5857a7d019e331252b18a6c5a377a9a47f2b1fdeca7795e1df3e3440ff07bd34f0d3fab1594f2ae879
|
|
@@ -70,6 +70,119 @@ module Labimotion
|
|
|
70
70
|
}
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
|
+
|
|
74
|
+
desc 'Delete one or multiple MTT requests'
|
|
75
|
+
params do
|
|
76
|
+
requires :ids, type: Array[Integer], desc: 'Array of request IDs to delete'
|
|
77
|
+
end
|
|
78
|
+
delete do
|
|
79
|
+
# Find requests belonging to current user
|
|
80
|
+
requests = Labimotion::DoseRespRequest.where(
|
|
81
|
+
id: params[:ids],
|
|
82
|
+
created_by: current_user.id
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
if requests.empty?
|
|
86
|
+
error!('No requests found or unauthorized', 404)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
deleted_count = requests.count
|
|
90
|
+
requests.destroy_all
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
success: true,
|
|
94
|
+
message: "Successfully deleted #{deleted_count} request(s)",
|
|
95
|
+
deleted_count: deleted_count
|
|
96
|
+
}
|
|
97
|
+
rescue StandardError => e
|
|
98
|
+
error!("Error deleting requests: #{e.message}", 500)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
desc 'Update MTT request'
|
|
102
|
+
params do
|
|
103
|
+
requires :id, type: Integer, desc: 'Request ID'
|
|
104
|
+
optional :state, type: Integer, desc: 'State (-1: error, 0: initial, 1: processing, 2: completed)', values: [-1, 0, 1, 2]
|
|
105
|
+
optional :resp_message, type: String, desc: 'Response message'
|
|
106
|
+
optional :wellplates_metadata, type: Hash, desc: 'Wellplates metadata'
|
|
107
|
+
optional :input_metadata, type: Hash, desc: 'Input metadata'
|
|
108
|
+
optional :revoked, type: Boolean, desc: 'Revoke access token'
|
|
109
|
+
end
|
|
110
|
+
patch ':id' do
|
|
111
|
+
# Find request belonging to current user
|
|
112
|
+
request = Labimotion::DoseRespRequest.find_by(
|
|
113
|
+
id: params[:id],
|
|
114
|
+
created_by: current_user.id
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
error!('Request not found or unauthorized', 404) unless request
|
|
118
|
+
|
|
119
|
+
# Prepare update attributes
|
|
120
|
+
update_attrs = {}
|
|
121
|
+
update_attrs[:state] = params[:state] if params.key?(:state)
|
|
122
|
+
update_attrs[:resp_message] = params[:resp_message] if params.key?(:resp_message)
|
|
123
|
+
update_attrs[:wellplates_metadata] = params[:wellplates_metadata] if params.key?(:wellplates_metadata)
|
|
124
|
+
update_attrs[:input_metadata] = params[:input_metadata] if params.key?(:input_metadata)
|
|
125
|
+
update_attrs[:revoked_at] = params[:revoked] ? Time.current : nil if params.key?(:revoked)
|
|
126
|
+
|
|
127
|
+
if request.update(update_attrs)
|
|
128
|
+
{
|
|
129
|
+
success: true,
|
|
130
|
+
message: 'Request updated successfully',
|
|
131
|
+
request: {
|
|
132
|
+
id: request.id,
|
|
133
|
+
request_id: request.request_id,
|
|
134
|
+
state: request.state,
|
|
135
|
+
state_name: case request.state
|
|
136
|
+
when Labimotion::DoseRespRequest::STATE_ERROR then 'error'
|
|
137
|
+
when Labimotion::DoseRespRequest::STATE_INITIAL then 'initial'
|
|
138
|
+
when Labimotion::DoseRespRequest::STATE_PROCESSING then 'processing'
|
|
139
|
+
when Labimotion::DoseRespRequest::STATE_COMPLETED then 'completed'
|
|
140
|
+
else 'unknown'
|
|
141
|
+
end,
|
|
142
|
+
resp_message: request.resp_message,
|
|
143
|
+
revoked: request.revoked?,
|
|
144
|
+
updated_at: request.updated_at
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else
|
|
148
|
+
error!("Validation error: #{request.errors.full_messages.join(', ')}", 422)
|
|
149
|
+
end
|
|
150
|
+
rescue ActiveRecord::RecordNotFound
|
|
151
|
+
error!('Request not found', 404)
|
|
152
|
+
rescue StandardError => e
|
|
153
|
+
error!("Error updating request: #{e.message}", 500)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
namespace :outputs do
|
|
158
|
+
desc 'Delete one or multiple MTT outputs'
|
|
159
|
+
params do
|
|
160
|
+
requires :ids, type: Array[Integer], desc: 'Array of output IDs to delete'
|
|
161
|
+
end
|
|
162
|
+
delete do
|
|
163
|
+
# Find outputs where the parent request belongs to current user
|
|
164
|
+
outputs = Labimotion::DoseRespOutput
|
|
165
|
+
.joins(:dose_resp_request)
|
|
166
|
+
.where(
|
|
167
|
+
id: params[:ids],
|
|
168
|
+
dose_resp_requests: { created_by: current_user.id }
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
if outputs.empty?
|
|
172
|
+
error!('No outputs found or unauthorized', 404)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
deleted_count = outputs.count
|
|
176
|
+
outputs.destroy_all
|
|
177
|
+
|
|
178
|
+
{
|
|
179
|
+
success: true,
|
|
180
|
+
message: "Successfully deleted #{deleted_count} output(s)",
|
|
181
|
+
deleted_count: deleted_count
|
|
182
|
+
}
|
|
183
|
+
rescue StandardError => e
|
|
184
|
+
error!("Error deleting outputs: #{e.message}", 500)
|
|
185
|
+
end
|
|
73
186
|
end
|
|
74
187
|
|
|
75
188
|
namespace :create_mtt_request do
|
data/lib/labimotion/version.rb
CHANGED