user_notifier 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdd2ab094e02c99e723edbbe759fdb9e1f89e043
4
- data.tar.gz: bdaf02d80f56b0a8bc36f2a3f8baf64d7739daed
3
+ metadata.gz: 6cb454c6c1c482a948d1f588878a24833712fd1a
4
+ data.tar.gz: 0cad09d1c573dd3d186c2d98250c9dcbf6fc8088
5
5
  SHA512:
6
- metadata.gz: 2210ddc1d6217c723e64cbb9d0bd473eae06fe891b69148bf40ff2343082d1e9137dc1ba88c68cc6453c5855713c68eb2d906324e9015fd4fa35f28cb2df1b51
7
- data.tar.gz: 8352e2a9266fb860f0e8196084f07a66210f35e15f095f5465aef015d182f911fdb8582b5ef3f842b8fbd38ef107f23c73766a8b58d890ace4be42e161b4f00d
6
+ metadata.gz: 4b60d65e3695cb8a5372a3321c7558d853e180c303e65a1225edfe0b03c17b55b3e9193e6ca70362a94d04bdac11669bdb7cd0399f7fb1cb5fc8f1213774935a
7
+ data.tar.gz: 5af36e65df4dac3b6b12b0e5e560ecd9dcd7e105f8bcb87d01cadec812df38e37e673902fab480e8a0c125564eaf14eaac8920d8694164129f0b966767dd5dec
@@ -8,6 +8,7 @@ class Create<%= notifications_table_name.camelize %> < ActiveRecord::Migration
8
8
  t.text :template_name, null: false
9
9
  t.text :locale, null: false
10
10
  t.timestamp :sent_at
11
+ t.timestamp :deliver_at
11
12
  t.timestamps
12
13
  end
13
14
  end
@@ -23,7 +23,7 @@ class UserNotifier::Base < ActiveRecord::Base
23
23
  end
24
24
 
25
25
  def deliver!
26
- UserNotifier::EmailWorker.perform_async(self.class.name.to_s, self.id)
26
+ UserNotifier::EmailWorker.perform_at((self.try(:deliver_at) || Time.now), self.class.name.to_s, self.id)
27
27
  end
28
28
 
29
29
  def deliver_without_worker
@@ -1,3 +1,3 @@
1
1
  module UserNotifier
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,25 +1,45 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
1
+ # PostgreSQL. Versions 9.1 or later are supported.
3
2
  #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
3
+ # Install the pg driver:
4
+ # gem install pg
5
+ # On Mac OS X with macports:
6
+ # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
7
+ # On Windows:
8
+ # gem install pg
9
+ # Choose the win32 build.
10
+ # Install PostgreSQL and put its /bin directory on your path.
6
11
  development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
12
+ adapter: postgresql
13
+ encoding: unicode
14
+ host: localhost
15
+ database: user_notifier_development
9
16
  pool: 5
10
- timeout: 5000
17
+ username: postgres
18
+
19
+
20
+ # Connect on a TCP socket. Omitted by default since the client uses a
21
+ # domain socket that doesn't need configuration. Windows does not have
22
+ # domain sockets, so uncomment these lines.
23
+ #host: localhost
24
+ #port: 5432
25
+
26
+ # Schema search path. The server defaults to $user,public
27
+ #schema_search_path: myapp,sharedapp,public
28
+
29
+ # Minimum log levels, in increasing order:
30
+ # debug5, debug4, debug3, debug2, debug1,
31
+ # log, notice, warning, error, fatal, and panic
32
+ # The server defaults to notice.
33
+ #min_messages: warning
11
34
 
12
35
  # Warning: The database defined as "test" will be erased and
13
36
  # re-generated from your development database when you run "rake".
14
37
  # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
38
 
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
39
+ test:
40
+ adapter: postgresql
41
+ encoding: unicode
42
+ host: localhost
43
+ database: user_notifier_test
24
44
  pool: 5
25
- timeout: 5000
45
+ username: postgres
@@ -0,0 +1,14 @@
1
+ class AddDeliverAtToNotifications < ActiveRecord::Migration
2
+ def up
3
+ add_column :order_notifications, :deliver_at, :timestamp
4
+ add_column :user_notifications, :deliver_at, :timestamp
5
+
6
+ execute "ALTER TABLE order_notifications ALTER deliver_at SET DEFAULT current_timestamp"
7
+ execute "ALTER TABLE user_notifications ALTER deliver_at SET DEFAULT current_timestamp"
8
+ end
9
+
10
+ def down
11
+ remove_column :order_notifications, :deliver_at, :timestamp
12
+ remove_column :user_notifications, :deliver_at, :timestamp
13
+ end
14
+ end
@@ -11,16 +11,20 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20140709170259) do
14
+ ActiveRecord::Schema.define(version: 20150713180329) do
15
+
16
+ # These are extensions that must be enabled in order to support this database
17
+ enable_extension "plpgsql"
15
18
 
16
19
  create_table "order_notifications", force: :cascade do |t|
17
- t.integer "user_id", null: false
18
- t.integer "order_id", null: false
19
- t.text "from_email", null: false
20
- t.text "from_name", null: false
21
- t.text "template_name", null: false
22
- t.text "locale", null: false
20
+ t.integer "user_id", null: false
21
+ t.integer "order_id", null: false
22
+ t.text "from_email", null: false
23
+ t.text "from_name", null: false
24
+ t.text "template_name", null: false
25
+ t.text "locale", null: false
23
26
  t.datetime "sent_at"
27
+ t.datetime "deliver_at", default: "now()"
24
28
  end
25
29
 
26
30
  create_table "orders", force: :cascade do |t|
@@ -37,6 +41,7 @@ ActiveRecord::Schema.define(version: 20140709170259) do
37
41
  t.text "template_name"
38
42
  t.text "locale"
39
43
  t.datetime "sent_at"
44
+ t.datetime "deliver_at", default: "now()"
40
45
  end
41
46
 
42
47
  create_table "users", force: :cascade do |t|
@@ -37,3 +37,152 @@ Migrating to CreateOrderNotifications (20140709170259)
37
37
   (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20140625163719')
38
38
   (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20140625183616')
39
39
   (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20140709164530')
40
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
41
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
42
+  (4.3ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
43
+  (1.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
44
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
45
+ Migrating to CreateUsers (20140625163719)
46
+  (0.2ms) BEGIN
47
+ 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 /Users/diogo/Projects/user_notifier/spec/dummy/db/migrate/20140625163719_create_users.rb:7)
48
+  (4.8ms) CREATE TABLE "users" ("id" serial primary key, "name" text, "email" text, "created_at" timestamp, "updated_at" timestamp) 
49
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140625163719"]]
50
+  (0.5ms) COMMIT
51
+ Migrating to CreateUserNotifications (20140625183616)
52
+  (0.3ms) BEGIN
53
+  (4.2ms) CREATE TABLE "user_notifications" ("id" serial primary key, "user_id" integer, "from_email" text, "from_name" text, "template_name" text, "locale" text, "sent_at" timestamp) 
54
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140625183616"]]
55
+  (0.6ms) COMMIT
56
+ Migrating to CreateOrders (20140709164530)
57
+  (0.4ms) BEGIN
58
+ 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 /Users/diogo/Projects/user_notifier/spec/dummy/db/migrate/20140709164530_create_orders.rb:7)
59
+  (5.8ms) CREATE TABLE "orders" ("id" serial primary key, "user_id" integer, "title" text, "created_at" timestamp, "updated_at" timestamp) 
60
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140709164530"]]
61
+  (0.5ms) COMMIT
62
+ Migrating to CreateOrderNotifications (20140709170259)
63
+  (0.4ms) BEGIN
64
+  (6.0ms) CREATE TABLE "order_notifications" ("id" serial primary key, "user_id" integer NOT NULL, "order_id" integer NOT NULL, "from_email" text NOT NULL, "from_name" text NOT NULL, "template_name" text NOT NULL, "locale" text NOT NULL, "sent_at" timestamp) 
65
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140709170259"]]
66
+  (0.5ms) COMMIT
67
+ Migrating to AddDeliverAtToNotifications (20150713180329)
68
+  (0.4ms) BEGIN
69
+  (1.1ms) ALTER TABLE "order_notifications" ADD "deliver_at" timestamp
70
+  (1.5ms) ALTER TABLE "user_notifications" ADD "deliver_at" timestamp
71
+  (1.5ms) ALTER TABLE order_notifications ALTER deliver_at SET DEFAULT current_timestamp
72
+  (1.0ms) ALTER TABLE user_notifications ALTER deliver_at SET DEFAULT current_timestamp
73
+ SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150713180329"]]
74
+  (0.6ms) COMMIT
75
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
76
+  (5.5ms) 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
77
+ FROM pg_constraint c
78
+ JOIN pg_class t1 ON c.conrelid = t1.oid
79
+ JOIN pg_class t2 ON c.confrelid = t2.oid
80
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
81
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
82
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
83
+ WHERE c.contype = 'f'
84
+ AND t1.relname = 'order_notifications'
85
+ AND t3.nspname = ANY (current_schemas(false))
86
+ ORDER BY c.conname
87
+
88
+  (4.6ms) 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
89
+ FROM pg_constraint c
90
+ JOIN pg_class t1 ON c.conrelid = t1.oid
91
+ JOIN pg_class t2 ON c.confrelid = t2.oid
92
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
93
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
94
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
95
+ WHERE c.contype = 'f'
96
+ AND t1.relname = 'orders'
97
+ AND t3.nspname = ANY (current_schemas(false))
98
+ ORDER BY c.conname
99
+ 
100
+  (5.0ms) 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
101
+ FROM pg_constraint c
102
+ JOIN pg_class t1 ON c.conrelid = t1.oid
103
+ JOIN pg_class t2 ON c.confrelid = t2.oid
104
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
105
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
106
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
107
+ WHERE c.contype = 'f'
108
+ AND t1.relname = 'user_notifications'
109
+ AND t3.nspname = ANY (current_schemas(false))
110
+ ORDER BY c.conname
111
+
112
+  (4.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
113
+ FROM pg_constraint c
114
+ JOIN pg_class t1 ON c.conrelid = t1.oid
115
+ JOIN pg_class t2 ON c.confrelid = t2.oid
116
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
117
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
118
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
119
+ WHERE c.contype = 'f'
120
+ AND t1.relname = 'users'
121
+ AND t3.nspname = ANY (current_schemas(false))
122
+ ORDER BY c.conname
123
+ 
124
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
125
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
126
+  (4.0ms) 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 = 'order_notifications'
135
+ AND t3.nspname = ANY (current_schemas(false))
136
+ ORDER BY c.conname
137
+ 
138
+  (3.5ms) 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 = 'orders'
147
+ AND t3.nspname = ANY (current_schemas(false))
148
+ ORDER BY c.conname
149
+
150
+  (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
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 = 'user_notifications'
159
+ AND t3.nspname = ANY (current_schemas(false))
160
+ ORDER BY c.conname
161
+ 
162
+  (3.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
163
+ FROM pg_constraint c
164
+ JOIN pg_class t1 ON c.conrelid = t1.oid
165
+ JOIN pg_class t2 ON c.confrelid = t2.oid
166
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
167
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
168
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
169
+ WHERE c.contype = 'f'
170
+ AND t1.relname = 'users'
171
+ AND t3.nspname = ANY (current_schemas(false))
172
+ ORDER BY c.conname
173
+
174
+  (120.6ms) DROP DATABASE IF EXISTS "user_notifier_test"
175
+  (243.4ms) CREATE DATABASE "user_notifier_test" ENCODING = 'unicode'
176
+ SQL (0.4ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
177
+  (7.1ms) CREATE TABLE "order_notifications" ("id" serial primary key, "user_id" integer NOT NULL, "order_id" integer NOT NULL, "from_email" text NOT NULL, "from_name" text NOT NULL, "template_name" text NOT NULL, "locale" text NOT NULL, "sent_at" timestamp, "deliver_at" timestamp DEFAULT 'now()')
178
+  (4.8ms) CREATE TABLE "orders" ("id" serial primary key, "user_id" integer, "title" text, "created_at" timestamp, "updated_at" timestamp) 
179
+  (4.4ms) CREATE TABLE "user_notifications" ("id" serial primary key, "user_id" integer, "from_email" text, "from_name" text, "template_name" text, "locale" text, "sent_at" timestamp, "deliver_at" timestamp DEFAULT 'now()')
180
+  (5.4ms) CREATE TABLE "users" ("id" serial primary key, "name" text, "email" text, "created_at" timestamp, "updated_at" timestamp) 
181
+  (2.3ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
182
+  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
183
+  (0.4ms) SELECT version FROM "schema_migrations"
184
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20150713180329')
185
+  (0.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20140625163719')
186
+  (0.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20140625183616')
187
+  (0.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20140709164530')
188
+  (0.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20140709170259')