needle_in_a_haystack 1.0.5 → 1.0.6
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/haystack_ontology.yml +255 -0
- data/lib/needle_in_a_haystack/concerns/taggable.rb +3 -6
- data/lib/needle_in_a_haystack/factories/haystack_factory.rb +6 -5
- data/lib/needle_in_a_haystack/models/haystack_tag.rb +26 -7
- data/lib/needle_in_a_haystack/version.rb +1 -1
- data/lib/needle_in_a_haystack.rb +2 -1
- data/spec/factories/haystack_tags.rb +1 -1
- metadata +5 -4
- /data/lib/needle_in_a_haystack/strategies/{find_by_tag_strategy.rb → find_by_tags_strategy.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b329760e8ef018728c47465a1a0aacf1b83a3e89562f4a0e1ecfe703c01fc3e5
|
|
4
|
+
data.tar.gz: 2e6d30cdc898b73a9e05f7210b3dc3e5294bdb6bd844dbb7bbfeb5e02e0b4afc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 429d11b80631e4b7a9cac61ad46f2c6655f74e599240d52f970cf83ac92269918756417bd58f2e2bb30cb0bc88eecf667395a82826599478b977b6765c6db034
|
|
7
|
+
data.tar.gz: ea62403765551a28022f267fc3d829fe86d0a28cc2afd5f9b43e4c049f1bcd8d497e41cc67b382c860dded4723c87786d3a94d5b2ce5208815dbee8e85ae0a0d
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
site:
|
|
2
|
+
description: Een geografische locatie in de gebouwde omgeving
|
|
3
|
+
children:
|
|
4
|
+
building:
|
|
5
|
+
description: Een structuur op een site
|
|
6
|
+
children:
|
|
7
|
+
floor:
|
|
8
|
+
description: Een verdieping in een gebouw
|
|
9
|
+
children:
|
|
10
|
+
area:
|
|
11
|
+
description: Een driedimensionale ruimte in de gebouwde omgeving
|
|
12
|
+
children:
|
|
13
|
+
room:
|
|
14
|
+
description: Een afgesloten ruimte binnen een gebouw
|
|
15
|
+
bathRoom:
|
|
16
|
+
description: Een ruimte met sanitaire voorzieningen
|
|
17
|
+
kitchen:
|
|
18
|
+
description: Een ruimte voor het bereiden van voedsel
|
|
19
|
+
bedRoom:
|
|
20
|
+
description: Een slaapkamer
|
|
21
|
+
openSpace:
|
|
22
|
+
description: Een open ruimte binnen een gebouw
|
|
23
|
+
corridor:
|
|
24
|
+
description: Een gang die verschillende ruimtes verbindt
|
|
25
|
+
lobby:
|
|
26
|
+
description: Een ontvangstruimte of hal in een gebouw
|
|
27
|
+
office:
|
|
28
|
+
description: Een werkruimte binnen een gebouw
|
|
29
|
+
conferenceRoom:
|
|
30
|
+
description: Een vergaderruimte binnen een gebouw
|
|
31
|
+
storage:
|
|
32
|
+
description: Een opslagruimte binnen een gebouw
|
|
33
|
+
mechanicalRoom:
|
|
34
|
+
description: Een ruimte voor mechanische apparatuur en installaties
|
|
35
|
+
electricalRoom:
|
|
36
|
+
description: Een ruimte voor elektrische apparatuur en installaties
|
|
37
|
+
|
|
38
|
+
equip:
|
|
39
|
+
description: Apparatuur asset
|
|
40
|
+
children:
|
|
41
|
+
meter:
|
|
42
|
+
description: Meetapparaat voor verbruik
|
|
43
|
+
children:
|
|
44
|
+
elecMeter:
|
|
45
|
+
description: Elektriciteitsmeter
|
|
46
|
+
children:
|
|
47
|
+
smartMeter:
|
|
48
|
+
description: Slimme meter voor elektriciteit
|
|
49
|
+
intervalMeter:
|
|
50
|
+
description: Intervalmeter voor elektriciteit
|
|
51
|
+
meterbeheer:
|
|
52
|
+
description: Meterbeheer elektriciteitsmeter
|
|
53
|
+
fudura:
|
|
54
|
+
description: Fudura elektriciteitsmeter
|
|
55
|
+
gasMeter:
|
|
56
|
+
description: Gasmeter
|
|
57
|
+
children:
|
|
58
|
+
smartMeter:
|
|
59
|
+
description: Slimme meter voor gas
|
|
60
|
+
intervalMeter:
|
|
61
|
+
description: Intervalmeter voor gas
|
|
62
|
+
meterbeheer:
|
|
63
|
+
description: Meterbeheer gasmeter
|
|
64
|
+
fudura:
|
|
65
|
+
description: Fudura gasmeter
|
|
66
|
+
waterMeter:
|
|
67
|
+
description: Watermeter
|
|
68
|
+
climateMeter:
|
|
69
|
+
description: Klimaatmeter
|
|
70
|
+
children:
|
|
71
|
+
tempMeter:
|
|
72
|
+
description: Temperatuurmeter
|
|
73
|
+
co2Meter:
|
|
74
|
+
description: CO2-meter
|
|
75
|
+
humidityMeter:
|
|
76
|
+
description: Luchtvochtigheidsmeter
|
|
77
|
+
loraMeter:
|
|
78
|
+
description: LoRa klimaatmeter voor temperatuur, luchtvochtigheid en CO2
|
|
79
|
+
|
|
80
|
+
weatherStation:
|
|
81
|
+
description: Weerstation voor meteorologische gegevens
|
|
82
|
+
children:
|
|
83
|
+
onlineWeather:
|
|
84
|
+
description: Online weerstation via api of website
|
|
85
|
+
hvac:
|
|
86
|
+
description: Verwarming, ventilatie en airconditioning
|
|
87
|
+
children:
|
|
88
|
+
ahu:
|
|
89
|
+
description: Luchtbehandelingskast
|
|
90
|
+
vav:
|
|
91
|
+
description: Variable Air Volume box
|
|
92
|
+
fcu:
|
|
93
|
+
description: Fan Coil Unit
|
|
94
|
+
chiller:
|
|
95
|
+
description: Koelmachine
|
|
96
|
+
boiler:
|
|
97
|
+
description: Verwarmingsketel
|
|
98
|
+
heatPump:
|
|
99
|
+
description: Warmtepomp
|
|
100
|
+
lighting:
|
|
101
|
+
description: Verlichtingssystemen
|
|
102
|
+
children:
|
|
103
|
+
luminaire:
|
|
104
|
+
description: Armatuur
|
|
105
|
+
lightSensor:
|
|
106
|
+
description: Lichtsensor
|
|
107
|
+
occupancySensor:
|
|
108
|
+
description: Aanwezigheidssensor
|
|
109
|
+
security:
|
|
110
|
+
description: Beveiligingssystemen
|
|
111
|
+
children:
|
|
112
|
+
accessControl:
|
|
113
|
+
description: Toegangscontrolesysteem
|
|
114
|
+
cctv:
|
|
115
|
+
description: Camerabewakingssysteem
|
|
116
|
+
|
|
117
|
+
# Datapunten
|
|
118
|
+
point:
|
|
119
|
+
description: Datapunt zoals een sensor of actuator
|
|
120
|
+
children:
|
|
121
|
+
sensor:
|
|
122
|
+
description: Meetpunt
|
|
123
|
+
children:
|
|
124
|
+
temp:
|
|
125
|
+
description: Temperatuursensor
|
|
126
|
+
children:
|
|
127
|
+
tempIndoor:
|
|
128
|
+
description: Binnentemperatuursensor
|
|
129
|
+
tempOutdoor:
|
|
130
|
+
description: Buitentemperatuursensor
|
|
131
|
+
co2:
|
|
132
|
+
description: CO2-sensor
|
|
133
|
+
humidity:
|
|
134
|
+
description: Luchtvochtigheidssensor
|
|
135
|
+
pressure:
|
|
136
|
+
description: Druksensor
|
|
137
|
+
flow:
|
|
138
|
+
description: Stromingssensor
|
|
139
|
+
power:
|
|
140
|
+
description: Vermogenssensor
|
|
141
|
+
energy:
|
|
142
|
+
description: Energiesensor
|
|
143
|
+
occupancy:
|
|
144
|
+
description: Bezettingssensor
|
|
145
|
+
cmd:
|
|
146
|
+
description: Commandopunt
|
|
147
|
+
children:
|
|
148
|
+
onOff:
|
|
149
|
+
description: Aan/uit commando
|
|
150
|
+
setpoint:
|
|
151
|
+
description: Instelpunt
|
|
152
|
+
sp:
|
|
153
|
+
description: Setpoint
|
|
154
|
+
children:
|
|
155
|
+
tempSp:
|
|
156
|
+
description: Temperatuur setpoint
|
|
157
|
+
humiditySp:
|
|
158
|
+
description: Luchtvochtigheid setpoint
|
|
159
|
+
pressureSp:
|
|
160
|
+
description: Druk setpoint
|
|
161
|
+
status:
|
|
162
|
+
description: Statuspunt
|
|
163
|
+
children:
|
|
164
|
+
alarm:
|
|
165
|
+
description: Alarmpunt
|
|
166
|
+
fault:
|
|
167
|
+
description: Foutpunt
|
|
168
|
+
|
|
169
|
+
# Energiebronnen
|
|
170
|
+
substance:
|
|
171
|
+
description: Energiebron of medium
|
|
172
|
+
children:
|
|
173
|
+
elec:
|
|
174
|
+
description: Elektriciteit
|
|
175
|
+
gas:
|
|
176
|
+
description: Gas
|
|
177
|
+
water:
|
|
178
|
+
description: Water
|
|
179
|
+
steam:
|
|
180
|
+
description: Stoom
|
|
181
|
+
oil:
|
|
182
|
+
description: Olie
|
|
183
|
+
|
|
184
|
+
# Metingen en eenheden
|
|
185
|
+
measurement:
|
|
186
|
+
description: Meetbare eigenschappen
|
|
187
|
+
children:
|
|
188
|
+
temp:
|
|
189
|
+
description: Temperatuur
|
|
190
|
+
humidity:
|
|
191
|
+
description: Luchtvochtigheid
|
|
192
|
+
co2:
|
|
193
|
+
description: Koolstofdioxide concentratie
|
|
194
|
+
pressure:
|
|
195
|
+
description: Druk
|
|
196
|
+
flow:
|
|
197
|
+
description: Stroming
|
|
198
|
+
power:
|
|
199
|
+
description: Vermogen
|
|
200
|
+
energy:
|
|
201
|
+
description: Energie
|
|
202
|
+
voltage:
|
|
203
|
+
description: Spanning
|
|
204
|
+
current:
|
|
205
|
+
description: Stroom
|
|
206
|
+
frequency:
|
|
207
|
+
description: Frequentie
|
|
208
|
+
luminosity:
|
|
209
|
+
description: Lichtsterkte
|
|
210
|
+
|
|
211
|
+
# Tijdgerelateerde tags
|
|
212
|
+
occupied:
|
|
213
|
+
description: Bezettingsstatus
|
|
214
|
+
schedule:
|
|
215
|
+
description: Tijdschema
|
|
216
|
+
timezone:
|
|
217
|
+
description: Tijdzone
|
|
218
|
+
|
|
219
|
+
# Netwerkgerelateerde tags
|
|
220
|
+
network:
|
|
221
|
+
description: Netwerkgerelateerde informatie
|
|
222
|
+
children:
|
|
223
|
+
protocol:
|
|
224
|
+
description: Communicatieprotocol
|
|
225
|
+
children:
|
|
226
|
+
bacnet:
|
|
227
|
+
description: BACnet protocol
|
|
228
|
+
modbus:
|
|
229
|
+
description: Modbus protocol
|
|
230
|
+
knx:
|
|
231
|
+
description: KNX protocol
|
|
232
|
+
lonworks:
|
|
233
|
+
description: LonWorks protocol
|
|
234
|
+
ipAddr:
|
|
235
|
+
description: IP-adres
|
|
236
|
+
mac:
|
|
237
|
+
description: MAC-adres
|
|
238
|
+
|
|
239
|
+
# Metadata tags
|
|
240
|
+
id:
|
|
241
|
+
description: Unieke identifier
|
|
242
|
+
dis:
|
|
243
|
+
description: Weergavenaam
|
|
244
|
+
area:
|
|
245
|
+
description: Oppervlakte
|
|
246
|
+
vol:
|
|
247
|
+
description: Volume
|
|
248
|
+
manufacturer:
|
|
249
|
+
description: Fabrikant
|
|
250
|
+
model:
|
|
251
|
+
description: Model
|
|
252
|
+
serialNum:
|
|
253
|
+
description: Serienummer
|
|
254
|
+
installationDate:
|
|
255
|
+
description: Installatiedatum
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
serialize :tags, JSON
|
|
6
|
-
end
|
|
1
|
+
class Taggable < ApplicationRecord
|
|
2
|
+
has_many :haystack_taggings, as: :taggable, dependent: :destroy
|
|
3
|
+
has_many :haystack_tags, through: :haystack_taggings
|
|
7
4
|
|
|
8
5
|
def add_haystack_marker(marker)
|
|
9
6
|
self.tags ||= {}
|
|
@@ -16,7 +16,11 @@ class HaystackFactory < BaseFactory
|
|
|
16
16
|
|
|
17
17
|
def find_or_create_tag(name, attributes = {})
|
|
18
18
|
tag = HaystackTag.find_or_create_by(name: name)
|
|
19
|
-
|
|
19
|
+
if tag.persisted?
|
|
20
|
+
@tag_strategy.update_tag(tag, attributes)
|
|
21
|
+
else
|
|
22
|
+
tag.update(attributes)
|
|
23
|
+
end
|
|
20
24
|
tag
|
|
21
25
|
end
|
|
22
26
|
|
|
@@ -29,10 +33,7 @@ class HaystackFactory < BaseFactory
|
|
|
29
33
|
|
|
30
34
|
Rails.logger.info("Created tag: #{tag.name}, Parent: #{parent_tag&.name}, Parent ID: #{parent_tag&.id}")
|
|
31
35
|
|
|
32
|
-
if data["children"]
|
|
33
|
-
Rails.logger.info("Processing children for tag: #{tag.name}")
|
|
34
|
-
create_tags(data["children"], tag)
|
|
35
|
-
end
|
|
36
|
+
create_tags(data["children"], tag) if data["children"]
|
|
36
37
|
end
|
|
37
38
|
end
|
|
38
39
|
end
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
|
|
1
3
|
class HaystackTag < BaseTag
|
|
2
4
|
belongs_to :parent_tag, class_name: "HaystackTag", optional: true
|
|
3
5
|
has_many :children, class_name: "HaystackTag", foreign_key: "parent_tag_id", dependent: :destroy, inverse_of: :parent_tag
|
|
4
6
|
has_many :haystack_taggings, dependent: :destroy
|
|
5
|
-
has_many :taggables, through: :haystack_taggings, source: :taggable
|
|
7
|
+
has_many :taggables, through: :haystack_taggings, source: :taggable, source_type: "Taggable"
|
|
6
8
|
|
|
7
|
-
validates :name, presence: true, uniqueness:
|
|
9
|
+
validates :name, presence: true, uniqueness: { scope: :parent_tag_id, message: "Moet uniek zijn binnen dezelfde categorie" }
|
|
8
10
|
validates :description, presence: true
|
|
9
11
|
validate :prevent_circular_reference
|
|
12
|
+
validate :ensure_identity
|
|
13
|
+
|
|
14
|
+
CATEGORIES = YAML.load_file("lib/haystack_ontology.yml")
|
|
10
15
|
|
|
11
16
|
def ancestors
|
|
12
17
|
ancestors = []
|
|
13
18
|
current = self
|
|
14
19
|
while current.parent_tag
|
|
15
20
|
break if ancestors.include?(current.parent_tag) # Voorkom oneindige lus
|
|
21
|
+
|
|
16
22
|
ancestors << current.parent_tag
|
|
17
23
|
current = current.parent_tag
|
|
18
24
|
end
|
|
@@ -20,13 +26,13 @@ class HaystackTag < BaseTag
|
|
|
20
26
|
end
|
|
21
27
|
|
|
22
28
|
def full_path
|
|
23
|
-
ancestors.reverse.map(&:name).join(
|
|
29
|
+
"#{ancestors.reverse.map(&:name).join(' > ')} > #{name}"
|
|
24
30
|
end
|
|
25
31
|
|
|
26
32
|
def self.find_by_path(path)
|
|
27
33
|
keys = path.split(".")
|
|
28
34
|
current = nil
|
|
29
|
-
|
|
35
|
+
keys.each do |key|
|
|
30
36
|
current = current ? current.children.find_by(name: key) : find_by(name: key)
|
|
31
37
|
return nil unless current
|
|
32
38
|
end
|
|
@@ -53,11 +59,24 @@ class HaystackTag < BaseTag
|
|
|
53
59
|
ancestors.size
|
|
54
60
|
end
|
|
55
61
|
|
|
62
|
+
def category
|
|
63
|
+
ancestors.empty? ? name : parent_tag.category
|
|
64
|
+
end
|
|
65
|
+
|
|
56
66
|
private
|
|
57
67
|
|
|
58
68
|
def prevent_circular_reference
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
return unless parent_tag == self || ancestors.include?(self)
|
|
70
|
+
|
|
71
|
+
errors.add(:parent_tag, "Kan geen circulaire referentie bevatten")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def ensure_identity
|
|
75
|
+
return if root? && name == category
|
|
76
|
+
|
|
77
|
+
return unless HaystackTag.where(name: name).any? { |tag| tag.category == category }
|
|
78
|
+
|
|
79
|
+
Rails.logger.error("Duplicate tag found: #{name} within category: #{category}")
|
|
80
|
+
errors.add(:name, "Moet uniek zijn binnen dezelfde categorie")
|
|
62
81
|
end
|
|
63
82
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "1.0.
|
|
1
|
+
VERSION = "1.0.6".freeze
|
data/lib/needle_in_a_haystack.rb
CHANGED
|
@@ -7,12 +7,13 @@ require "needle_in_a_haystack/concerns/base_tag"
|
|
|
7
7
|
require "needle_in_a_haystack/factories/base_factory"
|
|
8
8
|
|
|
9
9
|
require "needle_in_a_haystack/models/haystack_ontology"
|
|
10
|
+
require "needle_in_a_haystack/concerns/taggable"
|
|
10
11
|
require "needle_in_a_haystack/models/haystack_tag"
|
|
11
12
|
require "needle_in_a_haystack/models/haystack_tagging"
|
|
12
13
|
require "needle_in_a_haystack/factories/haystack_factory"
|
|
13
14
|
require "needle_in_a_haystack/strategies/query_context"
|
|
14
15
|
require "needle_in_a_haystack/strategies/query_strategy"
|
|
15
|
-
require "needle_in_a_haystack/strategies/
|
|
16
|
+
require "needle_in_a_haystack/strategies/find_by_tags_strategy"
|
|
16
17
|
require "needle_in_a_haystack/strategies/find_point_by_tag_strategy"
|
|
17
18
|
require "needle_in_a_haystack/strategies/find_points_with_multiple_tags_strategy"
|
|
18
19
|
require "needle_in_a_haystack/strategies/tag_strategy"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: needle_in_a_haystack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Frans Verberne
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-12-
|
|
11
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bcrypt_pbkdf
|
|
@@ -275,6 +275,7 @@ files:
|
|
|
275
275
|
- config/initializers/redis.rb
|
|
276
276
|
- config/initializers/wrap_parameters.rb
|
|
277
277
|
- config/locales/en.yml
|
|
278
|
+
- lib/haystack_ontology.yml
|
|
278
279
|
- lib/needle_in_a_haystack.rb
|
|
279
280
|
- lib/needle_in_a_haystack/application_record.rb
|
|
280
281
|
- lib/needle_in_a_haystack/concerns/base_tag.rb
|
|
@@ -288,7 +289,7 @@ files:
|
|
|
288
289
|
- lib/needle_in_a_haystack/models/haystack_tag.rb
|
|
289
290
|
- lib/needle_in_a_haystack/models/haystack_tagging.rb
|
|
290
291
|
- lib/needle_in_a_haystack/strategies/default_tag_strategy.rb
|
|
291
|
-
- lib/needle_in_a_haystack/strategies/
|
|
292
|
+
- lib/needle_in_a_haystack/strategies/find_by_tags_strategy.rb
|
|
292
293
|
- lib/needle_in_a_haystack/strategies/find_point_by_tag_strategy.rb
|
|
293
294
|
- lib/needle_in_a_haystack/strategies/find_points_with_multiple_tags_strategy.rb
|
|
294
295
|
- lib/needle_in_a_haystack/strategies/ontology_tag_strategy.rb
|
|
@@ -318,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
318
319
|
- !ruby/object:Gem::Version
|
|
319
320
|
version: '0'
|
|
320
321
|
requirements: []
|
|
321
|
-
rubygems_version: 3.5.
|
|
322
|
+
rubygems_version: 3.5.18
|
|
322
323
|
signing_key:
|
|
323
324
|
specification_version: 4
|
|
324
325
|
summary: Models and dependencies shared across our projects.
|
/data/lib/needle_in_a_haystack/strategies/{find_by_tag_strategy.rb → find_by_tags_strategy.rb}
RENAMED
|
File without changes
|