projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
merge 21447: closes #21447
[arvados.git]
/
services
/
api
/
lib
/
has_uuid.rb
diff --git
a/services/api/lib/has_uuid.rb
b/services/api/lib/has_uuid.rb
index 74d09e94e9122998cd376d867b88ae9816875978..217113beec34d8193bce89c7cf5c9517ada014fa 100644
(file)
--- a/
services/api/lib/has_uuid.rb
+++ b/
services/api/lib/has_uuid.rb
@@
-1,3
+1,7
@@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
module HasUuid
UUID_REGEX = /^[0-9a-z]{5}-([0-9a-z]{5})-[0-9a-z]{15}$/
module HasUuid
UUID_REGEX = /^[0-9a-z]{5}-([0-9a-z]{5})-[0-9a-z]{15}$/
@@
-10,14
+14,14
@@
module HasUuid
base.has_many(:links_via_head,
-> { where("not (link_class = 'permission')") },
class_name: 'Link',
base.has_many(:links_via_head,
-> { where("not (link_class = 'permission')") },
class_name: 'Link',
- foreign_key:
:head_uuid
,
- primary_key:
:uuid
,
+ foreign_key:
'head_uuid'
,
+ primary_key:
'uuid'
,
dependent: :destroy)
base.has_many(:links_via_tail,
-> { where("not (link_class = 'permission')") },
class_name: 'Link',
dependent: :destroy)
base.has_many(:links_via_tail,
-> { where("not (link_class = 'permission')") },
class_name: 'Link',
- foreign_key:
:tail_uuid
,
- primary_key:
:uuid
,
+ foreign_key:
'tail_uuid'
,
+ primary_key:
'uuid'
,
dependent: :destroy)
end
dependent: :destroy)
end
@@
-26,7
+30,7
@@
module HasUuid
Digest::MD5.hexdigest(self.to_s).to_i(16).to_s(36)[-5..-1]
end
def generate_uuid
Digest::MD5.hexdigest(self.to_s).to_i(16).to_s(36)[-5..-1]
end
def generate_uuid
- [
Server::Application.config.uuid_prefix
,
+ [
Rails.configuration.ClusterID
,
self.uuid_prefix,
rand(2**256).to_s(36)[-15..-1]].
join '-'
self.uuid_prefix,
rand(2**256).to_s(36)[-15..-1]].
join '-'
@@
-75,8
+79,8
@@
module HasUuid
def destroy_permission_links
if uuid
def destroy_permission_links
if uuid
- Link.
destroy_all
(['link_class=? and (head_uuid=? or tail_uuid=?)',
- 'permission', uuid, uuid])
+ Link.
where
(['link_class=? and (head_uuid=? or tail_uuid=?)',
+ 'permission', uuid, uuid]).destroy_all
end
end
end
end
end
end