Permalink
Browse files

More DemandProgress-specific settings moved to generic settings that …

…either identify VK as the chief application or rely on configuration variables.
  • Loading branch information...
1 parent 80f1930 commit 1fa924527f214aeea0f0198a6e4329f22062623d @bguthrie bguthrie committed Aug 6, 2013
View
@@ -9,11 +9,8 @@ gem 'memcachier'
gem 'dalli'
gem 'kgio'
-group :production do
- # just used for unsubscribes import
- gem 'mysql'
- gem 'mysql2'
-end
+# just used for unsubscribes import
+gem 'mysql2'
# Gems used only for assets and not required
# in production environments by default.
View
@@ -189,7 +189,6 @@ GEM
metaclass (~> 0.0.1)
multi_json (1.7.2)
multi_xml (0.5.2)
- mysql (2.9.0)
mysql2 (0.3.11)
newrelic-redis (1.4.0)
newrelic_rpm (~> 3.0)
@@ -389,7 +388,6 @@ DEPENDENCIES
kgio
memcachier
memoist!
- mysql
mysql2
newrelic-redis
newrelic_rpm
@@ -91,7 +91,7 @@ var facebook = (function() {
return;
}
var petition = $('meta[property="og:url"]').attr('content');
- FB.api('/me/watchdognet:sign', 'post', { petition: petition }, apiCallback);
+ FB.api('/me/victorykit:sign', 'post', { petition: petition }, apiCallback);
}
function apiCallback(res) {
@@ -3,7 +3,7 @@ module PetitionsHelper
def open_graph_for(petition, referral)
{
'og:title' => referral.title,
- 'og:type' => 'watchdognet:petition',
+ 'og:type' => 'victorykit:petition',
'og:description' => referral.facebook_description_for_sharing.html_safe,
'og:image' => referral.image,
'og:site_name' => social_media_config[:facebook][:site_name]
@@ -63,8 +63,7 @@ def compose(petition, member, email, petition_link, raw_petition_link)
mailbox, domain = Settings.site.list_unsubscribe.split("@")
address = "mailto:#{mailbox}+#{email_hash}@#{domain}"
-
- headers["List-Unsubscribe"] = "mailto:unsubscribe+" + email_hash + "@appmail.watchdog.net"
+ headers["List-Unsubscribe"] = address
mail = mail(
subject: email_experiment.subject,
@@ -0,0 +1,24 @@
+class ActionKitUnsubscribeGateway
+
+ def self.fetch_unsubscribers_since(date)
+ client = Mysql2::Client.new(settings)
+
+ results = client.query <<-SQL
+ SELECT email, core_action.created_at
+ FROM core_action
+ JOIN core_unsubscribeaction ON (core_action.id = core_unsubscribeaction.action_ptr_id)
+ JOIN core_user on (core_user.id = core_action.user_id)
+ WHERE core_action.created_at > '#{client.escape(date.to_s)}'
+ ORDER BY created_at DESC
+ SQL
+
+ results.to_a.map do |row|
+ UnsubscribeRequest.new(row["email"], row["created_at"])
+ end
+ end
+
+ def self.settings
+ Settings.action_kit.to_hash
+ end
+
+end
@@ -1,14 +0,0 @@
-class DemandProgressGateway
-
- def self.fetch_unsubscribers_since(date)
- client = Mysql2::Client.new(:host => settings.host, :username => settings.username, :password => settings.password, :database => settings.database)
- results = client.query("select email, core_action.created_at from core_action join core_unsubscribeaction on (core_action.id = core_unsubscribeaction.action_ptr_id) join core_user on (core_user.id = core_action.user_id) where core_action.created_at > '" + date.to_s + "' order by created_at desc")
-
- results.to_a.map{ |row| UnsubscribeRequest.new(row["email"], row["created_at"]) }
- end
-
- def self.settings
- Settings.dp_connection
- end
-
-end
@@ -3,7 +3,7 @@
:secret_access_key => Settings.aws.secret_access_key
if ENV['DKIM_PRIVATE_KEY']
- Dkim::domain = 'watchdog.net'
+ Dkim::domain = Settings.email.domain
Dkim::selector = 'mail'
Dkim::private_key = ENV['DKIM_PRIVATE_KEY']
View
@@ -9,11 +9,11 @@ google_analytics:
analytics_id: UA-31572927-1
email:
from_address: Melanie Jones <info@watchdog.net>
-dp_connection:
- host: OVERRIDE_ME
- username: OVERRIDE_ME
- password: OVERRIDE_ME
- database: OVERRIDE_ME
+action_kit:
+ host: <%= ENV["AK_IMPORT_DB_HOST"] %>
+ username: <%= ENV["AK_IMPORT_DB_UNAME"] %>
+ password: <%= ENV["AK_IMPORT_DB_PWD"] %>
+ database: <%= ENV["AK_IMPORT_DB"] %>
cloudmailin:
token: <%= ENV["CLOUDMAILIN_TOKEN"] %>
organization:
@@ -12,10 +12,5 @@ google_analytics:
client_secret: <%= ENV["OAUTH_CLIENT_SECRET"] %>
token: <%= ENV["OAUTH_TOKEN"] %>
secret: <%= ENV["OAUTH_SECRET"] %>
-dp_connection:
- host: <%= ENV["AK_IMPORT_DB_HOST"] %>
- username: <%= ENV["AK_IMPORT_DB_UNAME"] %>
- password: <%= ENV["AK_IMPORT_DB_PWD"] %>
- database: <%= ENV["AK_IMPORT_DB"] %>
paypal:
uri: <%= ENV["PAYPAL"] %>
@@ -12,8 +12,3 @@ google_analytics:
client_secret: <%= ENV["OAUTH_CLIENT_SECRET"] %>
token: <%= ENV["OAUTH_TOKEN"] %>
secret: <%= ENV["OAUTH_SECRET"] %>
-dp_connection:
- host: <%= ENV["AK_IMPORT_DB_HOST"] %>
- username: <%= ENV["AK_IMPORT_DB_UNAME"] %>
- password: <%= ENV["AK_IMPORT_DB_PWD"] %>
- database: <%= ENV["AK_IMPORT_DB"] %>
View
@@ -4,7 +4,7 @@
<meta charset='utf-8'>
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
- <title>Page not found -- Watchdog.net</title>
+ <title>Page not found -- VictoryKit</title>
<link type="text/css" rel="stylesheet" media="screen" href="/assets/application.css">
<style>
.container {
View
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Watchdog.net</title>
+ <title>VictoryKit</title>
</head>
<body>
<script>
@@ -171,7 +171,7 @@ def valid_attributes
body.xpath('//meta[@property="og:title"]/@content').first.inner_html.should == "evil unsafe characters! \"&amp;'&lt;&gt;"
body.xpath('//meta[@property="og:description"]/@content').first.inner_html.should == "\"&amp;'&lt;&gt;"
body.xpath('//meta[@property="og:site_name"]/@content').first.value.should == 'Victory Kit'
- body.xpath('//meta[@property="og:type"]/@content').first.value.should == 'watchdognet:petition'
+ body.xpath('//meta[@property="og:type"]/@content').first.value.should == 'victorykit:petition'
# We want a value there, but it'll change with time.
body.xpath('//meta[@property="og:image"]/@content').first.value.should_not be_empty
end
@@ -19,7 +19,7 @@
end
subject { helper.open_graph_for(petition, signer_code) }
- it { should include('og:type' => 'watchdognet:petition') }
+ it { should include('og:type' => 'victorykit:petition') }
it { should include('og:title' => petition.title) }
it { should include('og:description' => strip_tags(petition.description)) }
it "should have an image drawn from the list of possible Facebook images" do
@@ -1,19 +1,19 @@
class UnsubscribePoller
-
+
def self.unsubscribe_users
LastUpdatedUnsubscribe.transaction do
update_token = LastUpdatedUnsubscribe.find_by_id(1, :lock => true)
update_token = bootstrap(update_token)
-
+
if update_token.is_locked
Rails.logger.info "Skipping update of unsubscribe users: LastUpdateUnsubscribe is locked."
return
end
-
+
begin
lock_update_token(update_token, true)
- unsubscribe_requests = DemandProgressGateway.fetch_unsubscribers_since(update_token.updated_at)
+ unsubscribe_requests = ActionKitUnsubscribeGateway.fetch_unsubscribers_since(update_token.updated_at)
unsubscribe_requests.each {|r| r.unsubscribe_member}
latest_member_created = unsubscribe_requests.max { |x,y| x.created_at <=> y.created_at }
update_token.updated_at = latest_member_created.nil? ? update_token.updated_at : latest_member_created.created_at
@@ -25,18 +25,18 @@ def self.unsubscribe_users
end
end
end
-
- private
-
+
+ private
+
def self.bootstrap(update_token)
update_token.nil? ? LastUpdatedUnsubscribe.new(id: 1, updated_at: Time.at(0)) : update_token
end
-
+
def self.lock_update_token(update_token, lock)
update_token.is_locked = lock
update_token.save!
end
-
+
end
-UnsubscribePoller.unsubscribe_users
+UnsubscribePoller.unsubscribe_users

0 comments on commit 1fa9245

Please sign in to comment.