socialization-cassandra 0.0.3.pre.alpha → 0.0.4.pre.alpha
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/generators/socialization/templates/socialization_cassandra_migrations.rake +17 -17
- data/lib/socialization/stores/cassandra/base.rb +23 -23
- data/lib/socialization/version.rb +1 -1
- data/test/stores/cassandra/base_test.rb +15 -15
- data/test/test_helper.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19bea4f17e4a3dfd2d1b5b032a03ee3b6cd47c60
|
4
|
+
data.tar.gz: c7452de91ad750ab85c8e6f2e74d6b81cf37a577
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9f0aafe6ca252a2a18818ad0571ead2d0ebb980b8b88bf7cdd6186f776b4d269b581e4b05d64428a10cd25718924f2bf37c088729e015e0befe3e86da6d4df0
|
7
|
+
data.tar.gz: 600f99254260cbf8004827bfb5ff3ef34c5b6db88a20c079c8f407859fb4f55d73ea3fc4dbbdd6525b803ea049698e0f3ec3f00a55e44d1210f33b9907bdcae1
|
@@ -6,8 +6,8 @@ class SocializationCassandraMigrations
|
|
6
6
|
|
7
7
|
"CREATE TABLE likes (
|
8
8
|
actor_type varchar,
|
9
|
-
actor_id
|
10
|
-
victim_id
|
9
|
+
actor_id varchar,
|
10
|
+
victim_id varchar,
|
11
11
|
victim_type varchar,
|
12
12
|
created_at bigint,
|
13
13
|
PRIMARY KEY ((actor_type, actor_id), created_at)
|
@@ -18,8 +18,8 @@ class SocializationCassandraMigrations
|
|
18
18
|
|
19
19
|
"CREATE TABLE likers (
|
20
20
|
actor_type varchar,
|
21
|
-
actor_id
|
22
|
-
victim_id
|
21
|
+
actor_id varchar,
|
22
|
+
victim_id varchar,
|
23
23
|
victim_type varchar,
|
24
24
|
created_at bigint,
|
25
25
|
PRIMARY KEY ((victim_type, victim_id), created_at)
|
@@ -29,7 +29,7 @@ class SocializationCassandraMigrations
|
|
29
29
|
"CREATE INDEX ON likers (actor_id)",
|
30
30
|
|
31
31
|
"CREATE TABLE liker_counter (
|
32
|
-
victim_id
|
32
|
+
victim_id varchar,
|
33
33
|
victim_type varchar,
|
34
34
|
cnt counter,
|
35
35
|
PRIMARY KEY (victim_type, victim_id)
|
@@ -39,8 +39,8 @@ class SocializationCassandraMigrations
|
|
39
39
|
|
40
40
|
"CREATE TABLE followings (
|
41
41
|
actor_type varchar,
|
42
|
-
actor_id
|
43
|
-
victim_id
|
42
|
+
actor_id varchar,
|
43
|
+
victim_id varchar,
|
44
44
|
victim_type varchar,
|
45
45
|
created_at bigint,
|
46
46
|
PRIMARY KEY ((actor_type, actor_id), created_at)
|
@@ -51,8 +51,8 @@ class SocializationCassandraMigrations
|
|
51
51
|
|
52
52
|
"CREATE TABLE followers (
|
53
53
|
actor_type varchar,
|
54
|
-
actor_id
|
55
|
-
victim_id
|
54
|
+
actor_id varchar,
|
55
|
+
victim_id varchar,
|
56
56
|
victim_type varchar,
|
57
57
|
created_at bigint,
|
58
58
|
PRIMARY KEY ((victim_type, victim_id), created_at)
|
@@ -62,14 +62,14 @@ class SocializationCassandraMigrations
|
|
62
62
|
"CREATE INDEX ON followers (actor_id)",
|
63
63
|
|
64
64
|
"CREATE TABLE following_counter (
|
65
|
-
actor_id
|
65
|
+
actor_id varchar,
|
66
66
|
actor_type varchar,
|
67
67
|
cnt counter,
|
68
68
|
PRIMARY KEY (actor_type, actor_id)
|
69
69
|
);",
|
70
70
|
|
71
71
|
"CREATE TABLE follower_counter (
|
72
|
-
victim_id
|
72
|
+
victim_id varchar,
|
73
73
|
victim_type varchar,
|
74
74
|
cnt counter,
|
75
75
|
PRIMARY KEY (victim_type, victim_id)
|
@@ -79,8 +79,8 @@ class SocializationCassandraMigrations
|
|
79
79
|
|
80
80
|
"CREATE TABLE comments (
|
81
81
|
actor_type varchar,
|
82
|
-
actor_id
|
83
|
-
victim_id
|
82
|
+
actor_id varchar,
|
83
|
+
victim_id varchar,
|
84
84
|
victim_type varchar,
|
85
85
|
created_at bigint,
|
86
86
|
txt text,
|
@@ -88,7 +88,7 @@ class SocializationCassandraMigrations
|
|
88
88
|
);",
|
89
89
|
|
90
90
|
"CREATE TABLE comment_counter (
|
91
|
-
victim_id
|
91
|
+
victim_id varchar,
|
92
92
|
victim_type varchar,
|
93
93
|
cnt counter,
|
94
94
|
PRIMARY KEY (victim_type, victim_id)
|
@@ -98,8 +98,8 @@ class SocializationCassandraMigrations
|
|
98
98
|
|
99
99
|
"CREATE TABLE shares (
|
100
100
|
actor_type varchar,
|
101
|
-
actor_id
|
102
|
-
victim_id
|
101
|
+
actor_id varchar,
|
102
|
+
victim_id varchar,
|
103
103
|
victim_type varchar,
|
104
104
|
networks set<text>,
|
105
105
|
created_at bigint,
|
@@ -108,7 +108,7 @@ class SocializationCassandraMigrations
|
|
108
108
|
);",
|
109
109
|
|
110
110
|
"CREATE TABLE share_counter (
|
111
|
-
victim_id
|
111
|
+
victim_id varchar,
|
112
112
|
victim_type varchar,
|
113
113
|
cnt counter,
|
114
114
|
PRIMARY KEY (victim_type, victim_id)
|
@@ -6,7 +6,7 @@ module Socialization
|
|
6
6
|
protected
|
7
7
|
def actors(victim, klass, options = {})
|
8
8
|
if options[:pluck]
|
9
|
-
query_result = Socialization.cassandra_session.execute("SELECT actor_type, actor_id from #{backward_table_name} WHERE victim_type = '#{victim.class}' AND victim_id = #{victim.id}")
|
9
|
+
query_result = Socialization.cassandra_session.execute("SELECT actor_type, actor_id from #{backward_table_name} WHERE victim_type = '#{victim.class}' AND victim_id = '#{victim.id}'")
|
10
10
|
return [] if query_result.blank? || query_result.rows.blank?
|
11
11
|
query_result.rows.collect {|i| i['actor_id'] if i['actor_type'] == klass.to_s}
|
12
12
|
else
|
@@ -16,7 +16,7 @@ module Socialization
|
|
16
16
|
|
17
17
|
def actors_cnt(victim, klass, options = {})
|
18
18
|
return 0 if counter_backward_table_name.nil?
|
19
|
-
query_result = Socialization.cassandra_session.execute("SELECT cnt from #{counter_backward_table_name} WHERE victim_type = '#{victim.class}' AND victim_id = #{victim.id}")
|
19
|
+
query_result = Socialization.cassandra_session.execute("SELECT cnt from #{counter_backward_table_name} WHERE victim_type = '#{victim.class}' AND victim_id = '#{victim.id}'")
|
20
20
|
return 0 if query_result.blank? || query_result.rows.blank?
|
21
21
|
query_result.rows.first['cnt']
|
22
22
|
end
|
@@ -33,7 +33,7 @@ module Socialization
|
|
33
33
|
|
34
34
|
def victims(actor, klass, options = {})
|
35
35
|
if options[:pluck]
|
36
|
-
query_result = Socialization.cassandra_session.execute("SELECT victim_type, victim_id from #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id
|
36
|
+
query_result = Socialization.cassandra_session.execute("SELECT victim_type, victim_id from #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id='#{actor.id}'")
|
37
37
|
return [] if query_result.blank? || query_result.rows.blank?
|
38
38
|
query_result.rows.collect {|i| i['victim_id'] if i['victim_type'] == klass.to_s}
|
39
39
|
else
|
@@ -43,7 +43,7 @@ module Socialization
|
|
43
43
|
|
44
44
|
def victims_cnt(actor, klass, options = {})
|
45
45
|
return 0 if counter_forward_table_name.nil?
|
46
|
-
query_result = Socialization.cassandra_session.execute("SELECT cnt from #{counter_forward_table_name} WHERE actor_type = '#{actor.class}' AND actor_id = #{actor.id}")
|
46
|
+
query_result = Socialization.cassandra_session.execute("SELECT cnt from #{counter_forward_table_name} WHERE actor_type = '#{actor.class}' AND actor_id = '#{actor.id}'")
|
47
47
|
return 0 if query_result.blank? || query_result.rows.blank?
|
48
48
|
query_result.rows.first['cnt']
|
49
49
|
end
|
@@ -70,7 +70,7 @@ module Socialization
|
|
70
70
|
|
71
71
|
def relation?(actor, victim)
|
72
72
|
if backward_table_name
|
73
|
-
query_result = Socialization.cassandra_session.execute("SELECT * FROM #{backward_table_name} WHERE victim_type = '#{victim.class}' AND victim_id = #{victim.id} AND actor_type = '#{actor.class}' AND actor_id = #{actor.id} ALLOW FILTERING")
|
73
|
+
query_result = Socialization.cassandra_session.execute("SELECT * FROM #{backward_table_name} WHERE victim_type = '#{victim.class}' AND victim_id = '#{victim.id}' AND actor_type = '#{actor.class}' AND actor_id = '#{actor.id}' ALLOW FILTERING")
|
74
74
|
!query_result.rows.to_a.empty?
|
75
75
|
else
|
76
76
|
false
|
@@ -78,27 +78,27 @@ module Socialization
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def remove_actor_relations(victim)
|
81
|
-
query_result = Socialization.cassandra_session.execute("SELECT * FROM #{backward_table_name} WHERE victim_type='#{victim.class}' AND victim_id
|
81
|
+
query_result = Socialization.cassandra_session.execute("SELECT * FROM #{backward_table_name} WHERE victim_type='#{victim.class}' AND victim_id='#{victim.id}'")
|
82
82
|
if query_result.present? && query_result.rows.present?
|
83
83
|
query_result.rows.to_a.each do |i|
|
84
84
|
delete_entry_from_forward_table_name(i['actor_type'], i['actor_id'], victim.class, victim.id)
|
85
|
-
Socialization.cassandra_session.execute("DELETE FROM #{backward_table_name} WHERE victim_type='#{victim.class}' AND victim_id
|
85
|
+
Socialization.cassandra_session.execute("DELETE FROM #{backward_table_name} WHERE victim_type='#{victim.class}' AND victim_id='#{victim.id}' AND created_at=#{i["created_at"]}")
|
86
86
|
end
|
87
87
|
end
|
88
|
-
# puts "DELETE FROM #{backward_table_name} WHERE victim_type=#{victim.class} AND victim_id
|
89
|
-
# Socialization.cassandra_session.execute("DELETE FROM #{backward_table_name} WHERE victim_type=#{victim.class} AND victim_id
|
88
|
+
# puts "DELETE FROM #{backward_table_name} WHERE victim_type=#{victim.class} AND victim_id='#{victim.id}'"
|
89
|
+
# Socialization.cassandra_session.execute("DELETE FROM #{backward_table_name} WHERE victim_type=#{victim.class} AND victim_id='#{victim.id}'")
|
90
90
|
true
|
91
91
|
end
|
92
92
|
|
93
93
|
def remove_victim_relations(actor)
|
94
|
-
query_result = Socialization.cassandra_session.execute("SELECT * FROM #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id
|
94
|
+
query_result = Socialization.cassandra_session.execute("SELECT * FROM #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id='#{actor.id}'")
|
95
95
|
if query_result.present? && query_result.rows.present?
|
96
96
|
query_result.rows.to_a.each do |i|
|
97
97
|
delete_entry_from_backward_table_name(actor.class, actor.id, i['victim_type'], i['victim_id'])
|
98
|
-
Socialization.cassandra_session.execute("DELETE FROM #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id
|
98
|
+
Socialization.cassandra_session.execute("DELETE FROM #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id='#{actor.id}' AND created_at=#{i["created_at"]}")
|
99
99
|
end
|
100
100
|
end
|
101
|
-
# Socialization.cassandra_session.execute("DELETE FROM #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id
|
101
|
+
# Socialization.cassandra_session.execute("DELETE FROM #{forward_table_name} WHERE actor_type='#{actor.class}' AND actor_id='#{actor.id}'")
|
102
102
|
true
|
103
103
|
end
|
104
104
|
|
@@ -108,7 +108,7 @@ module Socialization
|
|
108
108
|
def add_new_entry(actor, victim, options={})
|
109
109
|
[forward_table_name, backward_table_name].uniq.each do |table_name|
|
110
110
|
query_columns = "actor_type, actor_id, victim_type, victim_id, created_at"
|
111
|
-
query_values = "'#{actor.class}', #{actor.id}, '#{victim.class}', #{victim.id}, #{(Time.now.to_f * 100000).to_i}"
|
111
|
+
query_values = "'#{actor.class}', '#{actor.id}', '#{victim.class}', '#{victim.id}', #{(Time.now.to_f * 100000).to_i}"
|
112
112
|
if options[:text]
|
113
113
|
query_columns += ", text"
|
114
114
|
query_values += ", '#{options[:text]}'"
|
@@ -119,27 +119,27 @@ module Socialization
|
|
119
119
|
end
|
120
120
|
Socialization.cassandra_session.execute("INSERT INTO #{table_name} (#{query_columns}) VALUES (#{query_values})")
|
121
121
|
end
|
122
|
-
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt + 1 WHERE actor_type = '#{actor.class}' AND actor_id = #{actor.id}") if counter_forward_table_name
|
123
|
-
Socialization.cassandra_session.execute("UPDATE #{counter_backward_table_name} SET cnt = cnt + 1 WHERE victim_type = '#{victim.class}' AND victim_id = #{victim.id}") if counter_backward_table_name
|
122
|
+
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt + 1 WHERE actor_type = '#{actor.class}' AND actor_id = '#{actor.id}'") if counter_forward_table_name
|
123
|
+
Socialization.cassandra_session.execute("UPDATE #{counter_backward_table_name} SET cnt = cnt + 1 WHERE victim_type = '#{victim.class}' AND victim_id = '#{victim.id}'") if counter_backward_table_name
|
124
124
|
end
|
125
125
|
|
126
126
|
def delete_entry_from_forward_table_name(actor_type, actor_id, victim_type, victim_id)
|
127
|
-
row = Socialization.cassandra_session.execute("SELECT * FROM #{forward_table_name} WHERE actor_type='#{actor_type}' AND actor_id
|
128
|
-
Socialization.cassandra_session.execute("DELETE FROM #{forward_table_name} WHERE actor_type='#{actor_type}' AND actor_id
|
129
|
-
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt - 1 WHERE actor_type = '#{actor_type}' AND actor_id = #{actor_id}") if counter_forward_table_name
|
127
|
+
row = Socialization.cassandra_session.execute("SELECT * FROM #{forward_table_name} WHERE actor_type='#{actor_type}' AND actor_id='#{actor_id}' AND victim_type='#{victim_type}' AND victim_id='#{victim_id}' ALLOW FILTERING").rows.first
|
128
|
+
Socialization.cassandra_session.execute("DELETE FROM #{forward_table_name} WHERE actor_type='#{actor_type}' AND actor_id='#{actor_id}' AND created_at=#{row["created_at"]}") # if row
|
129
|
+
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt - 1 WHERE actor_type = '#{actor_type}' AND actor_id = '#{actor_id}'") if counter_forward_table_name
|
130
130
|
end
|
131
131
|
|
132
132
|
def delete_entry_from_backward_table_name(actor_type, actor_id, victim_type, victim_id)
|
133
|
-
row = Socialization.cassandra_session.execute("SELECT * FROM #{backward_table_name} WHERE actor_type='#{actor_type}' AND actor_id
|
134
|
-
Socialization.cassandra_session.execute("DELETE FROM #{backward_table_name} WHERE victim_type='#{victim_type}' AND victim_id
|
135
|
-
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt - 1 WHERE actor_type = '#{actor_type}' AND actor_id = #{actor_id}") if counter_forward_table_name
|
133
|
+
row = Socialization.cassandra_session.execute("SELECT * FROM #{backward_table_name} WHERE actor_type='#{actor_type}' AND actor_id='#{actor_id}' AND victim_type='#{victim_type}' AND victim_id='#{victim_id}' ALLOW FILTERING").rows.to_a.first
|
134
|
+
Socialization.cassandra_session.execute("DELETE FROM #{backward_table_name} WHERE victim_type='#{victim_type}' AND victim_id='#{victim_id}' AND created_at=#{row["created_at"]}") if row
|
135
|
+
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt - 1 WHERE actor_type = '#{actor_type}' AND actor_id = '#{actor_id}'") if counter_forward_table_name
|
136
136
|
end
|
137
137
|
|
138
138
|
def delete_entry(actor, victim, options={})
|
139
139
|
delete_entry_from_forward_table_name(actor.class, actor.id, victim.class, victim.id) if forward_table_name
|
140
140
|
delete_entry_from_backward_table_name(actor.class, actor.id, victim.class, victim.id) if backward_table_name
|
141
|
-
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt - 1 WHERE actor_type = '#{actor.class}' AND actor_id = #{actor.id}") if counter_forward_table_name
|
142
|
-
Socialization.cassandra_session.execute("UPDATE #{counter_backward_table_name} SET cnt = cnt - 1 WHERE victim_type = '#{victim.class}' AND victim_id = #{victim.id}") if counter_backward_table_name
|
141
|
+
Socialization.cassandra_session.execute("UPDATE #{counter_forward_table_name} SET cnt = cnt - 1 WHERE actor_type = '#{actor.class}' AND actor_id = '#{actor.id}'") if counter_forward_table_name
|
142
|
+
Socialization.cassandra_session.execute("UPDATE #{counter_backward_table_name} SET cnt = cnt - 1 WHERE victim_type = '#{victim.class}' AND victim_id = '#{victim.id}'") if counter_backward_table_name
|
143
143
|
end
|
144
144
|
|
145
145
|
end # class << self
|
@@ -25,18 +25,18 @@ class CassandraBaseStoreTest < TestCase
|
|
25
25
|
context "#follow!" do
|
26
26
|
should "create follow records" do
|
27
27
|
@klass.follow!(@follower1, @followable1)
|
28
|
-
row = Socialization.cassandra_session.execute("SELECT actor_type, actor_id FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id
|
28
|
+
row = Socialization.cassandra_session.execute("SELECT actor_type, actor_id FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id='#{@followable1.id}' ALLOW FILTERING").rows.to_a.first
|
29
29
|
assert_array_similarity ["#{@follower1.class}:#{@follower1.id}"], ["#{row['actor_type']}:#{row['actor_id']}"]
|
30
|
-
row = Socialization.cassandra_session.execute("SELECT victim_type, victim_id FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id
|
30
|
+
row = Socialization.cassandra_session.execute("SELECT victim_type, victim_id FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id='#{@follower1.id}' ALLOW FILTERING").rows.to_a.last
|
31
31
|
assert_array_similarity ["#{@followable1.class}:#{@followable1.id}"], ["#{row['victim_type']}:#{row['victim_id']}"]
|
32
32
|
|
33
33
|
@klass.follow!(@follower2, @followable1)
|
34
|
-
rows = Socialization.cassandra_session.execute("SELECT actor_type, actor_id FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id
|
34
|
+
rows = Socialization.cassandra_session.execute("SELECT actor_type, actor_id FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id='#{@followable1.id}' ALLOW FILTERING").rows
|
35
35
|
assert_array_similarity ["#{@follower1.class}:#{@follower1.id}", "#{@follower2.class}:#{@follower2.id}"], (rows.collect {|i| "#{i['actor_type']}:#{i['actor_id']}"})
|
36
36
|
|
37
|
-
row = Socialization.cassandra_session.execute("SELECT victim_type, victim_id FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id
|
37
|
+
row = Socialization.cassandra_session.execute("SELECT victim_type, victim_id FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id='#{@follower1.id}' ALLOW FILTERING").rows.to_a.last
|
38
38
|
assert_array_similarity ["#{@followable1.class}:#{@followable1.id}"], ["#{row['victim_type']}:#{row['victim_id']}"]
|
39
|
-
row = Socialization.cassandra_session.execute("SELECT victim_type, victim_id FROM #{@klass.backward_table_name} where actor_type='#{@follower2.class}' AND actor_id
|
39
|
+
row = Socialization.cassandra_session.execute("SELECT victim_type, victim_id FROM #{@klass.backward_table_name} where actor_type='#{@follower2.class}' AND actor_id='#{@follower2.id}' ALLOW FILTERING").rows.to_a.first
|
40
40
|
assert_array_similarity ["#{@followable1.class}:#{@followable1.id}"], ["#{row['victim_type']}:#{row['victim_id']}"]
|
41
41
|
end
|
42
42
|
|
@@ -81,8 +81,8 @@ class CassandraBaseStoreTest < TestCase
|
|
81
81
|
|
82
82
|
should "remove follow records" do
|
83
83
|
@klass.unfollow!(@follower1, @followable1)
|
84
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id
|
85
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id
|
84
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id='#{@follower1.id}' ALLOW FILTERING").rows.to_a
|
85
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id='#{@followable1.id}' ALLOW FILTERING").rows.to_a
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -111,7 +111,7 @@ class CassandraBaseStoreTest < TestCase
|
|
111
111
|
follower2 = ImAFollower.create
|
112
112
|
follower1.follow!(@followable1)
|
113
113
|
follower2.follow!(@followable1)
|
114
|
-
assert_array_similarity [follower1.id, follower2.id], @klass.followers(@followable1, follower1.class, :pluck => :id)
|
114
|
+
assert_array_similarity [follower1.id.to_s, follower2.id.to_s], @klass.followers(@followable1, follower1.class, :pluck => :id)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -130,7 +130,7 @@ class CassandraBaseStoreTest < TestCase
|
|
130
130
|
followable2 = ImAFollowable.create
|
131
131
|
@follower1.follow!(followable1)
|
132
132
|
@follower1.follow!(followable2)
|
133
|
-
assert_array_similarity [followable1.id, followable2.id], @klass.followables(@follower1, followable1.class, :pluck => :id)
|
133
|
+
assert_array_similarity [followable1.id.to_s, followable2.id.to_s], @klass.followables(@follower1, followable1.class, :pluck => :id)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -142,9 +142,9 @@ class CassandraBaseStoreTest < TestCase
|
|
142
142
|
|
143
143
|
@klass.remove_followers(@followable1)
|
144
144
|
assert_equal 0, @followable1.followers(@follower1.class).count
|
145
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id
|
146
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id
|
147
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower2.class}' AND actor_id
|
145
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id='#{@followable1.id}' ALLOW FILTERING").rows.to_a
|
146
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id='#{@follower1.id}' ALLOW FILTERING").rows.to_a
|
147
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower2.class}' AND actor_id='#{@follower2.id}' ALLOW FILTERING").rows.to_a
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -156,9 +156,9 @@ class CassandraBaseStoreTest < TestCase
|
|
156
156
|
|
157
157
|
@klass.remove_followables(@follower1)
|
158
158
|
assert_equal 0, @follower1.followables(@followable1.class).count
|
159
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id
|
160
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id
|
161
|
-
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower2.class}' AND actor_id
|
159
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.forward_table_name} where victim_type='#{@followable1.class}' AND victim_id='#{@followable1.id}' ALLOW FILTERING").rows.to_a
|
160
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower1.class}' AND actor_id='#{@follower1.id}' ALLOW FILTERING").rows.to_a
|
161
|
+
assert_empty Socialization.cassandra_session.execute("SELECT * FROM #{@klass.backward_table_name} where actor_type='#{@follower2.class}' AND actor_id='#{@follower2.id}' ALLOW FILTERING").rows.to_a
|
162
162
|
# assert_empty Socialization.redis.smembers backward_key(@followable1)
|
163
163
|
# assert_empty Socialization.redis.smembers backward_key(@follower2)
|
164
164
|
# assert_empty Socialization.redis.smembers forward_key(@follower1)
|
data/test/test_helper.rb
CHANGED
@@ -100,33 +100,33 @@ ActiveRecord::Schema.define(:version => 0) do
|
|
100
100
|
|
101
101
|
create_table :follows do |t|
|
102
102
|
t.string :follower_type
|
103
|
-
t.
|
103
|
+
t.string :follower_id
|
104
104
|
t.string :followable_type
|
105
|
-
t.
|
105
|
+
t.string :followable_id
|
106
106
|
t.datetime :created_at
|
107
107
|
end
|
108
108
|
|
109
109
|
create_table :likes do |t|
|
110
110
|
t.string :liker_type
|
111
|
-
t.
|
111
|
+
t.string :liker_id
|
112
112
|
t.string :likeable_type
|
113
|
-
t.
|
113
|
+
t.string :likeable_id
|
114
114
|
t.datetime :created_at
|
115
115
|
end
|
116
116
|
|
117
117
|
create_table :comments do |t|
|
118
118
|
t.string :commenter_type
|
119
|
-
t.
|
119
|
+
t.string :commenter_id
|
120
120
|
t.string :commentable_type
|
121
|
-
t.
|
121
|
+
t.string :commentable_id
|
122
122
|
t.datetime :created_at
|
123
123
|
end
|
124
124
|
|
125
125
|
create_table :shares do |t|
|
126
126
|
t.string :sharer_type
|
127
|
-
t.
|
127
|
+
t.string :sharer_id
|
128
128
|
t.string :shareable_type
|
129
|
-
t.
|
129
|
+
t.string :shareable_id
|
130
130
|
t.datetime :created_at
|
131
131
|
end
|
132
132
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialization-cassandra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amrit Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|