logfiction 0.1.0 → 0.1.1
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/logfiction/version.rb +1 -1
- data/lib/logfiction.rb +10 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d3f6118948e68e08a99df9c4bb1ecded3eb022b2e7b895947855614fbce4cd
|
4
|
+
data.tar.gz: 00b64f911225769a062722f0e92594501de25465b82a08b5aa2293128cca4d3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84d23d3d0e823e458841d03ab2f0927db86076a607f64aa79adbe10a1a093840dd6acd8cf67aa1a616eaa4389edc00dee0ff8b0a3576a2ad1507c40ec8351b5
|
7
|
+
data.tar.gz: 79c67ccd0bc6dfcf2b6b25ee1a7f93de74f4db47fb49c57db0705f0f0b6338a15fee4cca212579b0500b78d7ff04d1ec0d68ce936005b7493325374d6de857b7
|
data/lib/logfiction/version.rb
CHANGED
data/lib/logfiction.rb
CHANGED
@@ -19,7 +19,7 @@ module Logfiction
|
|
19
19
|
@transitions = []
|
20
20
|
@auto_transiton = {}
|
21
21
|
@assumptions = {}
|
22
|
-
@access_log = {}
|
22
|
+
@access_log = {}
|
23
23
|
# access_log: user_id & seuquence of states
|
24
24
|
# ex.) {user_id1(int):
|
25
25
|
# [{timestamp: timestamp(str),
|
@@ -321,7 +321,11 @@ module Logfiction
|
|
321
321
|
# Output:
|
322
322
|
# n_actions(int): total number of user's actions
|
323
323
|
# n_sessions: total number of user's sessions
|
324
|
-
def generate_accesslog(
|
324
|
+
def generate_accesslog(n_max, output_form={})
|
325
|
+
|
326
|
+
# initialize access_log
|
327
|
+
@access_log = {}
|
328
|
+
|
325
329
|
|
326
330
|
# set default value unless another manual settting done
|
327
331
|
if @transitions.size == 0
|
@@ -337,7 +341,7 @@ module Logfiction
|
|
337
341
|
end
|
338
342
|
|
339
343
|
n_row = 1
|
340
|
-
while n_row <
|
344
|
+
while n_row < n_max
|
341
345
|
@users.each do |user|
|
342
346
|
user_id = user[:user_id]
|
343
347
|
n_actions = 0
|
@@ -350,10 +354,10 @@ module Logfiction
|
|
350
354
|
end
|
351
355
|
end
|
352
356
|
end
|
353
|
-
self.output_accesslog(
|
357
|
+
self.output_accesslog(n_max, output_form)
|
354
358
|
end
|
355
359
|
|
356
|
-
def output_accesslog(
|
360
|
+
def output_accesslog(n_max, output_form)
|
357
361
|
# default settings
|
358
362
|
output_form = {
|
359
363
|
basic_log: [:timestamp, :user_id, :state_id, :items],
|
@@ -397,7 +401,7 @@ module Logfiction
|
|
397
401
|
end
|
398
402
|
end
|
399
403
|
end
|
400
|
-
output_accesslogs.sort{|a, b| a[:timestamp] <=> b[:timestamp]}
|
404
|
+
output_accesslogs.sort{|a, b| a[:timestamp] <=> b[:timestamp]}[0,n_max]
|
401
405
|
end
|
402
406
|
|
403
407
|
def export_logfile(n_max=10000, filetype='CSV', filepath='./fiction_log.csv')
|