wolas_channel 0.1.3 → 0.1.4
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/wolas_channel/version.rb +1 -1
- data/lib/wolas_channel.rb +36 -14
- metadata +1 -2
- data/wolas_channel-0.1.2.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a138673a8f4ee2e0a4c7581c56b17175ee64d469
|
4
|
+
data.tar.gz: ff4807df9dfecd03f862f7561b84619cf0f43089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e79bd8153d18315091ee71e836704898fa861b0c8cc7ea162314f869c9cc5f5e6bf5722e05b2182b8cb3280b5b4ceb6115ba5f325061f88ea1e760646c612631
|
7
|
+
data.tar.gz: 8ab0c9ecaee0f3747e813a12d12ab0c9ec92c6b7de29dedef09295f03a7eadb71bb93c47e77ae598bebf0c38208b5b215831ba088aec96307935875d0629ac1a
|
data/lib/wolas_channel.rb
CHANGED
@@ -79,11 +79,11 @@ class WolasChannel
|
|
79
79
|
return nil if type == nil
|
80
80
|
|
81
81
|
# Now the entities are requested
|
82
|
-
ent_q = "SELECT `entities`.`entity_id`, `entities`.`body`, `entities`.`created
|
82
|
+
ent_q = "SELECT `entities`.`entity_id`, `entities`.`body`, `entities`.`created` FROM `channel`.`entities` \
|
83
83
|
INNER JOIN `channel`.`channel_entities` on `entities`.`entity_id` = `channel_entities`.`entity_id` \
|
84
84
|
INNER JOIN `channel`.`channels` on `channel_entities`.`channel_id` = `channels`.`channel_id` \
|
85
|
-
WHERE `channels`.`channel_id` = ?"
|
86
|
-
ent = prepare_exe(@connect, ent_q, channel_id)
|
85
|
+
WHERE `channels`.`channel_id` = ? AND `entities`.`active` = ?"
|
86
|
+
ent = prepare_exe(@connect, ent_q, channel_id, 1)
|
87
87
|
|
88
88
|
# And their metadata
|
89
89
|
data_q = "SELECT `data`.`entity_id`, `data`.`key`, `data`.`value` FROM `channel`.`data` \
|
@@ -114,12 +114,12 @@ class WolasChannel
|
|
114
114
|
return nil if type == nil
|
115
115
|
|
116
116
|
# Now the 20 most recent entities are requested
|
117
|
-
ent_q = "SELECT `entities`.`entity_id`, `entities`.`body`, `entities`.`created
|
117
|
+
ent_q = "SELECT `entities`.`entity_id`, `entities`.`body`, `entities`.`created` FROM `channel`.`entities` \
|
118
118
|
INNER JOIN `channel`.`channel_entities` on `entities`.`entity_id` = `channel_entities`.`entity_id` \
|
119
119
|
INNER JOIN `channel`.`channels` on `channel_entities`.`channel_id` = `channels`.`channel_id` \
|
120
|
-
WHERE `channels`.`channel_id` = ? \
|
120
|
+
WHERE `channels`.`channel_id` = ? AND `entities`.`active` = ? \
|
121
121
|
ORDER BY `entities`.`created` DESC LIMIT 20"
|
122
|
-
ent = prepare_exe(@connect, ent_q, channel_id)
|
122
|
+
ent = prepare_exe(@connect, ent_q, channel_id, 1)
|
123
123
|
|
124
124
|
# All meta data is selected for the channel as the entity_ids are unknown.
|
125
125
|
# However any data that does not match an entity id from the query above will
|
@@ -152,7 +152,6 @@ class WolasChannel
|
|
152
152
|
type = tenant_channel(channel_id)
|
153
153
|
return nil if type == nil
|
154
154
|
return nil if kv.length == 0
|
155
|
-
byebug
|
156
155
|
|
157
156
|
# This count determines the number of key / value matches that exist per
|
158
157
|
# entity. If the number of matches equals the number of kvs passed to the
|
@@ -161,7 +160,7 @@ class WolasChannel
|
|
161
160
|
INNER JOIN `channel`.`data` ON `entities`.`entity_id` = `data`.`entity_id` \
|
162
161
|
INNER JOIN `channel`.`channel_entities` ON `data`.`entity_id` = `channel_entities`.`entity_id` \
|
163
162
|
INNER JOIN `channel`.`channels` ON `channel_entities`.`channel_id` = `channels`.`channel_id` \
|
164
|
-
WHERE `channels`.`channel_id` = ? AND ("
|
163
|
+
WHERE `channels`.`channel_id` = ? AND `entities`.`active` = ? AND ("
|
165
164
|
kv_arr = []
|
166
165
|
kv.each_with_index do |hash, index|
|
167
166
|
if index != kv.length - 1
|
@@ -170,11 +169,11 @@ class WolasChannel
|
|
170
169
|
match_q = match_q + "(`data`.`key` = ? AND `data`.`value` = ?))"
|
171
170
|
end
|
172
171
|
# Push the key followed by the value into the array to match ?s
|
173
|
-
|
174
|
-
|
172
|
+
kv_arr << hash[:key]
|
173
|
+
kv_arr << hash[:value]
|
175
174
|
end
|
176
175
|
match_q = match_q + "GROUP BY `entities`.`entity_id`"
|
177
|
-
match = prepare_exe(@connect, match_q, channel_id, *kv_arr)
|
176
|
+
match = prepare_exe(@connect, match_q, channel_id, 1, *kv_arr)
|
178
177
|
|
179
178
|
match_raw = match.map{ |e| e }
|
180
179
|
entity_ids = []
|
@@ -194,7 +193,7 @@ class WolasChannel
|
|
194
193
|
q_marks = in_prepare(entity_ids)
|
195
194
|
|
196
195
|
# Now the entities are requested
|
197
|
-
ent_q = "SELECT `entities`.`entity_id`, `entities`.`body`, `entities`.`created
|
196
|
+
ent_q = "SELECT `entities`.`entity_id`, `entities`.`body`, `entities`.`created` FROM `channel`.`entities` \
|
198
197
|
INNER JOIN `channel`.`channel_entities` on `entities`.`entity_id` = `channel_entities`.`entity_id` \
|
199
198
|
INNER JOIN `channel`.`channels` on `channel_entities`.`channel_id` = `channels`.`channel_id` \
|
200
199
|
WHERE `channels`.`channel_id` = ? AND `entities`.`entity_id` IN (#{q_marks})"
|
@@ -250,8 +249,8 @@ class WolasChannel
|
|
250
249
|
raise ErrorHandling::InvalidObject, 'The entity object must include a body field'
|
251
250
|
end
|
252
251
|
|
253
|
-
insert = "INSERT INTO `channel`.`entities` (`body`, `created`, `
|
254
|
-
insert_sql = prepare_exe(@connect, insert, body, created,
|
252
|
+
insert = "INSERT INTO `channel`.`entities` (`body`, `created`, `active`) VALUES (?, ?, ?, ?)"
|
253
|
+
insert_sql = prepare_exe(@connect, insert, body, created, 1)
|
255
254
|
# The last_id mysql2 method provides direct access to the last id inserted
|
256
255
|
entity_id = @connect.last_id
|
257
256
|
|
@@ -331,6 +330,29 @@ class WolasChannel
|
|
331
330
|
end
|
332
331
|
end
|
333
332
|
|
333
|
+
# This method sets an entity to inactive, stoping it from being returned on
|
334
|
+
# requests
|
335
|
+
# This method allows the update of an entity
|
336
|
+
def delete_entity(entity_id)
|
337
|
+
begin
|
338
|
+
# Connect to the database. Instance variable used to pass connection to
|
339
|
+
# private methods
|
340
|
+
@connect = Connection.new.open(@database, @host, @user, @pw)
|
341
|
+
# Determine if the tenant has access to the entity requested
|
342
|
+
tenant_entity(entity_id)
|
343
|
+
|
344
|
+
# update the existing entity body
|
345
|
+
update = "UPDATE `channel`.`entities` SET `entities`.`active` = ? WHERE `entities`.`entity_id` = ?"
|
346
|
+
prepare_exe(@connect, update, 0, entity_id)
|
347
|
+
|
348
|
+
# Return the updated entity to the
|
349
|
+
entity = entity_construct(entity_id)
|
350
|
+
|
351
|
+
return entity
|
352
|
+
ensure
|
353
|
+
@connect.close
|
354
|
+
end
|
355
|
+
end
|
334
356
|
|
335
357
|
private
|
336
358
|
# This method constructs a single object from key-values returned from a
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wolas_channel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WOLAS
|
@@ -99,7 +99,6 @@ files:
|
|
99
99
|
- lib/connection.rb
|
100
100
|
- lib/wolas_channel.rb
|
101
101
|
- lib/wolas_channel/version.rb
|
102
|
-
- wolas_channel-0.1.2.gem
|
103
102
|
- wolas_channel.gemspec
|
104
103
|
homepage: https://bitbucket.org/wolas-revolution/srvc-channel
|
105
104
|
licenses: []
|
data/wolas_channel-0.1.2.gem
DELETED
Binary file
|