logfiction 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 529e1bf118293b4f1f0f7a025097383d2cb205da09eeb85dd520ff36efaf2555
4
- data.tar.gz: 8fcb8c5c3157653d48f2d18f6467da6e49757c4dd817cb49da73726808f24e68
3
+ metadata.gz: 19a4637168a7070901cf63f691e956d0ac38b7dffe14895bad4b743f506a7ea3
4
+ data.tar.gz: 538cf9e43851bda623f49f937608338a8a899da1bfc4015180584201e2bd43d0
5
5
  SHA512:
6
- metadata.gz: b4afe337c2212e22d14c57d7b2987540c686516990b7b11dbcd9b979a8477b55a51c7f2959128287bf804cdb04080e0ac8b4c0a51e10357465e426030b2e68ef
7
- data.tar.gz: 8e410f763adbf3549ff2a4b6ff1c3e4afdf90e615b6a8ba8ce48b564f9f497aff963b32e85191246e78079fd6c63a4c1ab83b351cbac428ee43c0208c150eb8f
6
+ metadata.gz: 24575d8d7c45a4484fe26e10642ce56dadaf6f50f537a6e9a5d9dcf1bc1aee294ba4a617c85561746942a1d99755bfc904311c323365666da587b9cefc5bfa55
7
+ data.tar.gz: 4ac128c5960fc2e0d4b1fe5dda45109e28fca3f173fce46ad5ee78f11e67134a689d22985eacc5da525565849098dd5fe460c5418f6dd899bc38b9f38f2e41e4
data/README.md CHANGED
@@ -55,6 +55,58 @@ la.export_logfile(filetype='CSV',filepath='/path/to/file')
55
55
  # 2018-06-29 11:19:12 +0900,12,0,"",top_page_view
56
56
  ```
57
57
 
58
+ ## Advanced Usage
59
+ ```ruby
60
+ require 'logfiction'
61
+
62
+ assumtions = {
63
+ # Set the log start time to January 01, 2018 AM 9:00 AM
64
+ time_access_from: Time.parse("2018-01-01 09:00:00"),
65
+
66
+ # Set session limit to 20
67
+ user_max_sessions: 20,
68
+
69
+ # Set action limit to 200
70
+ user_max_actions: 100,
71
+
72
+ # Set the number of generated users to 500
73
+ n_users: 500,
74
+
75
+ # Set the number of generated items to 200
76
+ n_items: 200
77
+ }
78
+
79
+ la = Logfiction::AccessLog.new(assumtions)
80
+
81
+ # State and transition settings
82
+ states = [
83
+ {state_id: 0, state_name: 'top_page_view', item_type: :no_item},
84
+ {state_id: 1, state_name: 'list_page_view', item_type: :many},
85
+ {state_id: 2, state_name: 'detail_page_view', item_type: :one},
86
+ {state_id: 3, state_name: 'item_purchase', item_type: :one}
87
+ ]
88
+
89
+ transitions = [
90
+ {from: 0, to: 1, probability: 0.6, restriction: false},
91
+ {from: 1, to: 2, probability: 0.4, restriction: true},
92
+ {from: 2, to: 3, probability: 0.2, restriction: true, auto_transiton: 0}
93
+ ]
94
+
95
+ states_transtions = {
96
+ start_state: [0],
97
+ states: states,
98
+ transitions: transitions
99
+ }
100
+
101
+ la.generate_state_transiton(states_transtions)
102
+
103
+ # get logs
104
+ logs = la.generate_accesslog(100)
105
+
106
+ # export logs
107
+ la.export_logfile(100, filetype='CSV',filepath="./fictionlog.csv")
108
+ ```
109
+
58
110
  ## Development
59
111
 
60
112
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/logfiction.rb CHANGED
@@ -113,7 +113,8 @@ module Logfiction
113
113
  @start_state, @transitions = start_state, taranstion
114
114
  else
115
115
  @start_state = state_transtion[:start_state]
116
- @transitions = state_transtion[:states]
116
+ @transitions = state_transtion[:transitions]
117
+ states = state_transtion[:states]
117
118
  end
118
119
  # convert states
119
120
  states_hash = {}
@@ -346,6 +347,7 @@ module Logfiction
346
347
 
347
348
  n_row = 1
348
349
  while n_row < n_max
350
+ # only one time update each users in second loop
349
351
  @users.each do |user|
350
352
  user_id = user[:user_id]
351
353
  n_actions = 0
@@ -1,3 +1,3 @@
1
1
  module Logfiction
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logfiction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - rilmayer