caddie 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/caddie/crest_data_retriever.rb +10 -7
  3. data/app/models/caddie/crest_price_history_last_day_timestamp.rb +30 -0
  4. data/app/models/caddie/crest_price_history_update.rb +50 -25
  5. data/app/models/caddie/crest_price_history_update_log.rb +10 -0
  6. data/app/models/caddie/m_threaded_updater.rb +12 -10
  7. data/db/migrate/20160803094530_create_caddie_crest_price_history_last_day_timestamps.rb +12 -0
  8. data/lib/caddie/version.rb +1 -1
  9. data/lib/tasks/caddie_tasks.rake +4 -6
  10. data/{app → test/dummy/app}/models/crest_price_history.rb +0 -0
  11. data/test/dummy/app/models/eve_item.rb +5 -9
  12. data/test/dummy/db/migrate/20150815033941_add_epic_blueprint_to_eve_item.rb +5 -0
  13. data/test/dummy/db/migrate/20150916052729_add_market_group_ref_to_eve_item.rb +6 -0
  14. data/test/dummy/db/migrate/20160803143148_crest_price_history_index_rework_and_others.rb +17 -0
  15. data/test/dummy/db/schema.rb +25 -15
  16. data/test/factories/caddie/crest_price_history.rb +7 -0
  17. data/test/factories/caddie/crest_price_history_last_day_timestamp.rb +7 -0
  18. data/test/factories/caddie/crest_price_history_updates.rb +3 -0
  19. data/test/factories/caddie/eve_items.rb +1 -39
  20. data/test/factories/caddie/regions.rb +4 -27
  21. data/test/models/caddie/crest_data_retriever_test.rb +36 -0
  22. data/test/models/caddie/crest_price_history_last_day_timestamp_test.rb +102 -0
  23. data/test/models/caddie/crest_price_history_update_log_test.rb +15 -3
  24. data/test/models/caddie/crest_price_history_update_test.rb +31 -9
  25. data/test/models/caddie/m_threaded_updater_test.rb +13 -25
  26. data/test/test_helper.rb +7 -2
  27. metadata +64 -66
  28. data/lib/tasks/m_threaded_updater_test.no_rake +0 -53
  29. data/test/dummy/log/development.log +0 -637
  30. data/test/dummy/log/test.log +0 -46048
@@ -1,637 +0,0 @@
1
-  (15.0ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2
-  (1.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
- ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
- Migrating to CreateEveItems (20150410082132)
5
-  (0.3ms) BEGIN
6
- DEPRECATION WARNING: `#timestamps` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /mnt/hdd1/ced/ruby/caddie/test/dummy/db/migrate/20150410082132_create_eve_items.rb:7)
7
-  (14.6ms) CREATE TABLE "eve_items" ("id" serial primary key, "eve_item_id" integer, "name" character varying, "created_at" timestamp, "updated_at" timestamp) 
8
-  (1.5ms) CREATE INDEX "index_eve_items_on_eve_item_id" ON "eve_items" ("eve_item_id")
9
- SQL (1.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150410082132"]]
10
-  (0.8ms) COMMIT
11
- Migrating to AddNameLowcaseToEveItem (20150414095303)
12
-  (0.5ms) BEGIN
13
-  (0.5ms) ALTER TABLE "eve_items" ADD "name_lowcase" character varying
14
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150414095303"]]
15
-  (1.1ms) COMMIT
16
- Migrating to RenameEveItemId (20150416154256)
17
-  (0.3ms) BEGIN
18
-  (0.4ms) ALTER TABLE "eve_items" RENAME COLUMN "eve_item_id" TO "cpp_eve_item_id"
19
-  (0.3ms) ALTER INDEX "index_eve_items_on_eve_item_id" RENAME TO "index_eve_items_on_cpp_eve_item_id"
20
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150416154256"]]
21
-  (0.6ms) COMMIT
22
- Migrating to AddCostToEveItem (20150417135716)
23
-  (0.2ms) BEGIN
24
-  (1.2ms) ALTER TABLE "eve_items" ADD "cost" float
25
- SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150417135716"]]
26
-  (1.0ms) COMMIT
27
- Migrating to AddCppMarketGroupIdToEveItem (20150906171550)
28
-  (0.4ms) BEGIN
29
-  (0.4ms) ALTER TABLE "eve_items" ADD "cpp_market_group_id" integer
30
-  (1.6ms) CREATE INDEX "index_eve_items_on_cpp_market_group_id" ON "eve_items" ("cpp_market_group_id")
31
- SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150906171550"]]
32
-  (1.8ms) COMMIT
33
- Migrating to AddInvolvedInBlueprintToEveItem (20150909162142)
34
-  (0.3ms) BEGIN
35
-  (11.1ms) ALTER TABLE "eve_items" ADD "involved_in_blueprint" bool DEFAULT 'f'
36
- SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150909162142"]]
37
-  (1.8ms) COMMIT
38
- Migrating to CreateRegions (20150910074544)
39
-  (0.2ms) BEGIN
40
-  (7.4ms) CREATE TABLE "regions" ("id" serial primary key, "cpp_region_id" character varying NOT NULL, "name" character varying NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
41
-  (3.5ms) CREATE UNIQUE INDEX "index_regions_on_cpp_region_id" ON "regions" ("cpp_region_id")
42
- SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150910074544"]]
43
-  (0.9ms) COMMIT
44
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
45
-  (4.8ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
46
- FROM pg_constraint c
47
- JOIN pg_class t1 ON c.conrelid = t1.oid
48
- JOIN pg_class t2 ON c.confrelid = t2.oid
49
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
50
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
51
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
52
- WHERE c.contype = 'f'
53
- AND t1.relname = 'eve_items'
54
- AND t3.nspname = ANY (current_schemas(false))
55
- ORDER BY c.conname
56
- 
57
-  (1.8ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
58
- FROM pg_constraint c
59
- JOIN pg_class t1 ON c.conrelid = t1.oid
60
- JOIN pg_class t2 ON c.confrelid = t2.oid
61
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
62
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
63
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
64
- WHERE c.contype = 'f'
65
- AND t1.relname = 'regions'
66
- AND t3.nspname = ANY (current_schemas(false))
67
- ORDER BY c.conname
68
-
69
- ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
70
- Migrating to CreateCaddieCrestPriceHistoryUpdates (20160524122651)
71
-  (0.2ms) BEGIN
72
-  (6.9ms) CREATE TABLE "caddie_crest_price_history_updates" ("id" serial primary key, "eve_item_id" integer, "region_id" integer, "max_update" date, "max_eve_item_create" date, "max_region_create" date, "max_date" date, "nb_days" integer, "process_queue" character varying, "process_queue_priority" integer, "next_process_date" date, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
73
-  (5.9ms) ALTER TABLE "caddie_crest_price_history_updates" ADD CONSTRAINT "fk_rails_30a37401e2"
74
- FOREIGN KEY ("eve_item_id")
75
- REFERENCES "eve_items" ("id")
76
-
77
-  (2.9ms) ALTER TABLE "caddie_crest_price_history_updates" ADD CONSTRAINT "fk_rails_ee255dc7cc"
78
- FOREIGN KEY ("region_id")
79
- REFERENCES "regions" ("id")
80
- 
81
-  (1.6ms) CREATE UNIQUE INDEX "index_caddie_cphu_on_eve_item_id_and_region_id" ON "caddie_crest_price_history_updates" ("eve_item_id", "region_id")
82
- SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160524122651"]]
83
-  (23.8ms) COMMIT
84
- Migrating to AddThreadSliceIdToCaddieCrestPriceHistoryUpdates (20160527152027)
85
-  (0.4ms) BEGIN
86
-  (0.5ms) ALTER TABLE "caddie_crest_price_history_updates" ADD "thread_slice_id" integer
87
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160527152027"]]
88
-  (0.6ms) COMMIT
89
- Migrating to CreateCaddieCrestPriceHistoryUpdateLogs (20160707153021)
90
-  (0.3ms) BEGIN
91
-  (4.7ms) CREATE TABLE "caddie_crest_price_history_update_logs" ("id" serial primary key, "feed_date" date, "update_planning_time" integer, "feeding_time" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
92
-  (3.7ms) CREATE UNIQUE INDEX "index_caddie_crest_price_history_update_logs_on_feed_date" ON "caddie_crest_price_history_update_logs" ("feed_date")
93
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160707153021"]]
94
-  (0.6ms) COMMIT
95
- Migrating to AddTotalInsertsToCrestPriceHistoryUpdateLog (20160710163612)
96
-  (0.2ms) BEGIN
97
-  (0.4ms) ALTER TABLE "caddie_crest_price_history_update_logs" ADD "total_inserts" integer
98
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160710163612"]]
99
-  (0.5ms) COMMIT
100
- Migrating to AddCoSecondsToCrestPriceHistoryUpdateLog (20160710163641)
101
-  (0.3ms) BEGIN
102
-  (0.5ms) ALTER TABLE "caddie_crest_price_history_update_logs" ADD "co_seconds" float
103
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160710163641"]]
104
-  (0.4ms) COMMIT
105
- Migrating to AddIndexesToCrestPriceHistoryUpdate (20160725091214)
106
-  (0.2ms) BEGIN
107
-  (3.3ms) CREATE INDEX "index_caddie_crest_price_history_updates_on_nb_days" ON "caddie_crest_price_history_updates" ("nb_days")
108
-  (2.5ms) CREATE INDEX "index_caddie_crest_price_history_updates_on_process_queue" ON "caddie_crest_price_history_updates" ("process_queue")
109
-  (2.7ms) CREATE INDEX "index_caddie_crest_price_history_updates_on_next_process_date" ON "caddie_crest_price_history_updates" ("next_process_date")
110
-  (1.4ms) CREATE INDEX "index_caddie_crest_price_history_updates_on_thread_slice_id" ON "caddie_crest_price_history_updates" ("thread_slice_id")
111
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160725091214"]]
112
-  (0.5ms) COMMIT
113
- ActiveRecord::SchemaMigration Load (0.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
114
-  (2.7ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
115
- FROM pg_constraint c
116
- JOIN pg_class t1 ON c.conrelid = t1.oid
117
- JOIN pg_class t2 ON c.confrelid = t2.oid
118
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
119
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
120
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
121
- WHERE c.contype = 'f'
122
- AND t1.relname = 'caddie_crest_price_history_update_logs'
123
- AND t3.nspname = ANY (current_schemas(false))
124
- ORDER BY c.conname
125
-
126
-  (2.7ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
127
- FROM pg_constraint c
128
- JOIN pg_class t1 ON c.conrelid = t1.oid
129
- JOIN pg_class t2 ON c.confrelid = t2.oid
130
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
131
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
132
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
133
- WHERE c.contype = 'f'
134
- AND t1.relname = 'caddie_crest_price_history_updates'
135
- AND t3.nspname = ANY (current_schemas(false))
136
- ORDER BY c.conname
137
- 
138
-  (2.7ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
139
- FROM pg_constraint c
140
- JOIN pg_class t1 ON c.conrelid = t1.oid
141
- JOIN pg_class t2 ON c.confrelid = t2.oid
142
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
143
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
144
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
145
- WHERE c.contype = 'f'
146
- AND t1.relname = 'eve_items'
147
- AND t3.nspname = ANY (current_schemas(false))
148
- ORDER BY c.conname
149
-
150
-  (2.8ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
151
- FROM pg_constraint c
152
- JOIN pg_class t1 ON c.conrelid = t1.oid
153
- JOIN pg_class t2 ON c.confrelid = t2.oid
154
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
155
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
156
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
157
- WHERE c.contype = 'f'
158
- AND t1.relname = 'regions'
159
- AND t3.nspname = ANY (current_schemas(false))
160
- ORDER BY c.conname
161
- 
162
-  (4.3ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
163
-  (0.7ms) BEGIN
164
- SQL (1.2ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
165
- SQL (1.1ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
166
- SQL (1.0ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
167
- SQL (1.0ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 4 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
168
-  (0.5ms) COMMIT
169
-  (1.1ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
170
-  (1.6ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
171
-  (3.2ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
172
- Caddie::CrestPriceHistoryUpdate Load (1.2ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
173
-  (0.6ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 2]]
174
-  (2.1ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
175
-  (1.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"], ["thread_slice_id", 2]]
176
-  (1.0ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
177
- Caddie::CrestPriceHistoryUpdate Load (0.3ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
178
-  (0.4ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 4]]
179
-  (1.8ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"], ["thread_slice_id", 4]]
180
-  (0.6ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
181
-  (0.4ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
182
- Caddie::CrestPriceHistoryUpdate Load (0.6ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
183
-  (0.7ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 1]]
184
-  (0.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"], ["thread_slice_id", 1]]
185
-  (0.9ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
186
-  (0.6ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
187
- Caddie::CrestPriceHistoryUpdate Load (0.7ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
188
-  (0.5ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 3]]
189
-  (1.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"], ["thread_slice_id", 3]]
190
-  (0.4ms) BEGIN
191
- SQL (4.6ms) INSERT INTO "regions" ("cpp_region_id", "name", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["cpp_region_id", "1232456"], ["name", "Toto"], ["created_at", "2016-07-25 15:01:38.457392"], ["updated_at", "2016-07-25 15:01:38.457392"]]
192
-  (1.1ms) COMMIT
193
-  (0.5ms) BEGIN
194
- SQL (3.4ms) INSERT INTO "eve_items" ("cpp_eve_item_id", "name", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["cpp_eve_item_id", 1232456], ["name", "Toto"], ["created_at", "2016-07-25 15:02:05.378860"], ["updated_at", "2016-07-25 15:02:05.378860"]]
195
-  (0.9ms) COMMIT
196
- Region Load (1.0ms) SELECT "regions".* FROM "regions" ORDER BY "regions"."id" ASC LIMIT 1
197
- EveItem Load (0.8ms) SELECT "eve_items".* FROM "eve_items" ORDER BY "eve_items"."id" ASC LIMIT 1
198
-  (0.4ms) BEGIN
199
- SQL (4.4ms) INSERT INTO "caddie_crest_price_history_updates" ("region_id", "eve_item_id", "next_process_date", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["region_id", 1], ["eve_item_id", 1], ["next_process_date", "2016-07-25"], ["created_at", "2016-07-25 15:03:04.293591"], ["updated_at", "2016-07-25 15:03:04.293591"]]
200
-  (0.7ms) COMMIT
201
-  (13.4ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
202
-  (0.1ms) BEGIN
203
- SQL (0.8ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."id" = 1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
204
- SQL (0.6ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
205
- SQL (0.5ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
206
- SQL (0.5ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 4 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
207
-  (4.9ms) COMMIT
208
-  (0.5ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
209
-  (0.3ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
210
-  (0.4ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
211
-  (3.2ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
212
- Caddie::CrestPriceHistoryUpdate Load (0.3ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
213
-  (1.5ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
214
-  (1.3ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
215
- Caddie::CrestPriceHistoryUpdate Load (0.5ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
216
-  (2.7ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
217
-  (2.1ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
218
-  (0.4ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
219
- Caddie::CrestPriceHistoryUpdate Load (1.4ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
220
- Caddie::CrestPriceHistoryUpdate Load (0.9ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
221
-  (0.6ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 2]]
222
-  (1.1ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"], ["thread_slice_id", 2]]
223
-  (1.0ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 4]]
224
-  (0.6ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 1]]
225
-  (1.2ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"], ["thread_slice_id", 1]]
226
-  (0.2ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 3]]
227
-  (0.9ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
228
-  (0.2ms) BEGIN
229
- SQL (1.0ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."id" = 1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
230
- SQL (0.5ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
231
- SQL (0.5ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
232
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 4 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-25"]]
233
-  (2.0ms) COMMIT
234
-  (0.4ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
235
-  (0.8ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
236
-  (0.5ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
237
- Caddie::CrestPriceHistoryUpdate Load (0.5ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
238
-  (0.5ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 [["next_process_date", "2016-07-25"], ["thread_slice_id", 1]]
239
-  (15.0ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
240
-  (0.7ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
241
- Caddie::CrestPriceHistoryUpdate Load (1.3ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"]]
242
-  (2.0ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-25"], ["thread_slice_id", 1]]
243
-  (2.6ms) SELECT COUNT(*) FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 [["next_process_date", "2016-07-25"]]
244
- ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
245
- Migrating to CreateCrestPriceHistories (20150910080646)
246
-  (0.3ms) BEGIN
247
-  (6.4ms) CREATE TABLE "crest_price_histories" ("id" serial primary key, "region_id" integer NOT NULL, "eve_item_id" integer NOT NULL, "day_timestamp" character varying NOT NULL, "history_date" timestamp NOT NULL, "order_count" bigint, "volume" bigint, "low_price" float, "avg_price" float, "high_price" float, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
248
-  (1.8ms) CREATE INDEX "index_crest_price_histories_on_region_id" ON "crest_price_histories" ("region_id")
249
-  (2.3ms) CREATE INDEX "index_crest_price_histories_on_eve_item_id" ON "crest_price_histories" ("eve_item_id")
250
-  (1.9ms) CREATE INDEX "index_crest_price_histories_on_day_timestamp" ON "crest_price_histories" ("day_timestamp")
251
-  (1.3ms) ALTER TABLE "crest_price_histories" ADD CONSTRAINT "fk_rails_35305feae4"
252
- FOREIGN KEY ("region_id")
253
- REFERENCES "regions" ("id")
254
- 
255
-  (1.0ms) ALTER TABLE "crest_price_histories" ADD CONSTRAINT "fk_rails_cc2b7d19d3"
256
- FOREIGN KEY ("eve_item_id")
257
- REFERENCES "eve_items" ("id")
258
-
259
-  (2.7ms) CREATE UNIQUE INDEX "price_histories_all_keys_index" ON "crest_price_histories" ("region_id", "eve_item_id", "day_timestamp")
260
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150910080646"]]
261
-  (1.2ms) COMMIT
262
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
263
-  (2.3ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
264
- FROM pg_constraint c
265
- JOIN pg_class t1 ON c.conrelid = t1.oid
266
- JOIN pg_class t2 ON c.confrelid = t2.oid
267
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
268
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
269
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
270
- WHERE c.contype = 'f'
271
- AND t1.relname = 'caddie_crest_price_history_update_logs'
272
- AND t3.nspname = ANY (current_schemas(false))
273
- ORDER BY c.conname
274
- 
275
-  (3.3ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
276
- FROM pg_constraint c
277
- JOIN pg_class t1 ON c.conrelid = t1.oid
278
- JOIN pg_class t2 ON c.confrelid = t2.oid
279
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
280
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
281
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
282
- WHERE c.contype = 'f'
283
- AND t1.relname = 'caddie_crest_price_history_updates'
284
- AND t3.nspname = ANY (current_schemas(false))
285
- ORDER BY c.conname
286
-
287
-  (4.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
288
- FROM pg_constraint c
289
- JOIN pg_class t1 ON c.conrelid = t1.oid
290
- JOIN pg_class t2 ON c.confrelid = t2.oid
291
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
292
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
293
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
294
- WHERE c.contype = 'f'
295
- AND t1.relname = 'crest_price_histories'
296
- AND t3.nspname = ANY (current_schemas(false))
297
- ORDER BY c.conname
298
- 
299
-  (2.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
300
- FROM pg_constraint c
301
- JOIN pg_class t1 ON c.conrelid = t1.oid
302
- JOIN pg_class t2 ON c.confrelid = t2.oid
303
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
304
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
305
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
306
- WHERE c.contype = 'f'
307
- AND t1.relname = 'eve_items'
308
- AND t3.nspname = ANY (current_schemas(false))
309
- ORDER BY c.conname
310
-
311
-  (2.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
312
- FROM pg_constraint c
313
- JOIN pg_class t1 ON c.conrelid = t1.oid
314
- JOIN pg_class t2 ON c.confrelid = t2.oid
315
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
316
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
317
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
318
- WHERE c.contype = 'f'
319
- AND t1.relname = 'regions'
320
- AND t3.nspname = ANY (current_schemas(false))
321
- ORDER BY c.conname
322
- 
323
-  (21.3ms) /* Don't forget to set the postgres sequence to cycle on production */
324
- /* ALTER SEQUENCE caddie_crest_price_history_updates_id_seq CYCLE; */
325
-
326
- /* TRUNCATE TABLE caddie_crest_price_history_updates; */
327
-
328
- /* Insert new regions / items */
329
- INSERT INTO caddie_crest_price_history_updates( eve_item_id, region_id, created_at, updated_at )
330
- SELECT eve_items.id, regions.id, now(), now()
331
- FROM eve_items, regions
332
- WHERE NOT EXISTS ( SELECT NULL FROM caddie_crest_price_history_updates WHERE eve_item_id = eve_items.id and region_id = regions.id );
333
-
334
- /* Update all datas */
335
- UPDATE caddie_crest_price_history_updates cphu
336
- SET max_update = sub.mua, max_eve_item_create = sub.max_eve_item_create, max_region_create = sub.max_region_create
337
- FROM (
338
- SELECT DISTINCT eve_item_id, region_id, MAX( crest_price_histories.updated_at ) mua, MAX( eve_items.created_at ) max_eve_item_create, MAX( regions.created_at ) max_region_create
339
- FROM crest_price_histories, eve_items, regions
340
- WHERE eve_item_id = eve_items.id
341
- AND region_id = regions.id
342
- GROUP BY eve_item_id, region_id
343
- ) sub
344
- WHERE cphu.eve_item_id = sub.eve_item_id
345
- AND cphu.region_id = sub.region_id;
346
-
347
- UPDATE caddie_crest_price_history_updates cphu SET max_date = GREATEST( max_update, max_eve_item_create, max_region_create );
348
-
349
- UPDATE caddie_crest_price_history_updates cphu SET nb_days = ( CURRENT_DATE - max_date );
350
-
351
- UPDATE caddie_crest_price_history_updates cphu
352
- SET process_queue = 'DAILY', next_process_date = current_date, process_queue_priority = 1, updated_at = localtimestamp
353
- WHERE nb_days <= 7;
354
-
355
- UPDATE caddie_crest_price_history_updates cphu
356
- SET process_queue = 'WEEKLY', next_process_date = date_trunc( 'week', ( current_date + ( interval '1 week' ) ) ), process_queue_priority = 2, updated_at = localtimestamp
357
- WHERE nb_days <= 30 AND nb_days > 7;
358
-
359
- UPDATE caddie_crest_price_history_updates cphu
360
- SET process_queue = 'MONTHLY', next_process_date = date_trunc( 'month', ( current_date + ( interval '1 month' ) ) ), process_queue_priority = 3, updated_at = localtimestamp
361
- WHERE nb_days > 30 OR nb_days IS NULL;
362
-
363
- 
364
-  (0.5ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"]]
365
-  (0.2ms) BEGIN
366
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 0 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
367
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
368
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
369
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
370
-  (0.3ms) COMMIT
371
-  (4.5ms) /* Don't forget to set the postgres sequence to cycle on production */
372
- /* ALTER SEQUENCE caddie_crest_price_history_updates_id_seq CYCLE; */
373
-
374
- /* TRUNCATE TABLE caddie_crest_price_history_updates; */
375
-
376
- /* Insert new regions / items */
377
- INSERT INTO caddie_crest_price_history_updates( eve_item_id, region_id, created_at, updated_at )
378
- SELECT eve_items.id, regions.id, now(), now()
379
- FROM eve_items, regions
380
- WHERE NOT EXISTS ( SELECT NULL FROM caddie_crest_price_history_updates WHERE eve_item_id = eve_items.id and region_id = regions.id );
381
-
382
- /* Update all datas */
383
- UPDATE caddie_crest_price_history_updates cphu
384
- SET max_update = sub.mua, max_eve_item_create = sub.max_eve_item_create, max_region_create = sub.max_region_create
385
- FROM (
386
- SELECT DISTINCT eve_item_id, region_id, MAX( crest_price_histories.updated_at ) mua, MAX( eve_items.created_at ) max_eve_item_create, MAX( regions.created_at ) max_region_create
387
- FROM crest_price_histories, eve_items, regions
388
- WHERE eve_item_id = eve_items.id
389
- AND region_id = regions.id
390
- GROUP BY eve_item_id, region_id
391
- ) sub
392
- WHERE cphu.eve_item_id = sub.eve_item_id
393
- AND cphu.region_id = sub.region_id;
394
-
395
- UPDATE caddie_crest_price_history_updates cphu SET max_date = GREATEST( max_update, max_eve_item_create, max_region_create );
396
-
397
- UPDATE caddie_crest_price_history_updates cphu SET nb_days = ( CURRENT_DATE - max_date );
398
-
399
- UPDATE caddie_crest_price_history_updates cphu
400
- SET process_queue = 'DAILY', next_process_date = current_date, process_queue_priority = 1, updated_at = localtimestamp
401
- WHERE nb_days <= 7;
402
-
403
- UPDATE caddie_crest_price_history_updates cphu
404
- SET process_queue = 'WEEKLY', next_process_date = date_trunc( 'week', ( current_date + ( interval '1 week' ) ) ), process_queue_priority = 2, updated_at = localtimestamp
405
- WHERE nb_days <= 30 AND nb_days > 7;
406
-
407
- UPDATE caddie_crest_price_history_updates cphu
408
- SET process_queue = 'MONTHLY', next_process_date = date_trunc( 'month', ( current_date + ( interval '1 month' ) ) ), process_queue_priority = 3, updated_at = localtimestamp
409
- WHERE nb_days > 30 OR nb_days IS NULL;
410
-
411
- 
412
-  (0.6ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"]]
413
-  (0.2ms) BEGIN
414
- SQL (0.6ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 0 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
415
- SQL (0.6ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
416
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
417
- SQL (0.5ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
418
-  (0.2ms) COMMIT
419
-  (1.4ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 2]]
420
-  (1.1ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 1]]
421
-  (1.7ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 0]]
422
-  (1.0ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 3]]
423
-  (3.7ms) /* Don't forget to set the postgres sequence to cycle on production */
424
- /* ALTER SEQUENCE caddie_crest_price_history_updates_id_seq CYCLE; */
425
-
426
- /* TRUNCATE TABLE caddie_crest_price_history_updates; */
427
-
428
- /* Insert new regions / items */
429
- INSERT INTO caddie_crest_price_history_updates( eve_item_id, region_id, created_at, updated_at )
430
- SELECT eve_items.id, regions.id, now(), now()
431
- FROM eve_items, regions
432
- WHERE NOT EXISTS ( SELECT NULL FROM caddie_crest_price_history_updates WHERE eve_item_id = eve_items.id and region_id = regions.id );
433
-
434
- /* Update all datas */
435
- UPDATE caddie_crest_price_history_updates cphu
436
- SET max_update = sub.mua, max_eve_item_create = sub.max_eve_item_create, max_region_create = sub.max_region_create
437
- FROM (
438
- SELECT DISTINCT eve_item_id, region_id, MAX( crest_price_histories.updated_at ) mua, MAX( eve_items.created_at ) max_eve_item_create, MAX( regions.created_at ) max_region_create
439
- FROM crest_price_histories, eve_items, regions
440
- WHERE eve_item_id = eve_items.id
441
- AND region_id = regions.id
442
- GROUP BY eve_item_id, region_id
443
- ) sub
444
- WHERE cphu.eve_item_id = sub.eve_item_id
445
- AND cphu.region_id = sub.region_id;
446
-
447
- UPDATE caddie_crest_price_history_updates cphu SET max_date = GREATEST( max_update, max_eve_item_create, max_region_create );
448
-
449
- UPDATE caddie_crest_price_history_updates cphu SET nb_days = ( CURRENT_DATE - max_date );
450
-
451
- UPDATE caddie_crest_price_history_updates cphu
452
- SET process_queue = 'DAILY', next_process_date = current_date, process_queue_priority = 1, updated_at = localtimestamp
453
- WHERE nb_days <= 7;
454
-
455
- UPDATE caddie_crest_price_history_updates cphu
456
- SET process_queue = 'WEEKLY', next_process_date = date_trunc( 'week', ( current_date + ( interval '1 week' ) ) ), process_queue_priority = 2, updated_at = localtimestamp
457
- WHERE nb_days <= 30 AND nb_days > 7;
458
-
459
- UPDATE caddie_crest_price_history_updates cphu
460
- SET process_queue = 'MONTHLY', next_process_date = date_trunc( 'month', ( current_date + ( interval '1 month' ) ) ), process_queue_priority = 3, updated_at = localtimestamp
461
- WHERE nb_days > 30 OR nb_days IS NULL;
462
-
463
- 
464
-  (0.3ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"]]
465
-  (0.2ms) BEGIN
466
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 0 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
467
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
468
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
469
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
470
-  (0.2ms) COMMIT
471
-  (1.7ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 0]]
472
-  (0.7ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 1]]
473
-  (0.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 2]]
474
-  (0.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 3]]
475
-  (6.7ms) /* Don't forget to set the postgres sequence to cycle on production */
476
- /* ALTER SEQUENCE caddie_crest_price_history_updates_id_seq CYCLE; */
477
-
478
- /* TRUNCATE TABLE caddie_crest_price_history_updates; */
479
-
480
- /* Insert new regions / items */
481
- INSERT INTO caddie_crest_price_history_updates( eve_item_id, region_id, created_at, updated_at )
482
- SELECT eve_items.id, regions.id, now(), now()
483
- FROM eve_items, regions
484
- WHERE NOT EXISTS ( SELECT NULL FROM caddie_crest_price_history_updates WHERE eve_item_id = eve_items.id and region_id = regions.id );
485
-
486
- /* Update all datas */
487
- UPDATE caddie_crest_price_history_updates cphu
488
- SET max_update = sub.mua, max_eve_item_create = sub.max_eve_item_create, max_region_create = sub.max_region_create
489
- FROM (
490
- SELECT DISTINCT eve_item_id, region_id, MAX( crest_price_histories.updated_at ) mua, MAX( eve_items.created_at ) max_eve_item_create, MAX( regions.created_at ) max_region_create
491
- FROM crest_price_histories, eve_items, regions
492
- WHERE eve_item_id = eve_items.id
493
- AND region_id = regions.id
494
- GROUP BY eve_item_id, region_id
495
- ) sub
496
- WHERE cphu.eve_item_id = sub.eve_item_id
497
- AND cphu.region_id = sub.region_id;
498
-
499
- UPDATE caddie_crest_price_history_updates cphu SET max_date = GREATEST( max_update, max_eve_item_create, max_region_create );
500
-
501
- UPDATE caddie_crest_price_history_updates cphu SET nb_days = ( CURRENT_DATE - max_date );
502
-
503
- UPDATE caddie_crest_price_history_updates cphu
504
- SET process_queue = 'DAILY', next_process_date = current_date, process_queue_priority = 1, updated_at = localtimestamp
505
- WHERE nb_days <= 7;
506
-
507
- UPDATE caddie_crest_price_history_updates cphu
508
- SET process_queue = 'WEEKLY', next_process_date = date_trunc( 'week', ( current_date + ( interval '1 week' ) ) ), process_queue_priority = 2, updated_at = localtimestamp
509
- WHERE nb_days <= 30 AND nb_days > 7;
510
-
511
- UPDATE caddie_crest_price_history_updates cphu
512
- SET process_queue = 'MONTHLY', next_process_date = date_trunc( 'month', ( current_date + ( interval '1 month' ) ) ), process_queue_priority = 3, updated_at = localtimestamp
513
- WHERE nb_days > 30 OR nb_days IS NULL;
514
-
515
- 
516
-  (0.4ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"]]
517
-  (0.2ms) BEGIN
518
- SQL (0.9ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 0 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
519
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
520
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
521
- SQL (0.6ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
522
-  (0.2ms) COMMIT
523
-  (1.3ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 2]]
524
-  (3.3ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 1]]
525
-  (1.2ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 0]]
526
-  (1.0ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 3]]
527
- Caddie::CrestPriceHistoryUpdate Load (0.8ms) SELECT "caddie_crest_price_history_updates".* FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"]]
528
-  (5.1ms) /* Don't forget to set the postgres sequence to cycle on production */
529
- /* ALTER SEQUENCE caddie_crest_price_history_updates_id_seq CYCLE; */
530
-
531
- /* TRUNCATE TABLE caddie_crest_price_history_updates; */
532
-
533
- /* Insert new regions / items */
534
- INSERT INTO caddie_crest_price_history_updates( eve_item_id, region_id, created_at, updated_at )
535
- SELECT eve_items.id, regions.id, now(), now()
536
- FROM eve_items, regions
537
- WHERE NOT EXISTS ( SELECT NULL FROM caddie_crest_price_history_updates WHERE eve_item_id = eve_items.id and region_id = regions.id );
538
-
539
- /* Update all datas */
540
- UPDATE caddie_crest_price_history_updates cphu
541
- SET max_update = sub.mua, max_eve_item_create = sub.max_eve_item_create, max_region_create = sub.max_region_create
542
- FROM (
543
- SELECT DISTINCT eve_item_id, region_id, MAX( crest_price_histories.updated_at ) mua, MAX( eve_items.created_at ) max_eve_item_create, MAX( regions.created_at ) max_region_create
544
- FROM crest_price_histories, eve_items, regions
545
- WHERE eve_item_id = eve_items.id
546
- AND region_id = regions.id
547
- GROUP BY eve_item_id, region_id
548
- ) sub
549
- WHERE cphu.eve_item_id = sub.eve_item_id
550
- AND cphu.region_id = sub.region_id;
551
-
552
- UPDATE caddie_crest_price_history_updates cphu SET max_date = GREATEST( max_update, max_eve_item_create, max_region_create );
553
-
554
- UPDATE caddie_crest_price_history_updates cphu SET nb_days = ( CURRENT_DATE - max_date );
555
-
556
- UPDATE caddie_crest_price_history_updates cphu
557
- SET process_queue = 'DAILY', next_process_date = current_date, process_queue_priority = 1, updated_at = localtimestamp
558
- WHERE nb_days <= 7;
559
-
560
- UPDATE caddie_crest_price_history_updates cphu
561
- SET process_queue = 'WEEKLY', next_process_date = date_trunc( 'week', ( current_date + ( interval '1 week' ) ) ), process_queue_priority = 2, updated_at = localtimestamp
562
- WHERE nb_days <= 30 AND nb_days > 7;
563
-
564
- UPDATE caddie_crest_price_history_updates cphu
565
- SET process_queue = 'MONTHLY', next_process_date = date_trunc( 'month', ( current_date + ( interval '1 month' ) ) ), process_queue_priority = 3, updated_at = localtimestamp
566
- WHERE nb_days > 30 OR nb_days IS NULL;
567
-
568
- 
569
-  (0.4ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"]]
570
-  (0.2ms) BEGIN
571
- SQL (0.5ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 0 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
572
- SQL (0.5ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
573
- SQL (0.2ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
574
- SQL (0.2ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
575
-  (0.1ms) COMMIT
576
-  (1.5ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 1]]
577
-  (0.8ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 0]]
578
-  (0.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 2]]
579
-  (0.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 3]]
580
-  (0.3ms) BEGIN
581
- SQL (3.4ms) INSERT INTO "caddie_crest_price_history_update_logs" ("feed_date", "update_planning_time", "feeding_time", "total_inserts", "co_seconds", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["feed_date", "2016-07-28"], ["update_planning_time", 0], ["feeding_time", 0], ["total_inserts", 0], ["co_seconds", 0.0], ["created_at", "2016-07-28 09:01:34.922997"], ["updated_at", "2016-07-28 09:01:34.922997"]]
582
-  (0.5ms) COMMIT
583
-  (5.2ms) /* Don't forget to set the postgres sequence to cycle on production */
584
- /* ALTER SEQUENCE caddie_crest_price_history_updates_id_seq CYCLE; */
585
-
586
- /* TRUNCATE TABLE caddie_crest_price_history_updates; */
587
-
588
- /* Insert new regions / items */
589
- INSERT INTO caddie_crest_price_history_updates( eve_item_id, region_id, created_at, updated_at )
590
- SELECT eve_items.id, regions.id, now(), now()
591
- FROM eve_items, regions
592
- WHERE NOT EXISTS ( SELECT NULL FROM caddie_crest_price_history_updates WHERE eve_item_id = eve_items.id and region_id = regions.id );
593
-
594
- /* Update all datas */
595
- UPDATE caddie_crest_price_history_updates cphu
596
- SET max_update = sub.mua, max_eve_item_create = sub.max_eve_item_create, max_region_create = sub.max_region_create
597
- FROM (
598
- SELECT DISTINCT eve_item_id, region_id, MAX( crest_price_histories.updated_at ) mua, MAX( eve_items.created_at ) max_eve_item_create, MAX( regions.created_at ) max_region_create
599
- FROM crest_price_histories, eve_items, regions
600
- WHERE eve_item_id = eve_items.id
601
- AND region_id = regions.id
602
- GROUP BY eve_item_id, region_id
603
- ) sub
604
- WHERE cphu.eve_item_id = sub.eve_item_id
605
- AND cphu.region_id = sub.region_id;
606
-
607
- UPDATE caddie_crest_price_history_updates cphu SET max_date = GREATEST( max_update, max_eve_item_create, max_region_create );
608
-
609
- UPDATE caddie_crest_price_history_updates cphu SET nb_days = ( CURRENT_DATE - max_date );
610
-
611
- UPDATE caddie_crest_price_history_updates cphu
612
- SET process_queue = 'DAILY', next_process_date = current_date, process_queue_priority = 1, updated_at = localtimestamp
613
- WHERE nb_days <= 7;
614
-
615
- UPDATE caddie_crest_price_history_updates cphu
616
- SET process_queue = 'WEEKLY', next_process_date = date_trunc( 'week', ( current_date + ( interval '1 week' ) ) ), process_queue_priority = 2, updated_at = localtimestamp
617
- WHERE nb_days <= 30 AND nb_days > 7;
618
-
619
- UPDATE caddie_crest_price_history_updates cphu
620
- SET process_queue = 'MONTHLY', next_process_date = date_trunc( 'month', ( current_date + ( interval '1 month' ) ) ), process_queue_priority = 3, updated_at = localtimestamp
621
- WHERE nb_days > 30 OR nb_days IS NULL;
622
-
623
- 
624
-  (0.4ms) SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"]]
625
-  (0.2ms) BEGIN
626
- SQL (1.0ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 0 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
627
- SQL (0.6ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 1 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
628
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 2 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
629
- SQL (0.4ms) UPDATE "caddie_crest_price_history_updates" SET "thread_slice_id" = 3 WHERE "caddie_crest_price_history_updates"."id" IN (SELECT "caddie_crest_price_history_updates"."id" FROM "caddie_crest_price_history_updates" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND 1=0 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC) [["next_process_date", "2016-07-28"]]
630
-  (0.3ms) COMMIT
631
-  (1.0ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 0]]
632
-  (0.8ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 1]]
633
-  (0.9ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 2]]
634
-  (1.0ms) SELECT "caddie_crest_price_history_updates"."eve_item_id", "caddie_crest_price_history_updates"."region_id", cpp_eve_item_id, cpp_region_id FROM "caddie_crest_price_history_updates" INNER JOIN "eve_items" ON "eve_items"."id" = "caddie_crest_price_history_updates"."eve_item_id" INNER JOIN "regions" ON "regions"."id" = "caddie_crest_price_history_updates"."region_id" WHERE "caddie_crest_price_history_updates"."next_process_date" = $1 AND "caddie_crest_price_history_updates"."thread_slice_id" = $2 ORDER BY "caddie_crest_price_history_updates"."process_queue_priority" ASC [["next_process_date", "2016-07-28"], ["thread_slice_id", 3]]
635
-  (0.3ms) BEGIN
636
- SQL (0.9ms) INSERT INTO "caddie_crest_price_history_update_logs" ("feed_date", "update_planning_time", "feeding_time", "total_inserts", "co_seconds", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["feed_date", "2016-07-28"], ["update_planning_time", 0], ["feeding_time", 0], ["total_inserts", 0], ["co_seconds", 0.0], ["created_at", "2016-07-28 09:05:10.978280"], ["updated_at", "2016-07-28 09:05:10.978280"]]
637
-  (0.2ms) ROLLBACK