-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2242 from brave-intl/staging
Release 2019-09-19
- Loading branch information
Showing
38 changed files
with
318 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -608,4 +608,4 @@ RUBY VERSION | |
ruby 2.5.5p157 | ||
|
||
BUNDLED WITH | ||
2.0.1 | ||
2.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'csv' | ||
|
||
module Admin | ||
class UpholdStatusReportsController < AdminController | ||
def index | ||
@uphold_status_reports = UpholdStatusReport. | ||
group('(EXTRACT(YEAR FROM created_at))::integer'). | ||
group('(EXTRACT(MONTH FROM created_at))::integer'). | ||
order('2 DESC, 3 DESC').count | ||
end | ||
|
||
def show | ||
date = DateTime.strptime(params[:id], "%Y-%m") | ||
start_date = date.at_beginning_of_month | ||
end_date = date.at_end_of_month | ||
|
||
uphold_status_reports = UpholdStatusReport.where("created_at >= :start AND created_at <= :finish", start: start_date, finish: end_date) | ||
|
||
generated = [] | ||
generated << ["publisher id", "publisher created at", "uphold id", "uphold connected time"].to_csv | ||
|
||
uphold_status_reports.each do |report| | ||
generated << [report.publisher_id, report.publisher.created_at, report.uphold_id, report.created_at].to_csv | ||
end | ||
|
||
send_data generated.join(''), filename: "uphold-#{params[:id]}.csv" | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
class Api::V1::Public::ChannelsController < Api::V1::Public::BaseController | ||
def channels | ||
channels_json = Rails.cache.fetch('browser_channels_json', race_condition_ttl: 30) do | ||
require 'sentry-raven' | ||
Raven.capture_message("Failed to use redis cache for /api/public/channels, using DB instead.") | ||
channels_json = JsonBuilders::ChannelsJsonBuilder.new.build | ||
end | ||
render(json: channels_json, status: 200) | ||
end | ||
include BrowserChannelsDynoCaching | ||
@@cached_payload ||= nil | ||
REDIS_KEY = 'browser_channels_json'.freeze | ||
|
||
def totals | ||
render(json: Channel.statistical_totals, status: 200) | ||
end | ||
|
||
private | ||
|
||
def dyno_expiration_key | ||
"browser_v1_channels_expiration:#{ENV['DYNO']}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
class Api::V2::Public::ChannelsController < Api::V2::Public::BaseController | ||
def channels | ||
channels_json = Rails.cache.fetch('browser_channels_json_v2', race_condition_ttl: 30) do | ||
require 'sentry-raven' | ||
Raven.capture_message("Failed to use redis cache for /api/public/channels V2, using DB instead.") | ||
channels_json = JsonBuilders::ChannelsJsonBuilderV2.new.build | ||
end | ||
render(json: channels_json, status: 200) | ||
end | ||
include BrowserChannelsDynoCaching | ||
@@cached_payload = nil | ||
REDIS_KEY = 'browser_channels_json_v2'.freeze | ||
|
||
def totals | ||
render(json: Channel.statistical_totals, status: 200) | ||
end | ||
|
||
private | ||
|
||
def dyno_expiration_key | ||
"browser_v3_channels_expiration:#{ENV['DYNO']}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
require 'sentry-raven' | ||
|
||
class Api::V3::Public::ChannelsController < Api::V3::Public::BaseController | ||
def channels | ||
channels_json = Rails.cache.fetch('browser_channels_json_v3', race_condition_ttl: 30) do | ||
Raven.capture_message("Failed to use redis cache for /api/public/channels V3, using DB instead.") | ||
channels_json = JsonBuilders::ChannelsJsonBuilderV3.new.build | ||
end | ||
render(json: channels_json, status: 200) | ||
end | ||
include BrowserChannelsDynoCaching | ||
@@cached_payload = nil | ||
REDIS_KEY = 'browser_channels_json_v3'.freeze | ||
|
||
def totals | ||
statistical_totals_json = Rails.cache.fetch(CacheBrowserChannelsJsonJobV3::TOTALS_CACHE_KEY, race_condition_ttl: 30) | ||
render(json: statistical_totals_json, status: 200) | ||
end | ||
|
||
private | ||
|
||
def dyno_expiration_key | ||
"browser_v3_channels_expiration:#{ENV['DYNO']}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module BrowserChannelsDynoCaching | ||
extend ActiveSupport::Concern | ||
require 'sentry-raven' | ||
|
||
def channels | ||
if dyno_cache_expired? || invalid_dyno_cache? | ||
update_dyno_cache | ||
end | ||
render(json: self.class.class_variable_get(klass_dyno_cache), status: 200) | ||
end | ||
|
||
private | ||
|
||
def dyno_cache_expired? | ||
expiration_time = Rails.cache.fetch(dyno_expiration_key) | ||
return expiration_time.nil? || Time.parse(expiration_time) <= Time.now | ||
end | ||
|
||
def invalid_dyno_cache? | ||
cached_dyno_value = self.class.class_variable_get(klass_dyno_cache) | ||
cached_dyno_value.nil? || !cached_dyno_value.is_a?(String) | ||
end | ||
|
||
def update_dyno_cache | ||
redis_value = Rails.cache.fetch(self.class::REDIS_KEY, race_condition_ttl: 30) do | ||
Raven.capture_message("Failed to use redis cache for Dyno cache: #{klass_dyno_cache}, continuing to read from cache instead") | ||
end | ||
if redis_value.present? | ||
self.class.class_variable_set(klass_dyno_cache, redis_value) | ||
Rails.cache.write(dyno_expiration_key, 1.hour.from_now.to_s, expires_in: 1.hour.from_now ) | ||
end | ||
end | ||
|
||
def dyno_expiration_key | ||
raise "Define me for dyno_expiration_name!" | ||
end | ||
|
||
def klass_dyno_cache | ||
:@@cached_payload | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/controllers/publishers/two_factor_authentications_removals_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Publishers | ||
class TwoFactorAuthenticationsRemovalsController < ApplicationController | ||
include TwoFactorAuth | ||
|
||
def new | ||
end | ||
|
||
def create | ||
publisher = pending_2fa_current_publisher | ||
|
||
publisher.register_for_2fa_removal if publisher.two_factor_authentication_removal.blank? | ||
publisher.reload | ||
|
||
MailerServices::TwoFactorAuthenticationRemovalReminderEmailer.new(publisher: publisher).perform | ||
redirect_to two_factor_authentications_path, flash: { notice: t("publishers.two_factor_authentication_removal.request_success") } | ||
end | ||
|
||
def destroy | ||
publisher = pending_2fa_current_publisher | ||
|
||
publisher.two_factor_authentication_removal.destroy if publisher.two_factor_authentication_removal.present? | ||
|
||
redirect_to two_factor_authentications_path, flash: { notice: t("publishers.two_factor_authentication_removal.confirm_cancel_flash") } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.