periodic_counter 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -7,7 +7,7 @@ Requirements
7
7
  ------------
8
8
 
9
9
  <pre>
10
- sudo gem install periodic_template
10
+ sudo gem install periodic_counter
11
11
  </pre>
12
12
 
13
13
  Create columns
@@ -48,15 +48,14 @@ class PeriodicCounter
48
48
  computed_at = data["#{col}_at"] || Time.now.utc
49
49
  duration = column_to_period_integer(col)
50
50
  time_since_compute = Time.now.utc - computed_at
51
- starting_value = data[col].to_i
52
51
  if (time_since_compute - duration) >= 0
53
- record[col] = count - starting_value
54
52
  data[col] = count
55
53
  data["#{col}_at"] = Time.now.utc
56
54
  else
57
55
  data[col] ||= count
58
56
  data["#{col}_at"] ||= Time.now.utc
59
57
  end
58
+ record[col] = count - data[col].to_i
60
59
  end
61
60
  # Update record
62
61
  record["#{column}_data"] = "'#{YAML::dump(data)}'"
data/require.rb CHANGED
@@ -18,7 +18,7 @@ Require do
18
18
  name 'periodic_counter'
19
19
  homepage "http://github.com/winton/#{name}"
20
20
  summary "Maintains period fields on any counter column in your database"
21
- version '0.1.0'
21
+ version '0.1.1'
22
22
  end
23
23
 
24
24
  bin { require 'lib/periodic_counter' }
data/spec/log/test.log CHANGED
@@ -9179,5 +9179,785 @@ counter_last_2_days_at: *id001
9179
9179
  counter_last_2_days: 3
9180
9180
  ', counter_last_day = 1, counter_last_2_days = 2
9181
9181
  WHERE id = 1
9182
+ 
9183
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9184
+ SQL (4.4ms) SET SQL_AUTO_IS_NULL=0
9185
+ SQL (12.9ms) SHOW TABLES
9186
+ SQL (0.3ms) SELECT version FROM schema_migrations
9187
+ SQL (0.2ms) SHOW TABLES
9188
+ SQL (4.4ms) SELECT version FROM schema_migrations
9189
+ Migrating to Counters (1)
9190
+ SQL (3.0ms) SHOW TABLES
9191
+ SQL (0.2ms) SELECT version FROM schema_migrations
9192
+ SQL (0.2ms) SHOW TABLES
9193
+ SQL (0.1ms) SELECT version FROM schema_migrations
9194
+ Migrating to Counters (1)
9195
+ SQL (68.8ms) DROP TABLE `counters`
9196
+ SQL (0.6ms) DELETE FROM schema_migrations WHERE version = '1'
9197
+ SQL (0.2ms) SHOW TABLES
9198
+ SQL (0.1ms) SELECT version FROM schema_migrations
9199
+ SQL (0.2ms) SHOW TABLES
9200
+ SQL (0.1ms) SELECT version FROM schema_migrations
9201
+ Migrating to Counters (1)
9202
+ SQL (1.7ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9203
+ SQL (11.8ms) INSERT INTO schema_migrations (version) VALUES ('1')
9204
+ Counter Columns (1.2ms) SHOW FIELDS FROM `counters`
9205
+ SQL (0.8ms) BEGIN
9206
+ Counter Create (0.3ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9207
+ SQL (0.5ms) COMMIT
9208
+ SQL (0.4ms) SHOW TABLES
9209
+ SQL (1.1ms) SHOW FIELDS FROM `counters`
9210
+ SQL (1.8ms) SHOW FIELDS FROM `schema_migrations`
9211
+ SQL (0.6ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9212
+ FROM counters
9213
+ 
9214
+ SQL (0.8ms)  UPDATE counters
9215
+ SET counter_data = '---
9216
+ counter_last_day: 1
9217
+ counter_last_day_at: 2010-06-10 21:52:32.893979 Z
9218
+ counter_last_2_days_at: 2010-06-10 21:52:32.894024 Z
9219
+ counter_last_2_days: 1
9220
+ ', counter_last_day = 0, counter_last_2_days = 0
9221
+ WHERE id = 1
9222
+ 
9223
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9224
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9225
+ SQL (0.1ms) BEGIN
9226
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:52:32.893979 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:52:32.894024 Z\n', `counter` = 2 WHERE `id` = 1
9227
+ SQL (0.8ms) COMMIT
9228
+ SQL (0.0ms) SHOW TABLES
9229
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9230
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9231
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9232
+ FROM counters
9233
+ 
9234
+ SQL (0.0ms)  UPDATE counters
9235
+ SET counter_data = '---
9236
+ counter_last_day: 2
9237
+ counter_last_day_at: 2010-06-11 21:52:32.900301 Z
9238
+ counter_last_2_days_at: 2010-06-10 21:52:32.894024 Z
9239
+ counter_last_2_days: 1
9240
+ ', counter_last_day = 0, counter_last_2_days = 1
9241
+ WHERE id = 1
9242
+ 
9243
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9244
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9245
+ SQL (0.1ms) BEGIN
9246
+ Counter Update (0.4ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 2\ncounter_last_day_at: 2010-06-11 21:52:32.900301 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:52:32.894024 Z\n', `counter` = 3 WHERE `id` = 1
9247
+ SQL (0.6ms) COMMIT
9248
+ SQL (0.0ms) SHOW TABLES
9249
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9250
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9251
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9252
+ FROM counters
9253
+ 
9254
+ SQL (0.0ms)  UPDATE counters
9255
+ SET counter_data = '---
9256
+ counter_last_day: 3
9257
+ counter_last_day_at: &id001 2010-06-12 21:52:32.944040 Z
9258
+ counter_last_2_days_at: *id001
9259
+ counter_last_2_days: 3
9260
+ ', counter_last_day = 0, counter_last_2_days = 0
9261
+ WHERE id = 1
9262
+ 
9263
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9264
+ SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
9265
+ SQL (7.4ms) SHOW TABLES
9266
+ SQL (0.2ms) SELECT version FROM schema_migrations
9267
+ SQL (0.2ms) SHOW TABLES
9268
+ SQL (0.2ms) SELECT version FROM schema_migrations
9269
+ Migrating to Counters (1)
9270
+ SQL (0.2ms) SHOW TABLES
9271
+ SQL (0.1ms) SELECT version FROM schema_migrations
9272
+ SQL (0.2ms) SHOW TABLES
9273
+ SQL (0.1ms) SELECT version FROM schema_migrations
9274
+ Migrating to Counters (1)
9275
+ SQL (8.7ms) DROP TABLE `counters`
9276
+ SQL (0.6ms) DELETE FROM schema_migrations WHERE version = '1'
9277
+ SQL (0.2ms) SHOW TABLES
9278
+ SQL (0.1ms) SELECT version FROM schema_migrations
9279
+ SQL (0.2ms) SHOW TABLES
9280
+ SQL (0.1ms) SELECT version FROM schema_migrations
9281
+ Migrating to Counters (1)
9282
+ SQL (22.6ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9283
+ SQL (0.9ms) INSERT INTO schema_migrations (version) VALUES ('1')
9284
+ Counter Columns (1.5ms) SHOW FIELDS FROM `counters`
9285
+ SQL (0.1ms) BEGIN
9286
+ Counter Create (0.3ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9287
+ SQL (0.5ms) COMMIT
9288
+ SQL (0.3ms) SHOW TABLES
9289
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9290
+ SQL (1.5ms) SHOW FIELDS FROM `schema_migrations`
9291
+ SQL (0.2ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9292
+ FROM counters
9293
+ 
9294
+ SQL (11.8ms)  UPDATE counters
9295
+ SET counter_data = '---
9296
+ counter_last_day: 1
9297
+ counter_last_day_at: 2010-06-10 21:55:06.092149 Z
9298
+ counter_last_2_days_at: 2010-06-10 21:55:06.092195 Z
9299
+ counter_last_2_days: 1
9300
+ ', counter_last_day = 0, counter_last_2_days = 0
9301
+ WHERE id = 1
9302
+ 
9303
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9304
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9305
+ SQL (0.1ms) BEGIN
9306
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:06.092149 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:06.092195 Z\n', `counter` = 2 WHERE `id` = 1
9307
+ SQL (0.6ms) COMMIT
9308
+ SQL (0.3ms) SHOW TABLES
9309
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9310
+ SQL (1.7ms) SHOW FIELDS FROM `schema_migrations`
9311
+ SQL (1.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9312
+ FROM counters
9313
+ 
9314
+ SQL (0.9ms)  UPDATE counters
9315
+ SET counter_data = '---
9316
+ counter_last_day: 1
9317
+ counter_last_day_at: 2010-06-10 21:55:06.092149 Z
9318
+ counter_last_2_days_at: 2010-06-10 21:55:06.092195 Z
9319
+ counter_last_2_days: 1
9320
+ ', counter_last_day = 1, counter_last_2_days = 1
9321
+ WHERE id = 1
9322
+ 
9323
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9324
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9325
+ SQL (0.1ms) BEGIN
9326
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:06.092149 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:06.092195 Z\n' WHERE `id` = 1
9327
+ SQL (0.6ms) COMMIT
9328
+ SQL (0.0ms) SHOW TABLES
9329
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9330
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9331
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9332
+ FROM counters
9333
+ 
9334
+ SQL (0.0ms)  UPDATE counters
9335
+ SET counter_data = '---
9336
+ counter_last_day: 2
9337
+ counter_last_day_at: 2010-06-11 21:55:06.137782 Z
9338
+ counter_last_2_days_at: 2010-06-10 21:55:06.092195 Z
9339
+ counter_last_2_days: 1
9340
+ ', counter_last_day = 0, counter_last_2_days = 1
9341
+ WHERE id = 1
9342
+ 
9343
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9344
+ Counter Load (1.5ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9345
+ SQL (0.1ms) BEGIN
9346
+ Counter Update (1.0ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 2\ncounter_last_day_at: 2010-06-11 21:55:06.137782 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:06.092195 Z\n', `counter` = 3 WHERE `id` = 1
9347
+ SQL (0.6ms) COMMIT
9348
+ SQL (0.0ms) SHOW TABLES
9349
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9350
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9351
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9352
+ FROM counters
9353
+ 
9354
+ SQL (0.0ms)  UPDATE counters
9355
+ SET counter_data = '---
9356
+ counter_last_day: 3
9357
+ counter_last_day_at: &id001 2010-06-12 21:55:06.155953 Z
9358
+ counter_last_2_days_at: *id001
9359
+ counter_last_2_days: 3
9360
+ ', counter_last_day = 0, counter_last_2_days = 0
9361
+ WHERE id = 1
9362
+ 
9363
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9364
+ SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
9365
+ SQL (0.3ms) SHOW TABLES
9366
+ SQL (0.2ms) SELECT version FROM schema_migrations
9367
+ SQL (0.2ms) SHOW TABLES
9368
+ SQL (0.1ms) SELECT version FROM schema_migrations
9369
+ Migrating to Counters (1)
9370
+ SQL (0.2ms) SHOW TABLES
9371
+ SQL (0.1ms) SELECT version FROM schema_migrations
9372
+ SQL (0.2ms) SHOW TABLES
9373
+ SQL (0.1ms) SELECT version FROM schema_migrations
9374
+ Migrating to Counters (1)
9375
+ SQL (11.1ms) DROP TABLE `counters`
9376
+ SQL (2.2ms) DELETE FROM schema_migrations WHERE version = '1'
9377
+ SQL (5.2ms) SHOW TABLES
9378
+ SQL (0.2ms) SELECT version FROM schema_migrations
9379
+ SQL (0.2ms) SHOW TABLES
9380
+ SQL (10.0ms) SELECT version FROM schema_migrations
9381
+ Migrating to Counters (1)
9382
+ SQL (68.6ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9383
+ SQL (3.9ms) INSERT INTO schema_migrations (version) VALUES ('1')
9384
+ Counter Columns (14.0ms) SHOW FIELDS FROM `counters`
9385
+ SQL (8.3ms) BEGIN
9386
+ Counter Create (0.3ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9387
+ SQL (0.8ms) COMMIT
9388
+ SQL (0.3ms) SHOW TABLES
9389
+ SQL (1.8ms) SHOW FIELDS FROM `counters`
9390
+ SQL (9.3ms) SHOW FIELDS FROM `schema_migrations`
9391
+ SQL (2.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9392
+ FROM counters
9393
+ 
9394
+ SQL (2.3ms)  UPDATE counters
9395
+ SET counter_data = '---
9396
+ counter_last_day: 1
9397
+ counter_last_day_at: 2010-06-10 21:55:17.011146 Z
9398
+ counter_last_2_days_at: 2010-06-10 21:55:17.011192 Z
9399
+ counter_last_2_days: 1
9400
+ ', counter_last_day = 0, counter_last_2_days = 0
9401
+ WHERE id = 1
9402
+ 
9403
+ Counter Load (1.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9404
+ Counter Load (1.4ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9405
+ SQL (2.9ms) BEGIN
9406
+ Counter Update (0.4ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:17.011146 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:17.011192 Z\n', `counter` = 2 WHERE `id` = 1
9407
+ SQL (0.4ms) COMMIT
9408
+ SQL (0.2ms) SHOW TABLES
9409
+ SQL (1.0ms) SHOW FIELDS FROM `counters`
9410
+ SQL (4.9ms) SHOW FIELDS FROM `schema_migrations`
9411
+ SQL (0.2ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9412
+ FROM counters
9413
+ 
9414
+ SQL (2.8ms)  UPDATE counters
9415
+ SET counter_data = '---
9416
+ counter_last_day: 1
9417
+ counter_last_day_at: 2010-06-10 21:55:17.011146 Z
9418
+ counter_last_2_days_at: 2010-06-10 21:55:17.011192 Z
9419
+ counter_last_2_days: 1
9420
+ ', counter_last_day = 1, counter_last_2_days = 1
9421
+ WHERE id = 1
9422
+ 
9423
+ Counter Load (0.4ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9424
+ Counter Load (6.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9425
+ SQL (3.1ms) BEGIN
9426
+ Counter Update (0.7ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:17.011146 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:17.011192 Z\n' WHERE `id` = 1
9427
+ SQL (2.0ms) COMMIT
9428
+ SQL (0.0ms) SHOW TABLES
9429
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9430
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9431
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9432
+ FROM counters
9433
+ 
9434
+ SQL (0.0ms)  UPDATE counters
9435
+ SET counter_data = '---
9436
+ counter_last_day: 2
9437
+ counter_last_day_at: 2010-06-11 21:55:17.053983 Z
9438
+ counter_last_2_days_at: 2010-06-10 21:55:17.011192 Z
9439
+ counter_last_2_days: 1
9440
+ ', counter_last_day = 0, counter_last_2_days = 1
9441
+ WHERE id = 1
9442
+ 
9443
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9444
+ Counter Load (0.4ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9445
+ SQL (0.1ms) BEGIN
9446
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 2\ncounter_last_day_at: 2010-06-11 21:55:17.053983 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:17.011192 Z\n', `counter` = 3 WHERE `id` = 1
9447
+ SQL (9.8ms) COMMIT
9448
+ SQL (0.0ms) SHOW TABLES
9449
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9450
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9451
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9452
+ FROM counters
9453
+ 
9454
+ SQL (0.0ms)  UPDATE counters
9455
+ SET counter_data = '---
9456
+ counter_last_day: 3
9457
+ counter_last_day_at: &id001 2010-06-12 21:55:17.146939 Z
9458
+ counter_last_2_days_at: *id001
9459
+ counter_last_2_days: 3
9460
+ ', counter_last_day = 0, counter_last_2_days = 0
9461
+ WHERE id = 1
9462
+ 
9463
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9464
+ SQL (0.1ms) SET SQL_AUTO_IS_NULL=0
9465
+ SQL (0.3ms) SHOW TABLES
9466
+ SQL (0.2ms) SELECT version FROM schema_migrations
9467
+ SQL (0.2ms) SHOW TABLES
9468
+ SQL (0.2ms) SELECT version FROM schema_migrations
9469
+ Migrating to Counters (1)
9470
+ SQL (0.2ms) SHOW TABLES
9471
+ SQL (0.1ms) SELECT version FROM schema_migrations
9472
+ SQL (0.2ms) SHOW TABLES
9473
+ SQL (0.1ms) SELECT version FROM schema_migrations
9474
+ Migrating to Counters (1)
9475
+ SQL (1.6ms) DROP TABLE `counters`
9476
+ SQL (0.6ms) DELETE FROM schema_migrations WHERE version = '1'
9477
+ SQL (0.4ms) SHOW TABLES
9478
+ SQL (0.2ms) SELECT version FROM schema_migrations
9479
+ SQL (0.2ms) SHOW TABLES
9480
+ SQL (0.2ms) SELECT version FROM schema_migrations
9481
+ Migrating to Counters (1)
9482
+ SQL (30.6ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9483
+ SQL (0.6ms) INSERT INTO schema_migrations (version) VALUES ('1')
9484
+ Counter Columns (1.6ms) SHOW FIELDS FROM `counters`
9485
+ SQL (0.1ms) BEGIN
9486
+ Counter Create (0.3ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9487
+ SQL (0.5ms) COMMIT
9488
+ SQL (0.3ms) SHOW TABLES
9489
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9490
+ SQL (1.9ms) SHOW FIELDS FROM `schema_migrations`
9491
+ SQL (0.8ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9492
+ FROM counters
9493
+ 
9494
+ SQL (0.7ms)  UPDATE counters
9495
+ SET counter_data = '---
9496
+ counter_last_day: 1
9497
+ counter_last_day_at: 2010-06-10 21:55:50.869436 Z
9498
+ counter_last_2_days_at: 2010-06-10 21:55:50.869483 Z
9499
+ counter_last_2_days: 1
9500
+ ', counter_last_day = 0, counter_last_2_days = 0
9501
+ WHERE id = 1
9502
+ 
9503
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9504
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9505
+ SQL (0.2ms) BEGIN
9506
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:50.869436 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:50.869483 Z\n', `counter` = 2 WHERE `id` = 1
9507
+ SQL (0.5ms) COMMIT
9508
+ SQL (0.3ms) SHOW TABLES
9509
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9510
+ SQL (1.6ms) SHOW FIELDS FROM `schema_migrations`
9511
+ SQL (0.3ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9512
+ FROM counters
9513
+ 
9514
+ SQL (0.8ms)  UPDATE counters
9515
+ SET counter_data = '---
9516
+ counter_last_day: 1
9517
+ counter_last_day_at: 2010-06-10 21:55:50.869436 Z
9518
+ counter_last_2_days_at: 2010-06-10 21:55:50.869483 Z
9519
+ counter_last_2_days: 1
9520
+ ', counter_last_day = 1, counter_last_2_days = 1
9521
+ WHERE id = 1
9522
+ 
9523
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9524
+ Counter Load (0.6ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9525
+ SQL (0.1ms) BEGIN
9526
+ Counter Update (0.2ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:50.869436 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:50.869483 Z\n', `counter` = 3 WHERE `id` = 1
9527
+ SQL (0.5ms) COMMIT
9528
+ SQL (0.0ms) SHOW TABLES
9529
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9530
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9531
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9532
+ FROM counters
9533
+ 
9534
+ SQL (0.0ms)  UPDATE counters
9535
+ SET counter_data = '---
9536
+ counter_last_day: 3
9537
+ counter_last_day_at: 2010-06-11 21:55:50.887279 Z
9538
+ counter_last_2_days_at: 2010-06-10 21:55:50.869483 Z
9539
+ counter_last_2_days: 1
9540
+ ', counter_last_day = 0, counter_last_2_days = 2
9541
+ WHERE id = 1
9542
+ 
9543
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9544
+ Counter Load (0.4ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9545
+ SQL (0.3ms) BEGIN
9546
+ Counter Update (0.4ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 3\ncounter_last_day_at: 2010-06-11 21:55:50.887279 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:50.869483 Z\n' WHERE `id` = 1
9547
+ SQL (0.5ms) COMMIT
9548
+ SQL (0.0ms) SHOW TABLES
9549
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9550
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9551
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9552
+ FROM counters
9553
+ 
9554
+ SQL (0.0ms)  UPDATE counters
9555
+ SET counter_data = '---
9556
+ counter_last_day: 3
9557
+ counter_last_day_at: &id001 2010-06-12 21:55:50.919734 Z
9558
+ counter_last_2_days_at: *id001
9559
+ counter_last_2_days: 3
9560
+ ', counter_last_day = 0, counter_last_2_days = 0
9561
+ WHERE id = 1
9562
+ 
9563
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9564
+ SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
9565
+ SQL (0.3ms) SHOW TABLES
9566
+ SQL (0.2ms) SELECT version FROM schema_migrations
9567
+ SQL (0.2ms) SHOW TABLES
9568
+ SQL (0.1ms) SELECT version FROM schema_migrations
9569
+ Migrating to Counters (1)
9570
+ SQL (0.2ms) SHOW TABLES
9571
+ SQL (0.1ms) SELECT version FROM schema_migrations
9572
+ SQL (0.2ms) SHOW TABLES
9573
+ SQL (0.1ms) SELECT version FROM schema_migrations
9574
+ Migrating to Counters (1)
9575
+ SQL (13.5ms) DROP TABLE `counters`
9576
+ SQL (7.4ms) DELETE FROM schema_migrations WHERE version = '1'
9577
+ SQL (0.3ms) SHOW TABLES
9578
+ SQL (0.2ms) SELECT version FROM schema_migrations
9579
+ SQL (0.2ms) SHOW TABLES
9580
+ SQL (0.1ms) SELECT version FROM schema_migrations
9581
+ Migrating to Counters (1)
9582
+ SQL (11.0ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9583
+ SQL (5.5ms) INSERT INTO schema_migrations (version) VALUES ('1')
9584
+ Counter Columns (15.1ms) SHOW FIELDS FROM `counters`
9585
+ SQL (7.4ms) BEGIN
9586
+ Counter Create (13.7ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9587
+ SQL (5.7ms) COMMIT
9588
+ SQL (6.5ms) SHOW TABLES
9589
+ SQL (14.1ms) SHOW FIELDS FROM `counters`
9590
+ SQL (8.7ms) SHOW FIELDS FROM `schema_migrations`
9591
+ SQL (7.6ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9592
+ FROM counters
9593
+ 
9594
+ SQL (10.9ms)  UPDATE counters
9595
+ SET counter_data = '---
9596
+ counter_last_day: 1
9597
+ counter_last_day_at: 2010-06-10 21:55:59.386527 Z
9598
+ counter_last_2_days_at: 2010-06-10 21:55:59.386573 Z
9599
+ counter_last_2_days: 1
9600
+ ', counter_last_day = 0, counter_last_2_days = 0
9601
+ WHERE id = 1
9602
+ 
9603
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9604
+ Counter Load (0.4ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9605
+ SQL (0.1ms) BEGIN
9606
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:59.386527 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:59.386573 Z\n', `counter` = 2 WHERE `id` = 1
9607
+ SQL (6.5ms) COMMIT
9608
+ SQL (4.7ms) SHOW TABLES
9609
+ SQL (10.2ms) SHOW FIELDS FROM `counters`
9610
+ SQL (1.3ms) SHOW FIELDS FROM `schema_migrations`
9611
+ SQL (1.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9612
+ FROM counters
9613
+ 
9614
+ SQL (6.1ms)  UPDATE counters
9615
+ SET counter_data = '---
9616
+ counter_last_day: 1
9617
+ counter_last_day_at: 2010-06-10 21:55:59.386527 Z
9618
+ counter_last_2_days_at: 2010-06-10 21:55:59.386573 Z
9619
+ counter_last_2_days: 1
9620
+ ', counter_last_day = 1, counter_last_2_days = 1
9621
+ WHERE id = 1
9622
+ 
9623
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9624
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9625
+ SQL (0.8ms) BEGIN
9626
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 21:55:59.386527 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:59.386573 Z\n', `counter` = 3 WHERE `id` = 1
9627
+ SQL (2.3ms) COMMIT
9628
+ SQL (0.0ms) SHOW TABLES
9629
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9630
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9631
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9632
+ FROM counters
9633
+ 
9634
+ SQL (0.0ms)  UPDATE counters
9635
+ SET counter_data = '---
9636
+ counter_last_day: 3
9637
+ counter_last_day_at: 2010-06-11 21:55:59.446753 Z
9638
+ counter_last_2_days_at: 2010-06-10 21:55:59.386573 Z
9639
+ counter_last_2_days: 1
9640
+ ', counter_last_day = 0, counter_last_2_days = 2
9641
+ WHERE id = 1
9642
+ 
9643
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9644
+ Counter Load (5.6ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9645
+ SQL (2.2ms) BEGIN
9646
+ Counter Update (1.9ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 3\ncounter_last_day_at: 2010-06-11 21:55:59.446753 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 21:55:59.386573 Z\n' WHERE `id` = 1
9647
+ SQL (1.1ms) COMMIT
9648
+ SQL (0.0ms) SHOW TABLES
9649
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9650
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9651
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9652
+ FROM counters
9653
+ 
9654
+ SQL (0.0ms)  UPDATE counters
9655
+ SET counter_data = '---
9656
+ counter_last_day: 3
9657
+ counter_last_day_at: &id001 2010-06-12 21:55:59.491493 Z
9658
+ counter_last_2_days_at: *id001
9659
+ counter_last_2_days: 3
9660
+ ', counter_last_day = 0, counter_last_2_days = 0
9661
+ WHERE id = 1
9662
+ 
9663
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9664
+ SQL (0.1ms) SET SQL_AUTO_IS_NULL=0
9665
+ SQL (27.4ms) SHOW TABLES
9666
+ SQL (0.3ms) SELECT version FROM schema_migrations
9667
+ SQL (0.2ms) SHOW TABLES
9668
+ SQL (0.6ms) SELECT version FROM schema_migrations
9669
+ Migrating to Counters (1)
9670
+ SQL (0.2ms) SHOW TABLES
9671
+ SQL (0.7ms) SELECT version FROM schema_migrations
9672
+ SQL (0.2ms) SHOW TABLES
9673
+ SQL (0.2ms) SELECT version FROM schema_migrations
9674
+ Migrating to Counters (1)
9675
+ SQL (57.8ms) DROP TABLE `counters`
9676
+ SQL (29.7ms) DELETE FROM schema_migrations WHERE version = '1'
9677
+ SQL (0.3ms) SHOW TABLES
9678
+ SQL (0.2ms) SELECT version FROM schema_migrations
9679
+ SQL (0.2ms) SHOW TABLES
9680
+ SQL (0.1ms) SELECT version FROM schema_migrations
9681
+ Migrating to Counters (1)
9682
+ SQL (5.0ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9683
+ SQL (2.1ms) INSERT INTO schema_migrations (version) VALUES ('1')
9684
+ Counter Columns (1.5ms) SHOW FIELDS FROM `counters`
9685
+ SQL (0.1ms) BEGIN
9686
+ Counter Create (0.3ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9687
+ SQL (10.7ms) COMMIT
9688
+ SQL (0.3ms) SHOW TABLES
9689
+ SQL (15.3ms) SHOW FIELDS FROM `counters`
9690
+ SQL (199.7ms) SHOW FIELDS FROM `schema_migrations`
9691
+ SQL (9.4ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9692
+ FROM counters
9693
+ 
9694
+ SQL (33.6ms)  UPDATE counters
9695
+ SET counter_data = '---
9696
+ counter_last_day: 1
9697
+ counter_last_day_at: 2010-06-10 22:13:23.563986 Z
9698
+ counter_last_2_days_at: 2010-06-10 22:13:23.564031 Z
9699
+ counter_last_2_days: 1
9700
+ ', counter_last_day = 0, counter_last_2_days = 0
9701
+ WHERE id = 1
9702
+ 
9703
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9704
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9705
+ SQL (0.1ms) BEGIN
9706
+ Counter Update (0.4ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 22:13:23.563986 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:13:23.564031 Z\n', `counter` = 2 WHERE `id` = 1
9707
+ SQL (27.9ms) COMMIT
9708
+ SQL (0.3ms) SHOW TABLES
9709
+ SQL (21.0ms) SHOW FIELDS FROM `counters`
9710
+ SQL (101.3ms) SHOW FIELDS FROM `schema_migrations`
9711
+ SQL (2.1ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9712
+ FROM counters
9713
+ 
9714
+ SQL (8.9ms)  UPDATE counters
9715
+ SET counter_data = '---
9716
+ counter_last_day: 1
9717
+ counter_last_day_at: 2010-06-10 22:13:23.563986 Z
9718
+ counter_last_2_days_at: 2010-06-10 22:13:23.564031 Z
9719
+ counter_last_2_days: 1
9720
+ ', counter_last_day = 1, counter_last_2_days = 1
9721
+ WHERE id = 1
9722
+ 
9723
+ Counter Load (0.5ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9724
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9725
+ SQL (0.1ms) BEGIN
9726
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 22:13:23.563986 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:13:23.564031 Z\n', `counter` = 3 WHERE `id` = 1
9727
+ SQL (10.9ms) COMMIT
9728
+ SQL (0.0ms) SHOW TABLES
9729
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9730
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9731
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9732
+ FROM counters
9733
+ 
9734
+ SQL (0.0ms)  UPDATE counters
9735
+ SET counter_data = '---
9736
+ counter_last_day: 3
9737
+ counter_last_day_at: 2010-06-11 22:13:23.787982 Z
9738
+ counter_last_2_days_at: 2010-06-10 22:13:23.564031 Z
9739
+ counter_last_2_days: 1
9740
+ ', counter_last_day = 0, counter_last_2_days = 2
9741
+ WHERE id = 1
9742
+ 
9743
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9744
+ Counter Load (2.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9745
+ SQL (0.1ms) BEGIN
9746
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 3\ncounter_last_day_at: 2010-06-11 22:13:23.787982 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:13:23.564031 Z\n', `counter` = 4 WHERE `id` = 1
9747
+ SQL (11.5ms) COMMIT
9748
+ SQL (0.0ms) SHOW TABLES
9749
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9750
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9751
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9752
+ FROM counters
9753
+ 
9754
+ SQL (0.0ms)  UPDATE counters
9755
+ SET counter_data = '---
9756
+ counter_last_day: 4
9757
+ counter_last_day_at: &id001 2010-06-12 22:13:24.046356 Z
9758
+ counter_last_2_days_at: *id001
9759
+ counter_last_2_days: 4
9760
+ ', counter_last_day = 0, counter_last_2_days = 0
9761
+ WHERE id = 1
9762
+ 
9763
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9764
+ SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
9765
+ SQL (0.4ms) SHOW TABLES
9766
+ SQL (0.2ms) SELECT version FROM schema_migrations
9767
+ SQL (0.2ms) SHOW TABLES
9768
+ SQL (0.1ms) SELECT version FROM schema_migrations
9769
+ Migrating to Counters (1)
9770
+ SQL (0.2ms) SHOW TABLES
9771
+ SQL (0.1ms) SELECT version FROM schema_migrations
9772
+ SQL (0.2ms) SHOW TABLES
9773
+ SQL (0.1ms) SELECT version FROM schema_migrations
9774
+ Migrating to Counters (1)
9775
+ SQL (10.6ms) DROP TABLE `counters`
9776
+ SQL (1.4ms) DELETE FROM schema_migrations WHERE version = '1'
9777
+ SQL (0.3ms) SHOW TABLES
9778
+ SQL (0.2ms) SELECT version FROM schema_migrations
9779
+ SQL (0.2ms) SHOW TABLES
9780
+ SQL (0.2ms) SELECT version FROM schema_migrations
9781
+ Migrating to Counters (1)
9782
+ SQL (36.3ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9783
+ SQL (0.7ms) INSERT INTO schema_migrations (version) VALUES ('1')
9784
+ Counter Columns (1.9ms) SHOW FIELDS FROM `counters`
9785
+ SQL (0.1ms) BEGIN
9786
+ Counter Create (0.3ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9787
+ SQL (12.0ms) COMMIT
9788
+ SQL (0.3ms) SHOW TABLES
9789
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9790
+ SQL (1.5ms) SHOW FIELDS FROM `schema_migrations`
9791
+ SQL (0.3ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9792
+ FROM counters
9793
+ 
9794
+ SQL (0.6ms)  UPDATE counters
9795
+ SET counter_data = '---
9796
+ counter_last_day: 1
9797
+ counter_last_day_at: 2010-06-10 22:13:46.107266 Z
9798
+ counter_last_2_days_at: 2010-06-10 22:13:46.107311 Z
9799
+ counter_last_2_days: 1
9800
+ ', counter_last_day = 0, counter_last_2_days = 0
9801
+ WHERE id = 1
9802
+ 
9803
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9804
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9805
+ SQL (0.1ms) BEGIN
9806
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 22:13:46.107266 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:13:46.107311 Z\n', `counter` = 2 WHERE `id` = 1
9807
+ SQL (1.0ms) COMMIT
9808
+ SQL (0.4ms) SHOW TABLES
9809
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9810
+ SQL (1.5ms) SHOW FIELDS FROM `schema_migrations`
9811
+ SQL (0.6ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9812
+ FROM counters
9813
+ 
9814
+ SQL (0.6ms)  UPDATE counters
9815
+ SET counter_data = '---
9816
+ counter_last_day: 1
9817
+ counter_last_day_at: 2010-06-10 22:13:46.107266 Z
9818
+ counter_last_2_days_at: 2010-06-10 22:13:46.107311 Z
9819
+ counter_last_2_days: 1
9820
+ ', counter_last_day = 1, counter_last_2_days = 1
9821
+ WHERE id = 1
9822
+ 
9823
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9824
+ Counter Load (0.3ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9825
+ SQL (0.1ms) BEGIN
9826
+ Counter Update (0.2ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 22:13:46.107266 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:13:46.107311 Z\n', `counter` = 3 WHERE `id` = 1
9827
+ SQL (0.4ms) COMMIT
9828
+ SQL (0.0ms) SHOW TABLES
9829
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9830
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9831
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9832
+ FROM counters
9833
+ 
9834
+ SQL (0.0ms)  UPDATE counters
9835
+ SET counter_data = '---
9836
+ counter_last_day: 3
9837
+ counter_last_day_at: 2010-06-11 22:13:46.125411 Z
9838
+ counter_last_2_days_at: 2010-06-10 22:13:46.107311 Z
9839
+ counter_last_2_days: 1
9840
+ ', counter_last_day = 0, counter_last_2_days = 2
9841
+ WHERE id = 1
9842
+ 
9843
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9844
+ Counter Load (0.4ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9845
+ SQL (0.1ms) BEGIN
9846
+ Counter Update (0.3ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 3\ncounter_last_day_at: 2010-06-11 22:13:46.125411 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:13:46.107311 Z\n', `counter` = 4 WHERE `id` = 1
9847
+ SQL (0.7ms) COMMIT
9848
+ SQL (0.0ms) SHOW TABLES
9849
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9850
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9851
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9852
+ FROM counters
9853
+ 
9854
+ SQL (0.0ms)  UPDATE counters
9855
+ SET counter_data = '---
9856
+ counter_last_day: 4
9857
+ counter_last_day_at: &id001 2010-06-12 22:13:46.139238 Z
9858
+ counter_last_2_days_at: *id001
9859
+ counter_last_2_days: 4
9860
+ ', counter_last_day = 0, counter_last_2_days = 0
9861
+ WHERE id = 1
9862
+ 
9863
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9864
+ SQL (0.1ms) SET SQL_AUTO_IS_NULL=0
9865
+ SQL (0.3ms) SHOW TABLES
9866
+ SQL (0.2ms) SELECT version FROM schema_migrations
9867
+ SQL (0.2ms) SHOW TABLES
9868
+ SQL (0.1ms) SELECT version FROM schema_migrations
9869
+ Migrating to Counters (1)
9870
+ SQL (0.2ms) SHOW TABLES
9871
+ SQL (0.1ms) SELECT version FROM schema_migrations
9872
+ SQL (0.2ms) SHOW TABLES
9873
+ SQL (0.1ms) SELECT version FROM schema_migrations
9874
+ Migrating to Counters (1)
9875
+ SQL (1.5ms) DROP TABLE `counters`
9876
+ SQL (0.6ms) DELETE FROM schema_migrations WHERE version = '1'
9877
+ SQL (0.2ms) SHOW TABLES
9878
+ SQL (0.1ms) SELECT version FROM schema_migrations
9879
+ SQL (0.2ms) SHOW TABLES
9880
+ SQL (0.1ms) SELECT version FROM schema_migrations
9881
+ Migrating to Counters (1)
9882
+ SQL (75.2ms) CREATE TABLE `counters` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `counter` int(11), `counter_last_day` int(11), `counter_last_2_days` int(11), `counter_data` varchar(2048)) ENGINE=InnoDB
9883
+ SQL (0.6ms) INSERT INTO schema_migrations (version) VALUES ('1')
9884
+ Counter Columns (1.5ms) SHOW FIELDS FROM `counters`
9885
+ SQL (0.1ms) BEGIN
9886
+ Counter Create (0.3ms) INSERT INTO `counters` (`counter_data`, `counter_last_day`, `counter`, `counter_last_2_days`) VALUES(NULL, NULL, 1, NULL)
9887
+ SQL (0.4ms) COMMIT
9888
+ SQL (0.3ms) SHOW TABLES
9889
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9890
+ SQL (1.6ms) SHOW FIELDS FROM `schema_migrations`
9891
+ SQL (0.6ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9892
+ FROM counters
9893
+ 
9894
+ SQL (0.6ms)  UPDATE counters
9895
+ SET counter_data = '---
9896
+ counter_last_day: 1
9897
+ counter_last_day_at: 2010-06-10 22:18:56.274766 Z
9898
+ counter_last_2_days_at: 2010-06-10 22:18:56.274810 Z
9899
+ counter_last_2_days: 1
9900
+ ', counter_last_day = 0, counter_last_2_days = 0
9901
+ WHERE id = 1
9902
+ 
9903
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9904
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9905
+ SQL (0.1ms) BEGIN
9906
+ Counter Update (0.2ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 22:18:56.274766 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:18:56.274810 Z\n', `counter` = 2 WHERE `id` = 1
9907
+ SQL (10.8ms) COMMIT
9908
+ SQL (0.3ms) SHOW TABLES
9909
+ SQL (1.3ms) SHOW FIELDS FROM `counters`
9910
+ SQL (1.6ms) SHOW FIELDS FROM `schema_migrations`
9911
+ SQL (0.6ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9912
+ FROM counters
9913
+ 
9914
+ SQL (0.6ms)  UPDATE counters
9915
+ SET counter_data = '---
9916
+ counter_last_day: 1
9917
+ counter_last_day_at: 2010-06-10 22:18:56.274766 Z
9918
+ counter_last_2_days_at: 2010-06-10 22:18:56.274810 Z
9919
+ counter_last_2_days: 1
9920
+ ', counter_last_day = 1, counter_last_2_days = 1
9921
+ WHERE id = 1
9922
+ 
9923
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9924
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9925
+ SQL (0.1ms) BEGIN
9926
+ Counter Update (0.2ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 1\ncounter_last_day_at: 2010-06-10 22:18:56.274766 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:18:56.274810 Z\n', `counter` = 3 WHERE `id` = 1
9927
+ SQL (0.5ms) COMMIT
9928
+ SQL (0.0ms) SHOW TABLES
9929
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9930
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9931
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9932
+ FROM counters
9933
+ 
9934
+ SQL (0.0ms)  UPDATE counters
9935
+ SET counter_data = '---
9936
+ counter_last_day: 3
9937
+ counter_last_day_at: 2010-06-11 22:18:56.300401 Z
9938
+ counter_last_2_days_at: 2010-06-10 22:18:56.274810 Z
9939
+ counter_last_2_days: 1
9940
+ ', counter_last_day = 0, counter_last_2_days = 2
9941
+ WHERE id = 1
9942
+ 
9943
+ Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9944
+ Counter Load (0.2ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
9945
+ SQL (0.1ms) BEGIN
9946
+ Counter Update (0.2ms) UPDATE `counters` SET `counter_data` = '--- \ncounter_last_day: 3\ncounter_last_day_at: 2010-06-11 22:18:56.300401 Z\ncounter_last_2_days: 1\ncounter_last_2_days_at: 2010-06-10 22:18:56.274810 Z\n', `counter` = 4 WHERE `id` = 1
9947
+ SQL (1.2ms) COMMIT
9948
+ SQL (0.0ms) SHOW TABLES
9949
+ SQL (0.0ms) SHOW FIELDS FROM `counters`
9950
+ SQL (0.0ms) SHOW FIELDS FROM `schema_migrations`
9951
+ SQL (0.0ms)  SELECT id, counter, counter_data, counter_last_day, counter_last_2_days
9952
+ FROM counters
9953
+ 
9954
+ SQL (0.0ms)  UPDATE counters
9955
+ SET counter_data = '---
9956
+ counter_last_day: 4
9957
+ counter_last_day_at: &id001 2010-06-12 22:18:56.313985 Z
9958
+ counter_last_2_days_at: *id001
9959
+ counter_last_2_days: 4
9960
+ ', counter_last_day = 0, counter_last_2_days = 0
9961
+ WHERE id = 1
9182
9962
  
9183
9963
  Counter Load (0.0ms) SELECT * FROM `counters` ORDER BY counters.id DESC LIMIT 1
@@ -27,43 +27,62 @@ describe PeriodicCounter do
27
27
  }
28
28
  end
29
29
 
30
- it "should add to counter_last_day" do
30
+ it "should add to both counters on increment" do
31
31
  Counter.last.update_attribute :counter, 2
32
- stub_time(Time.now + 1.day)
33
32
  start
34
33
  attributes = Counter.last.attributes
35
34
  data = attributes.delete('counter_data')
36
35
  data.delete('counter_last_day_at').to_s.should == Time.now.utc.to_s
37
- data.delete('counter_last_2_days_at').to_s.should == (Time.now - 1.day).utc.to_s
36
+ data.delete('counter_last_2_days_at').to_s.should == Time.now.utc.to_s
38
37
  data.should == {
39
- "counter_last_day"=>2,
38
+ "counter_last_day"=>1,
40
39
  "counter_last_2_days"=>1
41
40
  }
42
41
  attributes.should == {
43
42
  "id"=>1,
44
43
  "counter"=>2,
45
44
  "counter_last_day"=>1,
46
- "counter_last_2_days"=>0
45
+ "counter_last_2_days"=>1
47
46
  }
48
47
  end
49
48
 
50
- it "should add to counter_last_2_days" do
49
+ it "should reset counter_last_day" do
51
50
  Counter.last.update_attribute :counter, 3
52
- stub_time(Time.now + 2.days)
51
+ stub_time(Time.now + 1.day)
53
52
  start
54
53
  attributes = Counter.last.attributes
55
54
  data = attributes.delete('counter_data')
56
55
  data.delete('counter_last_day_at').to_s.should == Time.now.utc.to_s
57
- data.delete('counter_last_2_days_at').to_s.should == Time.now.utc.to_s
56
+ data.delete('counter_last_2_days_at').to_s.should == (Time.now - 1.day).utc.to_s
58
57
  data.should == {
59
58
  "counter_last_day"=>3,
60
- "counter_last_2_days"=>3
59
+ "counter_last_2_days"=>1
61
60
  }
62
61
  attributes.should == {
63
62
  "id"=>1,
64
63
  "counter"=>3,
65
- "counter_last_day"=>1,
64
+ "counter_last_day"=>0,
66
65
  "counter_last_2_days"=>2
67
66
  }
68
67
  end
68
+
69
+ it "should reset counter_last_2_days" do
70
+ Counter.last.update_attribute :counter, 4
71
+ stub_time(Time.now + 2.days)
72
+ start
73
+ attributes = Counter.last.attributes
74
+ data = attributes.delete('counter_data')
75
+ data.delete('counter_last_day_at').to_s.should == Time.now.utc.to_s
76
+ data.delete('counter_last_2_days_at').to_s.should == Time.now.utc.to_s
77
+ data.should == {
78
+ "counter_last_day"=>4,
79
+ "counter_last_2_days"=>4
80
+ }
81
+ attributes.should == {
82
+ "id"=>1,
83
+ "counter"=>4,
84
+ "counter_last_day"=>0,
85
+ "counter_last_2_days"=>0
86
+ }
87
+ end
69
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: periodic_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh