graph_starter 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45aeeb768a868dfa0b8cb6d65a4c3cfaf05415a6
|
4
|
+
data.tar.gz: 407b4b579be11348a16f4c47f7efab0ae3050cb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bfe075cdbabe38663dd5ecf653a2960bc8c999d791ee5bfed92fe9fccad50e9fba7674c4b54314e040ea3661c7209cbb5ca46556cb3ec9d0525b34214b275e6
|
7
|
+
data.tar.gz: 778dfd381ed626d572f9f9c05497a0ef93cfa01840f4753d1a20cf78e89e1a4be64d331a943c681a3d29b1a3c5d9e9d3f879a133addac2e2d47749c92950f8c1
|
@@ -4,6 +4,7 @@ module GraphStarter
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def index
|
7
|
+
@all_assets = asset_set(:asset, nil)
|
7
8
|
@assets = asset_set.to_a
|
8
9
|
end
|
9
10
|
|
@@ -31,7 +32,7 @@ module GraphStarter
|
|
31
32
|
render json: {results: results_data}.to_json
|
32
33
|
end
|
33
34
|
|
34
|
-
def asset_set(var = :asset)
|
35
|
+
def asset_set(var = :asset, limit = 50)
|
35
36
|
associations = []
|
36
37
|
associations << model_class.image_association
|
37
38
|
associations << model_class.category_association
|
@@ -40,7 +41,7 @@ module GraphStarter
|
|
40
41
|
scope = model_class_scope(var)
|
41
42
|
scope = yield scope if block_given?
|
42
43
|
|
43
|
-
scope = scope.limit(
|
44
|
+
scope = scope.limit(limit)
|
44
45
|
|
45
46
|
scope = if associations.present?
|
46
47
|
scope.query_as(var).with(var).proxy_as(model_class, var).with_associations(*associations)
|
@@ -147,8 +147,7 @@ module GraphStarter
|
|
147
147
|
def safe_title
|
148
148
|
sanitizer = Rails::Html::WhiteListSanitizer.new
|
149
149
|
|
150
|
-
|
151
|
-
|
150
|
+
sanitizer.sanitize(title, tags: %w(b em i strong))
|
152
151
|
end
|
153
152
|
|
154
153
|
def self.body_property(property_name = nil)
|
@@ -31,14 +31,14 @@ module GraphStarter
|
|
31
31
|
to_node.save
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.record_view(
|
35
|
-
test_view = new(properties.merge(from_node:
|
34
|
+
def self.record_view(session, target, properties = {})
|
35
|
+
test_view = new(properties.merge(from_node: session, to_node: target))
|
36
36
|
return test_view.errors if !test_view.valid?
|
37
37
|
|
38
38
|
query = <<-CYPHER
|
39
|
-
MATCH (
|
40
|
-
WHERE ID(
|
41
|
-
MERGE (
|
39
|
+
MATCH (session), (target)
|
40
|
+
WHERE ID(session) = {session_id} AND ID(target) = {target_id}
|
41
|
+
MERGE (session)-[view_rel:VIEWED]->(target)
|
42
42
|
ON CREATE SET
|
43
43
|
view_rel.created_at = {timestamp},
|
44
44
|
view_rel.count = 0
|
@@ -51,7 +51,7 @@ module GraphStarter
|
|
51
51
|
CYPHER
|
52
52
|
|
53
53
|
Neo4j::Session.current.query(query,
|
54
|
-
|
54
|
+
session_id: session.neo_id,
|
55
55
|
target_id: target.neo_id,
|
56
56
|
browser_string: properties[:browser_string],
|
57
57
|
ip_address: properties[:ip_address],
|
@@ -14,7 +14,7 @@
|
|
14
14
|
$.fn.api.settings.api = {search: "/#{@model_slug}/search/{query}.json"}
|
15
15
|
|
16
16
|
- count = @assets.size
|
17
|
-
- total_count = @
|
17
|
+
- total_count = @all_assets.count
|
18
18
|
.stacked.segment Displaying #{[count, total_count].min} of #{number_to_human(total_count)} total
|
19
19
|
|
20
20
|
.ui.divider
|