twitter_friendly 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/twitter_friendly/rest/api.rb +0 -2
- data/lib/twitter_friendly/version.rb +1 -1
- metadata +1 -2
- data/lib/twitter_friendly/rest/extension/timelines.rb +0 -129
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5611cd772b52ea39a00bb73218c52495d4934d3994fb5f471e37f8f9dc81cccc
|
4
|
+
data.tar.gz: 9e6a9094fe7f541d30de5281fa812fb273956645044acd69b755963f4235fe95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa33d8279f915b94f5e43e96f2ce09ec32d0b019e18fbe214f207f403bbfcde773b45627d546f6177b7735a6f234954eb616f45f79b808f7322e0de775dad196
|
7
|
+
data.tar.gz: 848f0e69305824b7cf7d3fbe219fbd278957c9968ad619ec7e648ed641d60174f3475294a20b185a877de35de80dcfee6cf3c186bae6ff8e839e9f54d9f0ec2c
|
data/Gemfile.lock
CHANGED
@@ -11,7 +11,6 @@ require 'twitter_friendly/rest/tweets'
|
|
11
11
|
|
12
12
|
# 後方互換性のために残した
|
13
13
|
require 'twitter_friendly/rest/extension/clusters'
|
14
|
-
require 'twitter_friendly/rest/extension/timelines'
|
15
14
|
|
16
15
|
module TwitterFriendly
|
17
16
|
module REST
|
@@ -28,7 +27,6 @@ module TwitterFriendly
|
|
28
27
|
include TwitterFriendly::REST::Tweets
|
29
28
|
|
30
29
|
include TwitterFriendly::REST::Extension::Clusters
|
31
|
-
include TwitterFriendly::REST::Extension::Timelines
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter_friendly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ts-3156
|
@@ -189,7 +189,6 @@ files:
|
|
189
189
|
- lib/twitter_friendly/rest/api.rb
|
190
190
|
- lib/twitter_friendly/rest/collector.rb
|
191
191
|
- lib/twitter_friendly/rest/extension/clusters.rb
|
192
|
-
- lib/twitter_friendly/rest/extension/timelines.rb
|
193
192
|
- lib/twitter_friendly/rest/favorites.rb
|
194
193
|
- lib/twitter_friendly/rest/friends_and_followers.rb
|
195
194
|
- lib/twitter_friendly/rest/lists.rb
|
@@ -1,129 +0,0 @@
|
|
1
|
-
module TwitterFriendly
|
2
|
-
module REST
|
3
|
-
module Extension
|
4
|
-
module Timelines
|
5
|
-
|
6
|
-
EVERY_DAY = (0..6)
|
7
|
-
WDAY_COUNT = EVERY_DAY.map { |n| [n, 0] }.to_h
|
8
|
-
WDAY_NIL_COUNT = EVERY_DAY.map { |n| [n, nil] }.to_h
|
9
|
-
|
10
|
-
EVERY_HOUR = (0..23)
|
11
|
-
HOUR_COUNT = EVERY_HOUR.map { |n| [n, 0] }.to_h
|
12
|
-
HOUR_NIL_COUNT = EVERY_HOUR.map { |n| [n, nil] }.to_h
|
13
|
-
|
14
|
-
def count_wday(times)
|
15
|
-
times.each_with_object(WDAY_COUNT.dup) { |time, memo| memo[time.wday] += 1 }
|
16
|
-
end
|
17
|
-
|
18
|
-
def count_hour(times)
|
19
|
-
times.each_with_object(HOUR_COUNT.dup) { |time, memo| memo[time.hour] += 1 }
|
20
|
-
end
|
21
|
-
|
22
|
-
# [
|
23
|
-
# {:name=>"Sun", :y=>111, :drilldown=>"Sun"},
|
24
|
-
# {:name=>"Mon", :y=>95, :drilldown=>"Mon"},
|
25
|
-
# {:name=>"Tue", :y=>72, :drilldown=>"Tue"},
|
26
|
-
# {:name=>"Wed", :y=>70, :drilldown=>"Wed"},
|
27
|
-
# {:name=>"Thu", :y=>73, :drilldown=>"Thu"},
|
28
|
-
# {:name=>"Fri", :y=>81, :drilldown=>"Fri"},
|
29
|
-
# {:name=>"Sat", :y=>90, :drilldown=>"Sat"}
|
30
|
-
# ]
|
31
|
-
def usage_stats_wday_series_data(times, day_names:)
|
32
|
-
count_wday(times).map do |wday, count|
|
33
|
-
{name: day_names[wday], y: count, drilldown: day_names[wday]}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# [
|
38
|
-
# {
|
39
|
-
# :name=>"Sun",
|
40
|
-
# :id=>"Sun",
|
41
|
-
# :data=> [ ["0", 7], ["1", 12], ... , ["22", 10], ["23", 12] ]
|
42
|
-
# },
|
43
|
-
# ...
|
44
|
-
# {
|
45
|
-
# :name=>"Mon",
|
46
|
-
# :id=>"Mon",
|
47
|
-
# :data=> [ ["0", 22], ["1", 11], ... , ["22", 9], ["23", 14] ]
|
48
|
-
# }
|
49
|
-
def usage_stats_wday_drilldown_series(times, day_names:)
|
50
|
-
counts =
|
51
|
-
EVERY_DAY.each_with_object(WDAY_NIL_COUNT.dup) do |wday, memo|
|
52
|
-
memo[wday] = count_hour(times.select { |t| t.wday == wday })
|
53
|
-
end
|
54
|
-
|
55
|
-
counts.map { |wday, hour_count| [day_names[wday], hour_count] }.map do |wday, hour_count|
|
56
|
-
{name: wday, id: wday, data: hour_count.map { |hour, count| [hour.to_s, count] }}
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# [
|
61
|
-
# {:name=>"0", :y=>66, :drilldown=>"0"},
|
62
|
-
# {:name=>"1", :y=>47, :drilldown=>"1"},
|
63
|
-
# ...
|
64
|
-
# {:name=>"22", :y=>73, :drilldown=>"22"},
|
65
|
-
# {:name=>"23", :y=>87, :drilldown=>"23"}
|
66
|
-
# ]
|
67
|
-
def usage_stats_hour_series_data(times)
|
68
|
-
count_hour(times).map do |hour, count|
|
69
|
-
{name: hour.to_s, y: count, drilldown: hour.to_s}
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# [
|
74
|
-
# {:name=>"0", :id=>"0", :data=>[["Sun", 7], ["Mon", 22], ["Tue", 8], ["Wed", 9], ["Thu", 9], ["Fri", 6], ["Sat", 5]]},
|
75
|
-
# {:name=>"1", :id=>"1", :data=>[["Sun", 12], ["Mon", 11], ["Tue", 5], ["Wed", 5], ["Thu", 0], ["Fri", 8], ["Sat", 6]]},
|
76
|
-
# ...
|
77
|
-
# ]
|
78
|
-
def usage_stats_hour_drilldown_series(times, day_names:)
|
79
|
-
counts =
|
80
|
-
EVERY_HOUR.each_with_object(HOUR_NIL_COUNT.dup) do |hour, memo|
|
81
|
-
memo[hour] = count_wday(times.select { |t| t.hour == hour })
|
82
|
-
end
|
83
|
-
|
84
|
-
counts.map do |hour, wday_count|
|
85
|
-
{name: hour.to_s, id: hour.to_s, data: wday_count.map { |wday, count| [day_names[wday], count] }}
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# [
|
90
|
-
# {:name=>"Sun", :y=>14.778310502283107},
|
91
|
-
# {:name=>"Mon", :y=>12.273439878234399},
|
92
|
-
# {:name=>"Tue", :y=>10.110578386605784},
|
93
|
-
# {:name=>"Wed", :y=>9.843683409436835},
|
94
|
-
# {:name=>"Thu", :y=>10.547945205479452},
|
95
|
-
# {:name=>"Fri", :y=>10.61773211567732},
|
96
|
-
# {:name=>"Sat", :y=>12.115753424657534}
|
97
|
-
# ]
|
98
|
-
def twitter_addiction_series(times, day_names:)
|
99
|
-
max_duration = 5.minutes
|
100
|
-
wday_count =
|
101
|
-
EVERY_DAY.each_with_object(WDAY_NIL_COUNT.dup) do |wday, memo|
|
102
|
-
target_times = times.select { |t| t.wday == wday }
|
103
|
-
memo[wday] =
|
104
|
-
if target_times.empty?
|
105
|
-
nil
|
106
|
-
else
|
107
|
-
target_times.each_cons(2).map { |newer, older| (newer - older) < max_duration ? newer - older : max_duration }.sum
|
108
|
-
end
|
109
|
-
end
|
110
|
-
days = times.map { |t| t.to_date.to_s(:long) }.uniq.size
|
111
|
-
weeks = [days / 7.0, 1.0].max
|
112
|
-
wday_count.map do |wday, seconds|
|
113
|
-
{name: day_names[wday], y: (seconds.nil? ? nil : seconds / weeks / 60)}
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def usage_stats(tweet_times, day_names: %w(Sun Mon Tue Wed Thu Fri Sat))
|
118
|
-
[
|
119
|
-
usage_stats_wday_series_data(tweet_times, day_names: day_names),
|
120
|
-
usage_stats_wday_drilldown_series(tweet_times, day_names: day_names),
|
121
|
-
usage_stats_hour_series_data(tweet_times),
|
122
|
-
usage_stats_hour_drilldown_series(tweet_times, day_names: day_names),
|
123
|
-
twitter_addiction_series(tweet_times, day_names: day_names)
|
124
|
-
]
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|