labimotion 2.2.0.rc2 → 2.2.0.rc3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 201e0597dc0d1a272ec2a74ffd387add0788c96cf31605c32ab1105c8c88fe40
4
- data.tar.gz: 0bb95660dda6cb62c0449b80c0f73b1cae37e21490c671519dd53065c74b968e
3
+ metadata.gz: cb971ee12b9b92fde6ca26d8f0a0bd985394818a288737a2f81cb59aba287e2f
4
+ data.tar.gz: 2c46c6d66d83862000fbf793ecfac276ce8a3c2a227fb10262645bc30f849c5f
5
5
  SHA512:
6
- metadata.gz: 3cab6e2a1d8405d9dc53e7fe352c1bcd28ac7c2af742a1deec806e15895440d502921e15426d85f181835a241fb84e3c17605637046aae428d19b5e6e65b5905
7
- data.tar.gz: 66aad0cd9770ff0db4b6d17b6224b997ed67726517416f100c24edeb5bbe989d79ca0b54028909529e9eca24dc88ce81a967f452c7198dbaa6cc725de1d57e1c
6
+ metadata.gz: afe6d72ca32cf16a795f71f9aee7b757f1cdd7cb6b7703885c6d24912f1f73a800da0455183fc1cc9944511d2f090c4c99ee8933f83aea02e81b11b5b982bd17
7
+ data.tar.gz: 42f7025b7f47dab2554ab2b39992e978ff9c3e63959f0fe5342f5c4c09bb64b2a6525c9d2355eb4f7b77a6a9881c4a6ce594997b3ff773fcefea64dcb7f9162f
@@ -70,9 +70,120 @@ 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
73
155
  end
74
156
 
75
- namespace :create_mtt_request do
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
186
+ end
76
187
  desc 'Create MTT assay request'
77
188
  params do
78
189
  use :create_mtt_request_params
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '2.2.0.rc2'
5
+ VERSION = '2.2.0.rc3'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: labimotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.rc2
4
+ version: 2.2.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chia-Lin Lin