yinx_st 0.1.3 → 0.1.4

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: 8c3d3d186fa2bba07b7314e6195b19a5df87ead5
4
- data.tar.gz: 848bc6578b833a3ffa8267b17b81691a7e51c8a7
3
+ metadata.gz: 0b0deeefba377acfcc34856ffa6bd7ad58903312
4
+ data.tar.gz: 6dd56be4c22f6df1d08d2d88f3ca59aa70087d74
5
5
  SHA512:
6
- metadata.gz: 1bd84662616f72ac877bc53241d3148fd7304169f08089d1b66037b78a7e1e19f97e1278a228a392645e78d870871e922d1f1d8cdcebf6c84a4893adc92348a1
7
- data.tar.gz: f29e77e31b6d1c49a2d6c8abf3fdaeb56ce86d666403adc839308f6bfbb81767b80fb484c677994d0e9cbe4e5fb86f2e88c72a767b27d22e8378e03a469cfd3e
6
+ metadata.gz: 0b77671dea7ef76537d791d3b253766aeb5b0b7ef233261d085b2b6394edc54a7484f86297f4eb384130484892dc6477c9e8d8a0bc934fb39d22e51ea339af7c
7
+ data.tar.gz: 805f5f49cb9423bc8dd57c82bac8efef126cbbe14425c9b3d56d55685b5d20ed3dd2e361dd981aa6d56f42c2836269acacdb2e6dd2c0dc7019fe7d8676641c40
@@ -38,4 +38,16 @@ class Yinx::NoteMeta
38
38
  prev_version and prev_version.tags.sort != self.tags.sort
39
39
  end
40
40
 
41
+ def stack_book
42
+ st = stack.nil? ? '' : "#{stack}/"
43
+ "#{st}#{book}"
44
+ end
45
+
46
+ def stack_name
47
+ stack ? stack : 'No Stack'
48
+ end
49
+
50
+ def tags_count
51
+ tags.count
52
+ end
41
53
  end
@@ -1,3 +1,3 @@
1
1
  module YinxSt
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/yinx_st.rb CHANGED
@@ -1,14 +1,18 @@
1
1
  require "yinx_st/version"
2
2
  require 'yinx'
3
3
  require 'yinx_sql'
4
- require 'my_chart'
5
4
  require 'time_seq'
6
5
 
7
6
  require 'yinx_st/note_meta'
8
7
  require 'yinx_st/batches'
9
8
 
9
+ require 'my_chartkick'
10
+
10
11
  module YinxSt
11
12
  class << self
13
+
14
+ attr_reader :chart
15
+
12
16
  def fetch *args
13
17
  Yinx::SQL.connect(*args)
14
18
  self
@@ -18,66 +22,94 @@ module YinxSt
18
22
  batches = Batches.new(n + 1)
19
23
  duration = "最近#{n}日"
20
24
 
21
- @chart = MyChart.js do
22
- material batches.all_notes
23
- material batches.unwind_tags, name: :unwind_tags
24
-
25
- select :yesterday do |note|
26
- note.dump_id == batches.latest_id
27
- end
28
-
29
- select :yesterday, from: :unwind_tags do |note|
30
- note.dump_id == batches.latest_id
31
- end
32
-
33
- select :changed_content do |note|
34
- note.status != :remained
35
- end
36
-
37
- select :moved_book do |note|
38
- note.moved_book?
39
- end
40
-
41
- select :changed_tags do |note|
42
- note.changed_tags?
43
- end
44
-
45
- group_by :stack_book do |note|
46
- stack = note.stack.nil? ? '' : "#{note.stack}/"
47
- "#{stack}#{note.book}"
48
- end
49
-
50
- group_by(:stack){|note| note.stack or 'NO_STACK'}
51
-
52
- group_by :number_of_tags do |note|
53
- note.tags.count
54
- end
55
-
56
- plainBar :dump_day, name: "#{duration}总数变化", w: 1000, h:240, asc: :key, last: n
57
- line :dump_day, :status, name: "#{duration}新建/修改/删除", from: :changed_content, w: 1000, h:240, asc: :key, keys: batches.time_line, last: n
58
- line :dump_day, name: "#{duration}移动笔记本", from: :moved_book, w: 1000, h:240, asc: :key, keys: batches.time_line, last: n
59
- line :dump_day, name: "#{duration}更改标签", from: :changed_tags, w: 1000, h:240, asc: :key, keys: batches.time_line, last: n
60
-
61
- bar :stack_book, name: '目前最大的10个笔记本', from: :yesterday, w:1400 ,h: 540, desc: :count, first: 10
62
- line :dump_day, :stack_book, name: "#{duration}笔记本体积变化", w: 1200, h:540, asc: :key, keys: batches.time_line, last: n
63
-
64
- bar :stack, name: '目前最大的10个笔记本组', from: :yesterday, w:1400 ,h: 240, desc: :count, first: 10
65
- line :dump_day, :stack, name: "#{duration}笔记本组体积变化", w: 1000, h:340, asc: :key, keys: batches.time_line, last: n
66
-
67
- pie :tags, name: '目前使用最多的15个标签', from: :yesterday__from__unwind_tags, w:1400 ,h: 340, desc: :count, first: 15
68
- bar :number_of_tags, name: '目前每篇笔记的标签数', from: :yesterday, w: 800, h: 240, asc: :key
69
- line :dump_day, :tags, name: "#{duration}标签数变化", from: :unwind_tags, w: 1400, h:740, asc: :key, keys: batches.time_line, last: n
25
+ time_line = batches.time_line
26
+
27
+ all = batches.all_notes
28
+ unwind_tags = batches.unwind_tags
29
+
30
+ yesterday = all.select{|note| note.dump_id == batches.latest_id}
31
+ yesterday_unwind_tags = unwind_tags.select{|note| note.dump_id == batches.latest_id}
32
+
33
+ changed_content = all.select{|note| note.status != :remained}
34
+ moved_book = all.select &:moved_book?
35
+ changed_tags = all.select &:changed_tags?
36
+
37
+ @chart = MyChartkick.bundle do |s|
38
+ s.my_line_chart all,
39
+ title: "#{duration}总数变化",
40
+ x: :dump_day,
41
+ min: 2400,
42
+ asc: :key,
43
+ last: n
44
+
45
+ s.my_line_chart changed_content,
46
+ title: "#{duration}新建/修改/删除",
47
+ x: :dump_day, y: :status,
48
+ keys: time_line,
49
+ asc: :key,
50
+ last: n
51
+
52
+ s.my_line_chart moved_book,
53
+ title: "#{duration}移动笔记本",
54
+ x: :dump_day,
55
+ keys: time_line,
56
+ asc: :key,
57
+ last: n
58
+
59
+ s.my_line_chart changed_tags,
60
+ title: "#{duration}更改标签",
61
+ x: :dump_day,
62
+ keys: time_line,
63
+ asc: :key,
64
+ last: n
65
+
66
+ s.my_column_chart yesterday,
67
+ title: "目前最大的10个笔记本",
68
+ x: :stack_book,
69
+ desc: :count,
70
+ first: 10
71
+
72
+ s.my_line_chart all,
73
+ title: "#{duration}笔记本体积变化",
74
+ x: :dump_day, y: :stack_book,
75
+ asc: :key,
76
+ height: '540px',
77
+ last: n
78
+
79
+ s.my_column_chart yesterday,
80
+ title: "目前最大的10个笔记本组",
81
+ x: :stack_name,
82
+ desc: :count,
83
+ first: 10
84
+
85
+ s.my_line_chart all,
86
+ title: "#{duration}笔记本组体积变化",
87
+ x: :dump_day, y: :stack_name,
88
+ asc: :key,
89
+ last: n
90
+
91
+ s.my_pie_chart yesterday_unwind_tags,
92
+ title: "目前使用最多的15个标签",
93
+ x: :tags,
94
+ desc: :count,
95
+ first: 15
96
+
97
+ s.my_column_chart yesterday,
98
+ title: "目前每篇笔记的标签数",
99
+ x: :tags_count,
100
+ asc: :key
101
+
102
+ s.my_line_chart unwind_tags,
103
+ title: "#{duration}标签数变化",
104
+ x: :dump_day, y: :tags,
105
+ asc: :key,
106
+ height: '740px',
107
+ last: n
70
108
 
71
109
  end
72
110
 
73
- self
74
111
  end
75
112
 
76
- attr_reader :chart
77
113
 
78
- def generate_html(erb_file=File.expand_path('../yinx_st/chart.erb', __FILE__))
79
- template = File.read erb_file
80
- html = ERB.new(template).result(binding)
81
- end
82
114
  end
83
115
  end
data/yinx_st.gemspec CHANGED
@@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency "yinx", "~> 0.1.0"
28
28
  spec.add_dependency "yinx_sql", "~> 0.1.2"
29
- spec.add_dependency "my_chart", "~> 0.1.0"
29
+ spec.add_dependency "my_chartkick", "~> 0.1.0"
30
30
  spec.add_dependency "time_seq", "~> 0.1.0"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yinx_st
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-18 00:00:00.000000000 Z
11
+ date: 2017-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.1.2
83
83
  - !ruby/object:Gem::Dependency
84
- name: my_chart
84
+ name: my_chartkick
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"