StatsCollect 0.2.0.20110830 → 0.3.0.20120314
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +3 -1
- data/ChangeLog +15 -0
- data/LICENSE +1 -1
- data/README +2 -5
- data/ReleaseInfo +8 -8
- data/bin/StatsCollect.rb +3 -3
- data/lib/StatsCollect/Backends/MySQL.rb +63 -63
- data/lib/StatsCollect/Backends/Terminal.rb +43 -43
- data/lib/StatsCollect/Locations/AddThis.rb +7 -7
- data/lib/StatsCollect/Locations/CSV.rb +9 -9
- data/lib/StatsCollect/Locations/Facebook.rb +7 -7
- data/lib/StatsCollect/Locations/FacebookArtist.rb +7 -7
- data/lib/StatsCollect/Locations/FacebookLike.rb +7 -7
- data/lib/StatsCollect/Locations/GoogleGroup.rb +10 -10
- data/lib/StatsCollect/Locations/GoogleSearch.rb +6 -6
- data/lib/StatsCollect/Locations/MySpace.rb +43 -43
- data/lib/StatsCollect/Locations/RB.rb +10 -10
- data/lib/StatsCollect/Locations/ReverbNation.rb +34 -34
- data/lib/StatsCollect/Locations/Tweets.rb +7 -7
- data/lib/StatsCollect/Locations/Twitter.rb +11 -11
- data/lib/StatsCollect/Locations/Youtube.rb +33 -49
- data/lib/StatsCollect/Notifiers/Custom.rb +3 -3
- data/lib/StatsCollect/Notifiers/LogFile.rb +4 -4
- data/lib/StatsCollect/Notifiers/None.rb +3 -3
- data/lib/StatsCollect/Notifiers/SendMail.rb +3 -3
- data/lib/StatsCollect/Stats.rb +81 -81
- data/lib/StatsCollect/StatsOrdersProxy.rb +3 -3
- data/lib/StatsCollect/StatsProxy.rb +28 -28
- metadata +24 -12
data/AUTHORS
CHANGED
data/ChangeLog
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
= StatsCollect Release History
|
2
2
|
|
3
|
+
== 0.3.0.20120314 (Beta)
|
4
|
+
|
5
|
+
* Added rUtilAnts dependency in the release information.
|
6
|
+
* Adapted release information to last version of RubyPackager.
|
7
|
+
* Removed rdoc warning in documentation
|
8
|
+
* Updated Copyright information
|
9
|
+
* Updated email address of Muriel Salvan
|
10
|
+
* Adapted comments to match a better RDoc syntax
|
11
|
+
* Adapted to new version of rUtilAnts
|
12
|
+
* Renamed public methods to match standard Ruby's conventions
|
13
|
+
* Locations/GoogleGroup: Adapted to new GoogleGroups version.
|
14
|
+
* Locations/GoogleSearch: Adapted to new Google search version.
|
15
|
+
* Locations/ReverbNation: Adapted to new ReverbNation version.
|
16
|
+
* Locations/Youtube: Adapted to new Youtube version.
|
17
|
+
|
3
18
|
== 0.2.0.20110830 (Beta)
|
4
19
|
|
5
20
|
=== General
|
data/LICENSE
CHANGED
@@ -6,7 +6,7 @@ This list is found in the file named AUTHORS.
|
|
6
6
|
The AUTHORS and LICENSE files have to be included in any release of software
|
7
7
|
embedding source code of this package, or using it as a derivative software.
|
8
8
|
|
9
|
-
Copyright (c) 2010 -
|
9
|
+
Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
10
10
|
|
11
11
|
Redistribution and use in source and binary forms, with or without
|
12
12
|
modification, are permitted provided that the following conditions are met:
|
data/README
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
-- This file is best viewed when processed by rdoc.
|
2
|
-
++
|
3
|
-
|
4
1
|
= StatsCollect
|
5
2
|
|
6
3
|
StatsCollect is a little framework gathering statistics from external sources (social networks, web sites...), stored in pluggable backends. It can be very easily extended thanks to its plugins (currently include Facebook, Myspace, Youtube, Google).
|
@@ -11,8 +8,8 @@ Check the website at http://statscollect.sourceforge.net
|
|
11
8
|
|
12
9
|
== Who wrote it ?
|
13
10
|
|
14
|
-
Check the AUTHORS[link:
|
11
|
+
Check the AUTHORS[link:AUTHORS.html] file.
|
15
12
|
|
16
13
|
== What is the license ?
|
17
14
|
|
18
|
-
You can find out in the LICENSE[link:
|
15
|
+
You can find out in the LICENSE[link:LICENSE.html] file.
|
data/ReleaseInfo
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
# This file has been generated by RubyPackager during a delivery.
|
3
|
-
# More info about RubyPackager: http://rubypackager.sourceforge.net
|
4
|
-
{
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
}
|
1
|
+
|
2
|
+
# This file has been generated by RubyPackager during a delivery.
|
3
|
+
# More info about RubyPackager: http://rubypackager.sourceforge.net
|
4
|
+
{
|
5
|
+
:version => '0.3.0.20120314',
|
6
|
+
:tags => [ 'Beta' ],
|
7
|
+
:dev_status => 'Beta'
|
8
|
+
}
|
data/bin/StatsCollect.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/bin/env ruby
|
2
2
|
#--
|
3
|
-
# Copyright (c) 2010 -
|
3
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
4
4
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
5
5
|
#++
|
6
6
|
|
7
7
|
require 'rUtilAnts/Logging'
|
8
|
-
RUtilAnts::Logging::
|
8
|
+
RUtilAnts::Logging::install_logger_on_object
|
9
9
|
require 'tmpdir'
|
10
10
|
lLogFile = "#{Dir.tmpdir}/StatsCollect_#{Process.pid}.log"
|
11
|
-
|
11
|
+
set_log_file(lLogFile)
|
12
12
|
require 'StatsCollect/Stats'
|
13
13
|
|
14
14
|
rErrorCode = 0
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -37,39 +37,39 @@ module StatsCollect
|
|
37
37
|
|
38
38
|
# Initialize a session of this backend
|
39
39
|
#
|
40
|
-
# Parameters
|
40
|
+
# Parameters::
|
41
41
|
# * *iConf* (<em>map<Symbol,Object></em>): Configuration of this backend
|
42
|
-
def
|
42
|
+
def init_session(iConf)
|
43
43
|
require 'rUtilAnts/MySQLPool'
|
44
|
-
RUtilAnts::MySQLPool::
|
45
|
-
lError, @MySQLConnection =
|
44
|
+
RUtilAnts::MySQLPool::install_mysql_pool_on_object
|
45
|
+
lError, @MySQLConnection = connect_to_mysql(iConf[:DBHost], iConf[:DBName], iConf[:DBUser], iConf[:DBPassword])
|
46
46
|
if (lError != nil)
|
47
47
|
raise lError
|
48
48
|
end
|
49
|
-
@StatementSelectFromStatsOrders =
|
50
|
-
@StatementDeleteFromStatsOrders =
|
51
|
-
@StatementInsertIntoStatsLocations =
|
52
|
-
@StatementInsertIntoStatsCategories =
|
53
|
-
@StatementInsertIntoStatsObjects =
|
54
|
-
@StatementInsertIntoStatsValues =
|
55
|
-
@StatementSelectFromStatsValues =
|
56
|
-
@StatementInsertIntoStatsBinaryValues =
|
57
|
-
@StatementInsertIntoStatsOrders =
|
58
|
-
@StatementSelectFromStatsLastKeys =
|
59
|
-
@StatementSelectFromStatsBinaryValues =
|
60
|
-
@StatementInsertIntoStatsLastKeys =
|
61
|
-
@StatementUpdateStatsLastKeys =
|
49
|
+
@StatementSelectFromStatsOrders = get_prepared_statement(@MySQLConnection, 'SELECT id, timestamp, locations_list, objects_list, categories_list, status FROM stats_orders WHERE (status = 0 OR status = 1) AND timestamp < ? ORDER BY timestamp DESC', :leave_open => true)
|
50
|
+
@StatementDeleteFromStatsOrders = get_prepared_statement(@MySQLConnection, 'DELETE FROM stats_orders WHERE id=?', :leave_open => true)
|
51
|
+
@StatementInsertIntoStatsLocations = get_prepared_statement(@MySQLConnection, 'INSERT INTO stats_locations (name) VALUES (?)', :leave_open => true)
|
52
|
+
@StatementInsertIntoStatsCategories = get_prepared_statement(@MySQLConnection, 'INSERT INTO stats_categories (name, value_type) VALUES (?, ?)', :leave_open => true)
|
53
|
+
@StatementInsertIntoStatsObjects = get_prepared_statement(@MySQLConnection, 'INSERT INTO stats_objects (name) VALUES (?)', :leave_open => true)
|
54
|
+
@StatementInsertIntoStatsValues = get_prepared_statement(@MySQLConnection, 'INSERT INTO stats_values (timestamp, stats_location_id, stats_object_id, stats_category_id, value) VALUES (?, ?, ?, ?, ?)', :leave_open => true)
|
55
|
+
@StatementSelectFromStatsValues = get_prepared_statement(@MySQLConnection, 'SELECT value FROM stats_values WHERE timestamp = ? AND stats_location_id = ? AND stats_object_id = ? AND stats_category_id = ?', :leave_open => true)
|
56
|
+
@StatementInsertIntoStatsBinaryValues = get_prepared_statement(@MySQLConnection, 'INSERT INTO stats_binary_values (timestamp, stats_location_id, stats_object_id, stats_category_id, value) VALUES (?, ?, ?, ?, ?)', :leave_open => true)
|
57
|
+
@StatementInsertIntoStatsOrders = get_prepared_statement(@MySQLConnection, 'INSERT INTO stats_orders (timestamp, locations_list, objects_list, categories_list, status) VALUES (?, ?, ?, ?, ?)', :leave_open => true)
|
58
|
+
@StatementSelectFromStatsLastKeys = get_prepared_statement(@MySQLConnection, 'SELECT stats_value_id FROM stats_last_keys WHERE stats_location_id = ? AND stats_object_id = ? AND stats_category_id = ?', :leave_open => true)
|
59
|
+
@StatementSelectFromStatsBinaryValues = get_prepared_statement(@MySQLConnection, 'SELECT id, value FROM stats_binary_values WHERE stats_location_id = ? AND stats_object_id = ? AND stats_category_id = ? AND id >= ? ORDER BY id', :leave_open => true)
|
60
|
+
@StatementInsertIntoStatsLastKeys = get_prepared_statement(@MySQLConnection, 'INSERT INTO stats_last_keys (stats_location_id, stats_object_id, stats_category_id, stats_value_id) VALUES (?, ?, ?, ?)', :leave_open => true)
|
61
|
+
@StatementUpdateStatsLastKeys = get_prepared_statement(@MySQLConnection, 'UPDATE stats_last_keys SET stats_value_id = ? WHERE stats_location_id = ? AND stats_object_id = ? AND stats_category_id = ?', :leave_open => true)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Get the next stats orders.
|
65
65
|
#
|
66
|
-
# Parameters
|
66
|
+
# Parameters::
|
67
67
|
# * *oStatsOrdersProxy* (_StatsOrdersProxy_): The stats orders proxy to be used to give stats orders
|
68
|
-
def
|
68
|
+
def get_stats_orders(oStatsOrdersProxy)
|
69
69
|
@StatementSelectFromStatsOrders.execute(DateTime.now.to_MySQLTime)
|
70
70
|
@StatementSelectFromStatsOrders.each do |iRow|
|
71
71
|
iID, iMySQLTimeStamp, iStrLocations, iStrObjects, iStrCategories, iStatus = iRow
|
72
|
-
oStatsOrdersProxy.
|
72
|
+
oStatsOrdersProxy.add_stats_order(
|
73
73
|
iID,
|
74
74
|
DateTime.civil(
|
75
75
|
iMySQLTimeStamp.year,
|
@@ -88,9 +88,9 @@ module StatsCollect
|
|
88
88
|
# Dequeue the given stat orders IDs.
|
89
89
|
# Code to begin a new transaction can be set in this method too. In this case, the dequeue should be part of the transaction, or it will have to be re-enqueued during rollback method call (otherwise orders will be lost).
|
90
90
|
#
|
91
|
-
# Parameters
|
91
|
+
# Parameters::
|
92
92
|
# * *iLstStatsOrderIDs* (<em>list<Integer></em>): The list of stats order IDs to dequeue
|
93
|
-
def
|
93
|
+
def dequeue_stats_orders(iLstStatsOrderIDs)
|
94
94
|
@MySQLConnection.query('start transaction')
|
95
95
|
iLstStatsOrderIDs.each do |iStatsOrderID|
|
96
96
|
@StatementDeleteFromStatsOrders.execute(iStatsOrderID)
|
@@ -99,9 +99,9 @@ module StatsCollect
|
|
99
99
|
|
100
100
|
# Get the list of known locations
|
101
101
|
#
|
102
|
-
# Return
|
102
|
+
# Return::
|
103
103
|
# * <em>map<String,Integer></em>: Each location with its associated ID
|
104
|
-
def
|
104
|
+
def get_known_locations
|
105
105
|
rKnownLocations = {}
|
106
106
|
|
107
107
|
@MySQLConnection.query('SELECT name, id FROM stats_locations').each do |iRow|
|
@@ -114,9 +114,9 @@ module StatsCollect
|
|
114
114
|
|
115
115
|
# Get the list of known categories
|
116
116
|
#
|
117
|
-
# Return
|
117
|
+
# Return::
|
118
118
|
# * <em>map<String,[Integer,Integer]></em>: Each category with its associated ID and value type
|
119
|
-
def
|
119
|
+
def get_known_categories
|
120
120
|
rKnownCategories = {}
|
121
121
|
|
122
122
|
@MySQLConnection.query('SELECT name, id, value_type FROM stats_categories').each do |iRow|
|
@@ -129,9 +129,9 @@ module StatsCollect
|
|
129
129
|
|
130
130
|
# Get the list of known objects
|
131
131
|
#
|
132
|
-
# Return
|
132
|
+
# Return::
|
133
133
|
# * <em>map<String,Integer></em>: Each object with its associated ID
|
134
|
-
def
|
134
|
+
def get_known_objects
|
135
135
|
rKnownObjects = {}
|
136
136
|
|
137
137
|
@MySQLConnection.query('SELECT name, id FROM stats_objects').each do |iRow|
|
@@ -144,11 +144,11 @@ module StatsCollect
|
|
144
144
|
|
145
145
|
# Add a new location
|
146
146
|
#
|
147
|
-
# Parameters
|
147
|
+
# Parameters::
|
148
148
|
# * *iLocation* (_String_): The location
|
149
|
-
# Return
|
149
|
+
# Return::
|
150
150
|
# * _Integer_: Its resulting ID
|
151
|
-
def
|
151
|
+
def add_location(iLocation)
|
152
152
|
@StatementInsertIntoStatsLocations.execute(iLocation)
|
153
153
|
|
154
154
|
return @StatementInsertIntoStatsLocations.insert_id
|
@@ -156,12 +156,12 @@ module StatsCollect
|
|
156
156
|
|
157
157
|
# Add a new category
|
158
158
|
#
|
159
|
-
# Parameters
|
159
|
+
# Parameters::
|
160
160
|
# * *iCategory* (_String_): The category
|
161
161
|
# * *iValueType* (_Integer_): Its value type
|
162
|
-
# Return
|
162
|
+
# Return::
|
163
163
|
# * _Integer_: Its resulting ID
|
164
|
-
def
|
164
|
+
def add_category(iCategory, iValueType)
|
165
165
|
@StatementInsertIntoStatsCategories.execute(iCategory, iValueType)
|
166
166
|
|
167
167
|
return @StatementInsertIntoStatsCategories.insert_id
|
@@ -169,11 +169,11 @@ module StatsCollect
|
|
169
169
|
|
170
170
|
# Add a new object
|
171
171
|
#
|
172
|
-
# Parameters
|
172
|
+
# Parameters::
|
173
173
|
# * *iObject* (_String_): The object
|
174
|
-
# Return
|
174
|
+
# Return::
|
175
175
|
# * _Integer_: Its resulting ID
|
176
|
-
def
|
176
|
+
def add_object(iObject)
|
177
177
|
@StatementInsertIntoStatsObjects.execute(iObject)
|
178
178
|
|
179
179
|
return @StatementInsertIntoStatsObjects.insert_id
|
@@ -181,14 +181,14 @@ module StatsCollect
|
|
181
181
|
|
182
182
|
# Add a new stat
|
183
183
|
#
|
184
|
-
# Parameters
|
184
|
+
# Parameters::
|
185
185
|
# * *iTimeStamp* (_DateTime_): The time stamp
|
186
186
|
# * *iLocationID* (_Integer_): Location ID
|
187
187
|
# * *iObjectID* (_Integer_): Object ID
|
188
188
|
# * *iCategoryID* (_Integer_): Category ID
|
189
189
|
# * *iValue* (_Object_): The value to store
|
190
190
|
# * *iValueType* (_Integer_): The value type
|
191
|
-
def
|
191
|
+
def add_stat(iTimeStamp, iLocationID, iObjectID, iCategoryID, iValue, iValueType)
|
192
192
|
# Do we need to store this value ID in the last keys ?
|
193
193
|
lStoreInLastKeys = false
|
194
194
|
lExistingLastKey = false
|
@@ -253,7 +253,7 @@ module StatsCollect
|
|
253
253
|
when DIFFDATA_SAME
|
254
254
|
# Nothing to do
|
255
255
|
else
|
256
|
-
|
256
|
+
log_err "Unknown diff value type: #{iRowValue[0..0]}"
|
257
257
|
raise RuntimeError.new("Unknown diff value type: #{iRowValue[0..0]}")
|
258
258
|
end
|
259
259
|
end
|
@@ -293,7 +293,7 @@ module StatsCollect
|
|
293
293
|
when STATS_VALUE_TYPE_STRING
|
294
294
|
lStrValue = iValue
|
295
295
|
else
|
296
|
-
|
296
|
+
log_err "Unknown category value type: #{iValueType}. It will be treated as Unknown."
|
297
297
|
lStrValue = iValue.to_s
|
298
298
|
end
|
299
299
|
# Add the new stat in the DB for real
|
@@ -311,15 +311,15 @@ module StatsCollect
|
|
311
311
|
|
312
312
|
# Get an existing stat value
|
313
313
|
#
|
314
|
-
# Parameters
|
314
|
+
# Parameters::
|
315
315
|
# * *iTimeStamp* (_DateTime_): The timestamp
|
316
316
|
# * *iLocationID* (_Integer_): The location ID
|
317
317
|
# * *iObjectID* (_Integer_): The object ID
|
318
318
|
# * *iCategoryID* (_Integer_): The category ID
|
319
319
|
# * *iValueType* (_Integer_): The value type
|
320
|
-
# Return
|
320
|
+
# Return::
|
321
321
|
# * _Object_: The corresponding value, or nil if none
|
322
|
-
def
|
322
|
+
def get_stat(iTimeStamp, iLocationID, iObjectID, iCategoryID, iValueType)
|
323
323
|
rValue = nil
|
324
324
|
|
325
325
|
@StatementSelectFromStatsValues.execute(iTimeStamp.to_MySQLTime, iLocationID, iObjectID, iCategoryID)
|
@@ -341,7 +341,7 @@ module StatsCollect
|
|
341
341
|
when STATS_VALUE_TYPE_STRING
|
342
342
|
rValue = lStrValue
|
343
343
|
else
|
344
|
-
|
344
|
+
log_err "Unknown category value type: #{iValueType}. It will be treated as Unknown."
|
345
345
|
rValue = lStrValue
|
346
346
|
end
|
347
347
|
break
|
@@ -353,13 +353,13 @@ module StatsCollect
|
|
353
353
|
|
354
354
|
# Add a new stats order
|
355
355
|
#
|
356
|
-
# Parameters
|
356
|
+
# Parameters::
|
357
357
|
# * *iTimeStamp* (_DateTime_): The time stamp
|
358
358
|
# * *iLstLocations* (<em>list<String></em>): List of locations
|
359
359
|
# * *iLstObjects* (<em>list<String></em>): List of objects
|
360
360
|
# * *iLstCategories* (<em>list<String></em>): List of categories
|
361
361
|
# * *iStatus* (_Integer_): The order status
|
362
|
-
def
|
362
|
+
def put_new_stats_order(iTimeStamp, iLstLocations, iLstObjects, iLstCategories, iStatus)
|
363
363
|
lMySQLTime = Mysql::Time.new(
|
364
364
|
iTimeStamp.year,
|
365
365
|
iTimeStamp.month,
|
@@ -381,21 +381,21 @@ module StatsCollect
|
|
381
381
|
end
|
382
382
|
|
383
383
|
# Close a session of this backend
|
384
|
-
def
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
384
|
+
def close_session
|
385
|
+
close_prepared_statement(@MySQLConnection, @StatementSelectFromStatsOrders)
|
386
|
+
close_prepared_statement(@MySQLConnection, @StatementDeleteFromStatsOrders)
|
387
|
+
close_prepared_statement(@MySQLConnection, @StatementInsertIntoStatsLocations)
|
388
|
+
close_prepared_statement(@MySQLConnection, @StatementInsertIntoStatsCategories)
|
389
|
+
close_prepared_statement(@MySQLConnection, @StatementInsertIntoStatsObjects)
|
390
|
+
close_prepared_statement(@MySQLConnection, @StatementInsertIntoStatsValues)
|
391
|
+
close_prepared_statement(@MySQLConnection, @StatementSelectFromStatsValues)
|
392
|
+
close_prepared_statement(@MySQLConnection, @StatementInsertIntoStatsBinaryValues)
|
393
|
+
close_prepared_statement(@MySQLConnection, @StatementInsertIntoStatsOrders)
|
394
|
+
close_prepared_statement(@MySQLConnection, @StatementSelectFromStatsLastKeys)
|
395
|
+
close_prepared_statement(@MySQLConnection, @StatementSelectFromStatsBinaryValues)
|
396
|
+
close_prepared_statement(@MySQLConnection, @StatementInsertIntoStatsLastKeys)
|
397
|
+
close_prepared_statement(@MySQLConnection, @StatementUpdateStatsLastKeys)
|
398
|
+
close_mysql(@MySQLConnection)
|
399
399
|
end
|
400
400
|
|
401
401
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -11,37 +11,37 @@ module StatsCollect
|
|
11
11
|
|
12
12
|
# Initialize a session of this backend
|
13
13
|
#
|
14
|
-
# Parameters
|
14
|
+
# Parameters::
|
15
15
|
# * *iConf* (<em>map<Symbol,Object></em>): Configuration of this backend
|
16
|
-
def
|
16
|
+
def init_session(iConf)
|
17
17
|
@IdxID = 0
|
18
|
-
|
18
|
+
log_msg 'Session initialized.'
|
19
19
|
end
|
20
20
|
|
21
21
|
# Get the next stats orders.
|
22
22
|
#
|
23
|
-
# Parameters
|
23
|
+
# Parameters::
|
24
24
|
# * *oStatsOrdersProxy* (_StatsOrdersProxy_): The stats orders proxy to be used to give stats orders
|
25
|
-
def
|
26
|
-
oStatsOrdersProxy.
|
27
|
-
# oStatsOrdersProxy.
|
28
|
-
|
25
|
+
def get_stats_orders(oStatsOrdersProxy)
|
26
|
+
oStatsOrdersProxy.add_stats_order(0, DateTime.now, [], [], [], STATS_ORDER_STATUS_TOBEPROCESSED)
|
27
|
+
# oStatsOrdersProxy.add_stats_order(0, DateTime.now, ['MySpace'], [], ['Friends list'], STATS_ORDER_STATUS_TOBEPROCESSED)
|
28
|
+
log_msg 'Added stats order 0.'
|
29
29
|
end
|
30
30
|
|
31
31
|
# Dequeue the given stat orders IDs.
|
32
32
|
# Code to begin a new transaction can be set in this method too. In this case, the dequeue should be part of the transaction, or it will have to be re-enqueued during rollback method call (otherwise orders will be lost).
|
33
33
|
#
|
34
|
-
# Parameters
|
34
|
+
# Parameters::
|
35
35
|
# * *iLstStatsOrderIDs* (<em>list<Integer></em>): The list of stats order IDs to dequeue
|
36
|
-
def
|
37
|
-
|
36
|
+
def dequeue_stats_orders(iLstStatsOrderIDs)
|
37
|
+
log_msg "Transaction started and stats orders dequeued: #{iLstStatsOrderIDs.join(', ')}"
|
38
38
|
end
|
39
39
|
|
40
40
|
# Get the list of known locations
|
41
41
|
#
|
42
|
-
# Return
|
42
|
+
# Return::
|
43
43
|
# * <em>map<String,Integer></em>: Each location with its associated ID
|
44
|
-
def
|
44
|
+
def get_known_locations
|
45
45
|
rKnownLocations = {}
|
46
46
|
|
47
47
|
return rKnownLocations
|
@@ -49,9 +49,9 @@ module StatsCollect
|
|
49
49
|
|
50
50
|
# Get the list of known categories
|
51
51
|
#
|
52
|
-
# Return
|
52
|
+
# Return::
|
53
53
|
# * <em>map<String,[Integer,Integer]></em>: Each category with its associated ID and value type
|
54
|
-
def
|
54
|
+
def get_known_categories
|
55
55
|
rKnownCategories = {}
|
56
56
|
|
57
57
|
return rKnownCategories
|
@@ -59,9 +59,9 @@ module StatsCollect
|
|
59
59
|
|
60
60
|
# Get the list of known objects
|
61
61
|
#
|
62
|
-
# Return
|
62
|
+
# Return::
|
63
63
|
# * <em>map<String,Integer></em>: Each object with its associated ID
|
64
|
-
def
|
64
|
+
def get_known_objects
|
65
65
|
rKnownObjects = {}
|
66
66
|
|
67
67
|
return rKnownObjects
|
@@ -69,12 +69,12 @@ module StatsCollect
|
|
69
69
|
|
70
70
|
# Add a new location
|
71
71
|
#
|
72
|
-
# Parameters
|
72
|
+
# Parameters::
|
73
73
|
# * *iLocation* (_String_): The location
|
74
|
-
# Return
|
74
|
+
# Return::
|
75
75
|
# * _Integer_: Its resulting ID
|
76
|
-
def
|
77
|
-
|
76
|
+
def add_location(iLocation)
|
77
|
+
log_msg "Added location: #{iLocation} (#{@IdxID})"
|
78
78
|
@IdxID += 1
|
79
79
|
|
80
80
|
return @IdxID-1
|
@@ -82,13 +82,13 @@ module StatsCollect
|
|
82
82
|
|
83
83
|
# Add a new category
|
84
84
|
#
|
85
|
-
# Parameters
|
85
|
+
# Parameters::
|
86
86
|
# * *iCategory* (_String_): The category
|
87
87
|
# * *iValueType* (_Integer_): Its value type
|
88
|
-
# Return
|
88
|
+
# Return::
|
89
89
|
# * _Integer_: Its resulting ID
|
90
|
-
def
|
91
|
-
|
90
|
+
def add_category(iCategory, iValueType)
|
91
|
+
log_msg "Added category: #{iCategory}, #{iValueType} (#{@IdxID})"
|
92
92
|
@IdxID += 1
|
93
93
|
|
94
94
|
return @IdxID-1
|
@@ -96,12 +96,12 @@ module StatsCollect
|
|
96
96
|
|
97
97
|
# Add a new object
|
98
98
|
#
|
99
|
-
# Parameters
|
99
|
+
# Parameters::
|
100
100
|
# * *iObject* (_String_): The object
|
101
|
-
# Return
|
101
|
+
# Return::
|
102
102
|
# * _Integer_: Its resulting ID
|
103
|
-
def
|
104
|
-
|
103
|
+
def add_object(iObject)
|
104
|
+
log_msg "Added object: #{iObject} (#{@IdxID})"
|
105
105
|
@IdxID += 1
|
106
106
|
|
107
107
|
return @IdxID-1
|
@@ -109,57 +109,57 @@ module StatsCollect
|
|
109
109
|
|
110
110
|
# Add a new stat
|
111
111
|
#
|
112
|
-
# Parameters
|
112
|
+
# Parameters::
|
113
113
|
# * *iTimeStamp* (_DateTime_): The time stamp
|
114
114
|
# * *iLocationID* (_Integer_): Location ID
|
115
115
|
# * *iObjectID* (_Integer_): Object ID
|
116
116
|
# * *iCategoryID* (_Integer_): Category ID
|
117
117
|
# * *iValue* (_Object_): The value to store
|
118
118
|
# * *iValueType* (_Integer_): The value type
|
119
|
-
def
|
120
|
-
|
119
|
+
def add_stat(iTimeStamp, iLocationID, iObjectID, iCategoryID, iValue, iValueType)
|
120
|
+
log_msg "Added stat: #{iTimeStamp} | Location: #{iLocationID} | Object: #{iObjectID} | Category: #{iCategoryID} (value type: #{iValueType}) | Value: #{iValue}"
|
121
121
|
end
|
122
122
|
|
123
123
|
# Get an existing stat value
|
124
124
|
#
|
125
|
-
# Parameters
|
125
|
+
# Parameters::
|
126
126
|
# * *iTimeStamp* (_DateTime_): The timestamp
|
127
127
|
# * *iLocationID* (_Integer_): The location ID
|
128
128
|
# * *iObjectID* (_Integer_): The object ID
|
129
129
|
# * *iCategoryID* (_Integer_): The category ID
|
130
130
|
# * *iValueType* (_Integer_): The value type
|
131
|
-
# Return
|
131
|
+
# Return::
|
132
132
|
# * _Object_: The corresponding value, or nil if none
|
133
|
-
def
|
134
|
-
|
133
|
+
def get_stat(iTimeStamp, iLocationID, iObjectID, iCategoryID, iValueType)
|
134
|
+
log_msg "Get stat: #{iTimeStamp} | Location: #{iLocationID} | Object: #{iObjectID} | Category: #{iCategoryID} (value type: #{iValueType})"
|
135
135
|
|
136
136
|
return nil
|
137
137
|
end
|
138
138
|
|
139
139
|
# Add a new stats order
|
140
140
|
#
|
141
|
-
# Parameters
|
141
|
+
# Parameters::
|
142
142
|
# * *iTimeStamp* (_DateTime_): The time stamp
|
143
143
|
# * *iLstLocations* (<em>list<String></em>): List of locations
|
144
144
|
# * *iLstObjects* (<em>list<String></em>): List of objects
|
145
145
|
# * *iLstCategories* (<em>list<String></em>): List of categories
|
146
146
|
# * *iStatus* (_Integer_): The order status
|
147
|
-
def
|
148
|
-
|
147
|
+
def put_new_stats_order(iTimeStamp, iLstLocations, iLstObjects, iLstCategories, iStatus)
|
148
|
+
log_msg "Added new stats order: #{iTimeStamp} | Locations: #{iLstLocations.join(', ')} | Objects: #{iLstObjects.join(', ')} | Categories: #{iLstCategories.join(', ')} | Status: #{iStatus}"
|
149
149
|
end
|
150
150
|
|
151
151
|
# Commit the current stats order transaction
|
152
152
|
def commit
|
153
|
-
|
153
|
+
log_msg 'Transaction committed'
|
154
154
|
end
|
155
155
|
|
156
156
|
# Rollback the current stats order transaction
|
157
157
|
def rollback
|
158
|
-
|
158
|
+
log_msg 'Transaction rollbacked'
|
159
159
|
end
|
160
160
|
|
161
161
|
# Close a session of this backend
|
162
|
-
def
|
162
|
+
def close_session
|
163
163
|
end
|
164
164
|
|
165
165
|
end
|