labimotion 0.2.1 → 0.2.2
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/generic_element_api.rb +2 -2
- data/lib/labimotion/helpers/dataset_helpers.rb +3 -2
- data/lib/labimotion/helpers/element_helpers.rb +36 -9
- data/lib/labimotion/helpers/generic_helpers.rb +3 -2
- data/lib/labimotion/helpers/segment_helpers.rb +5 -4
- data/lib/labimotion/models/concerns/datasetable.rb +1 -0
- data/lib/labimotion/models/concerns/generic_klass_revisions.rb +13 -4
- data/lib/labimotion/models/concerns/segmentable.rb +1 -0
- data/lib/labimotion/utils/utils.rb +0 -1
- 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: 327103b60af0374bdfd4fa53653b2f314c3395f3a7e0277022caa9b8a5e865a3
|
|
4
|
+
data.tar.gz: 118586faba049e9b0db78533e912c1ea1143a27314e4d13395dca19469c9cecd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5efea48afcc6d27d8619039fde17de1d66db7d371f547f05a61ace9a763e7eee539dc79f4c3ff947df497233d4cca74a572d9277cc869bcaa5bae310f16ae1c
|
|
7
|
+
data.tar.gz: 3be73cae26b84356fdd1d316391552c6e82d4b63b467705d9faad843c2d706c464bf50b1ff3335255e43c76ecffb708e17748dfe659bb23a2c9c4f1ffd9e0668
|
|
@@ -225,7 +225,7 @@ module Labimotion
|
|
|
225
225
|
@klz = fetch_klass(params[:klass], params[:id])
|
|
226
226
|
end
|
|
227
227
|
post do
|
|
228
|
-
update_template(params)
|
|
228
|
+
update_template(params, current_user)
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
231
|
|
|
@@ -237,10 +237,10 @@ module Labimotion
|
|
|
237
237
|
optional :from_date, type: Integer, desc: 'created_date from in ms'
|
|
238
238
|
optional :to_date, type: Integer, desc: 'created_date to in ms'
|
|
239
239
|
optional :filter_created_at, type: Boolean, desc: 'filter by created at or updated at'
|
|
240
|
+
optional :sort_column, type: String, desc: 'sort by updated_at or selected layers property'
|
|
240
241
|
end
|
|
241
242
|
paginate per_page: 7, offset: 0, max_per_page: 100
|
|
242
243
|
get do
|
|
243
|
-
|
|
244
244
|
scope = list_serialized_elements(params, current_user)
|
|
245
245
|
|
|
246
246
|
reset_pagination_page(scope)
|
|
@@ -16,7 +16,8 @@ module Labimotion
|
|
|
16
16
|
def create_repo_klass(params, current_user)
|
|
17
17
|
response = Labimotion::TemplateHub.fetch_identifier('DatasetKlass', params[:identifier])
|
|
18
18
|
attributes = response.slice('ols_term_id', 'label', 'desc', 'uuid', 'identifier', 'properties_release', 'version') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at)
|
|
19
|
-
attributes['
|
|
19
|
+
attributes['properties_release']['identifier'] = attributes['identifier']
|
|
20
|
+
attributes['properties_template'] = attributes['properties_release']
|
|
20
21
|
attributes['place'] = ((Labimotion::DatasetKlass.all.length * 10) || 0) + 10
|
|
21
22
|
attributes['is_active'] = false
|
|
22
23
|
attributes['updated_by'] = current_user.id
|
|
@@ -29,7 +30,7 @@ module Labimotion
|
|
|
29
30
|
attributes['created_by'] = current_user.id
|
|
30
31
|
ds = Labimotion::DatasetKlass.create!(attributes)
|
|
31
32
|
end
|
|
32
|
-
ds.create_klasses_revision(current_user
|
|
33
|
+
ds.create_klasses_revision(current_user)
|
|
33
34
|
rescue StandardError => e
|
|
34
35
|
Labimotion.log_exception(e, current_user)
|
|
35
36
|
# { error: e.message }
|
|
@@ -34,7 +34,7 @@ module Labimotion
|
|
|
34
34
|
|
|
35
35
|
new_klass = Labimotion::ElementKlass.create!(attributes)
|
|
36
36
|
new_klass.reload
|
|
37
|
-
new_klass.create_klasses_revision(current_user
|
|
37
|
+
new_klass.create_klasses_revision(current_user)
|
|
38
38
|
klass_names_file = Rails.root.join('app/packs/klasses.json')
|
|
39
39
|
klasses = Labimotion::ElementKlass.where(is_active: true)&.pluck(:name) || []
|
|
40
40
|
File.write(klass_names_file, klasses)
|
|
@@ -71,6 +71,7 @@ module Labimotion
|
|
|
71
71
|
params[:properties]['klass_uuid'] = klass[:uuid]
|
|
72
72
|
params[:properties]['pkg'] = Labimotion::Utils.pkg(params[:properties]['pkg'])
|
|
73
73
|
params[:properties]['klass'] = 'Element'
|
|
74
|
+
params[:properties]['identifier'] = klass[:identifier]
|
|
74
75
|
properties = params[:properties]
|
|
75
76
|
properties.delete('flow') unless properties['flow'].nil?
|
|
76
77
|
properties.delete('flowObject') unless properties['flowObject'].nil?
|
|
@@ -247,7 +248,7 @@ module Labimotion
|
|
|
247
248
|
.where(
|
|
248
249
|
element_klasses: { name: params[:el_type] },
|
|
249
250
|
collections_elements: { collection_id: collection_id },
|
|
250
|
-
).includes(:tag, collections: :sync_collections_users)
|
|
251
|
+
).includes(:tag, collections: :sync_collections_users)
|
|
251
252
|
else
|
|
252
253
|
Labimotion::Element.none
|
|
253
254
|
end
|
|
@@ -256,10 +257,35 @@ module Labimotion
|
|
|
256
257
|
from = params[:from_date]
|
|
257
258
|
to = params[:to_date]
|
|
258
259
|
by_created_at = params[:filter_created_at] || false
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
if params[:sort_column]&.include?('.')
|
|
261
|
+
layer, field = params[:sort_column].split('.')
|
|
262
|
+
|
|
263
|
+
element_klass = Labimotion::ElementKlass.find_by(name: params[:el_type])
|
|
264
|
+
allowed_fields = element_klass.properties_release.dig('layers', layer, 'fields')&.pluck('field') || []
|
|
265
|
+
|
|
266
|
+
if field.in?(allowed_fields)
|
|
267
|
+
query = ActiveRecord::Base.sanitize_sql(
|
|
268
|
+
[
|
|
269
|
+
"LEFT JOIN LATERAL(
|
|
270
|
+
SELECT field->'value' AS value
|
|
271
|
+
FROM jsonb_array_elements(properties->'layers'->:layer->'fields') a(field)
|
|
272
|
+
WHERE field->>'field' = :field
|
|
273
|
+
) a ON true",
|
|
274
|
+
{ layer: layer, field: field },
|
|
275
|
+
],
|
|
276
|
+
)
|
|
277
|
+
scope = scope.joins(query).order('value ASC NULLS FIRST')
|
|
278
|
+
else
|
|
279
|
+
scope = scope.order(updated_at: :desc)
|
|
280
|
+
end
|
|
281
|
+
else
|
|
282
|
+
scope = scope.order(updated_at: :desc)
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
scope = scope.elements_created_time_from(Time.at(from)) if from && by_created_at
|
|
286
|
+
scope = scope.elements_created_time_to(Time.at(to) + 1.day) if to && by_created_at
|
|
287
|
+
scope = scope.elements_updated_time_from(Time.at(from)) if from && !by_created_at
|
|
288
|
+
scope = scope.elements_updated_time_to(Time.at(to) + 1.day) if to && !by_created_at
|
|
263
289
|
scope
|
|
264
290
|
rescue StandardError => e
|
|
265
291
|
Labimotion.log_exception(e, current_user)
|
|
@@ -268,8 +294,9 @@ module Labimotion
|
|
|
268
294
|
|
|
269
295
|
def create_repo_klass(params, current_user)
|
|
270
296
|
response = Labimotion::TemplateHub.fetch_identifier('ElementKlass', params[:identifier])
|
|
271
|
-
attributes = response.slice('name', 'label', 'desc', 'icon_name', 'klass_prefix', 'is_generic', 'identifier', 'properties_release', 'version')
|
|
272
|
-
attributes['
|
|
297
|
+
attributes = response.slice('name', 'label', 'desc', 'icon_name', 'klass_prefix', 'is_generic', 'identifier', 'properties_release', 'version')
|
|
298
|
+
attributes['properties_release']['identifier'] = attributes['identifier']
|
|
299
|
+
attributes['properties_template'] = attributes['properties_release']
|
|
273
300
|
attributes['place'] = ((Labimotion::DatasetKlass.all.length * 10) || 0) + 10
|
|
274
301
|
attributes['is_active'] = false
|
|
275
302
|
attributes['updated_by'] = current_user.id
|
|
@@ -283,7 +310,7 @@ module Labimotion
|
|
|
283
310
|
attributes['created_by'] = current_user.id
|
|
284
311
|
element_klass = Labimotion::ElementKlass.create!(attributes)
|
|
285
312
|
end
|
|
286
|
-
element_klass.create_klasses_revision(current_user
|
|
313
|
+
element_klass.create_klasses_revision(current_user)
|
|
287
314
|
rescue StandardError => e
|
|
288
315
|
Labimotion.log_exception(e, current_user)
|
|
289
316
|
# { error: e.message }
|
|
@@ -41,7 +41,7 @@ module Labimotion
|
|
|
41
41
|
raise e
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def update_template(params)
|
|
44
|
+
def update_template(params, current_user)
|
|
45
45
|
klz = fetch_klass(params[:klass], params[:id])
|
|
46
46
|
uuid = SecureRandom.uuid
|
|
47
47
|
properties = params[:properties_template]
|
|
@@ -51,12 +51,13 @@ module Labimotion
|
|
|
51
51
|
properties['version'] = klz.version
|
|
52
52
|
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || klz.properties_template['pkg'])
|
|
53
53
|
properties['klass'] = klz.class.name.split('::').last
|
|
54
|
+
properties['identifier'] = klz.identifier
|
|
54
55
|
properties.delete('eln') if properties['eln'].present?
|
|
55
56
|
klz.updated_by = current_user.id
|
|
56
57
|
klz.properties_template = properties
|
|
57
58
|
klz.save!
|
|
58
59
|
klz.reload
|
|
59
|
-
klz.create_klasses_revision(current_user
|
|
60
|
+
klz.create_klasses_revision(current_user) if params[:release] != 'draft'
|
|
60
61
|
klz
|
|
61
62
|
rescue StandardError => e
|
|
62
63
|
Labimotion.log_exception(e, current_user)
|
|
@@ -38,7 +38,7 @@ module Labimotion
|
|
|
38
38
|
attributes[:properties_release] = attributes[:properties_template]
|
|
39
39
|
klass = Labimotion::SegmentKlass.create!(attributes)
|
|
40
40
|
klass.reload
|
|
41
|
-
klass.create_klasses_revision(current_user
|
|
41
|
+
klass.create_klasses_revision(current_user)
|
|
42
42
|
klass
|
|
43
43
|
rescue StandardError => e
|
|
44
44
|
Labimotion.log_exception(e, current_user)
|
|
@@ -65,8 +65,9 @@ module Labimotion
|
|
|
65
65
|
|
|
66
66
|
def create_repo_klass(params, current_user)
|
|
67
67
|
response = Labimotion::TemplateHub.fetch_identifier('SegmentKlass', params[:identifier])
|
|
68
|
-
attributes = response.slice('label', 'desc', 'uuid', 'identifier', 'released_at', 'properties_release', 'version')
|
|
69
|
-
attributes['
|
|
68
|
+
attributes = response.slice('label', 'desc', 'uuid', 'identifier', 'released_at', 'properties_release', 'version')
|
|
69
|
+
attributes['properties_release']['identifier'] = attributes['identifier']
|
|
70
|
+
attributes['properties_template'] = attributes['properties_release']
|
|
70
71
|
attributes['place'] = ((Labimotion::SegmentKlass.all.length * 10) || 0) + 10
|
|
71
72
|
attributes['is_active'] = false
|
|
72
73
|
attributes['updated_by'] = current_user.id
|
|
@@ -89,7 +90,7 @@ module Labimotion
|
|
|
89
90
|
attributes['created_by'] = current_user.id
|
|
90
91
|
segment_klass = Labimotion::SegmentKlass.create!(attributes)
|
|
91
92
|
end
|
|
92
|
-
segment_klass.create_klasses_revision(current_user
|
|
93
|
+
segment_klass.create_klasses_revision(current_user)
|
|
93
94
|
rescue StandardError => e
|
|
94
95
|
Labimotion.log_exception(e, current_user)
|
|
95
96
|
raise e
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Labimotion
|
|
4
|
-
|
|
4
|
+
## Generic Klass Revisions Helpers
|
|
5
|
+
module GenericKlassRevisions
|
|
5
6
|
extend ActiveSupport::Concern
|
|
6
7
|
included do
|
|
7
8
|
# has_many :element_klasses_revisions, dependent: :destroy
|
|
8
9
|
end
|
|
9
10
|
|
|
10
|
-
def create_klasses_revision(
|
|
11
|
+
def create_klasses_revision(current_user)
|
|
11
12
|
properties_release = properties_template
|
|
12
13
|
migrate_workflow if properties_release['flow'].present?
|
|
13
14
|
|
|
@@ -21,11 +22,19 @@ module Labimotion
|
|
|
21
22
|
end
|
|
22
23
|
properties_release['flowObject']['nodes'] = elements
|
|
23
24
|
end
|
|
25
|
+
klass_attributes = {
|
|
26
|
+
uuid: properties_template['uuid'],
|
|
27
|
+
properties_template: properties_release,
|
|
28
|
+
properties_release: properties_release,
|
|
29
|
+
released_at: DateTime.now,
|
|
30
|
+
updated_by: current_user&.id,
|
|
31
|
+
released_by: current_user&.id,
|
|
32
|
+
}
|
|
24
33
|
|
|
25
|
-
self.update!(
|
|
34
|
+
self.update!(klass_attributes)
|
|
26
35
|
reload
|
|
27
36
|
attributes = {
|
|
28
|
-
released_by:
|
|
37
|
+
released_by: released_by,
|
|
29
38
|
uuid: uuid,
|
|
30
39
|
version: version,
|
|
31
40
|
properties_release: properties_release,
|
|
@@ -48,6 +48,7 @@ module Labimotion
|
|
|
48
48
|
uuid = SecureRandom.uuid
|
|
49
49
|
props = seg['properties']
|
|
50
50
|
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
|
51
|
+
props['identifier'] = identifier
|
|
51
52
|
props['uuid'] = uuid
|
|
52
53
|
props['klass'] = 'Segment'
|
|
53
54
|
segment = Labimotion::Segment.find_by(element_type: Labimotion::Utils.element_name(self.class.name), element_id: self.id, segment_klass_id: seg['segment_klass_id'])
|
data/lib/labimotion/version.rb
CHANGED