Skip to content

Commit

Permalink
Merge pull request #2338 from brave-intl/staging
Browse files Browse the repository at this point in the history
Release 2019-10-25
  • Loading branch information
yachtcaptain23 authored Oct 25, 2019
2 parents 8db5b7a + 40ef89d commit 469f99b
Show file tree
Hide file tree
Showing 58 changed files with 1,823 additions and 416 deletions.
15 changes: 15 additions & 0 deletions app/assets/images/icn-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 8 additions & 10 deletions app/assets/images/icn-info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 58 additions & 11 deletions app/assets/stylesheets/pages/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@

.promo-flex-col {
display: flex;
justify-content: space-evenly;
flex-direction: column;
color: #fff;
}

.promo-flex-stats {
display: flex;
flex-direction: column-reverse;
justify-content: space-between;

}

@media only screen and (max-width: 400px) {
Expand All @@ -141,6 +144,7 @@

.promo-flex-row {
display: flex;
justify-content: space-between;

&-sub {
color: #326183;
Expand All @@ -155,10 +159,63 @@
font-size: 1em;
}

.promo-table {
color: #326183;
letter-spacing: 0.5px;
font-size: 14px;

tr {
border-bottom: solid 1px rgba(0, 0, 0, 0.2);
border-top: solid 1px rgba(0, 0, 0, 0.2);

td {
padding: 5px 3px;
}
}
}

.promo-info {
margin-top: 15px;

display: flex;
align-items: center;

svg {
width: 18px;
height: 18px;
margin: 0 10px 0 0;
}

a {
color: #fff !important;
}
}

.promo-selected {
color: rgb(27, 29, 47);
}

.promo-period {
background: rgba(255, 255, 255, 0.2);
padding: 5px 10px;
font-weight: 600;

border-radius: $brave-panels-borderRadius;
select {
border: 0;
color: #EEE;
background: transparent;
font-weight: bold;
padding: 2px 10px;
-webkit-appearance: none;
}
}

.promo-panel-number {
text-align: center;
text-align: right;
font-weight: 600;
font-size: 30px;
color: white;
}

.promo-panel-title {
Expand Down Expand Up @@ -366,16 +423,6 @@
border-radius: $brave-panels-borderRadius;
}

.in-place-edit {
background: $braveGray-9;
border-radius: $brave-panels-borderRadius;
padding: 18px;

.button.form-group a {
display: inline-block;
}
}

.form-group {
padding-top: 5px;
}
Expand Down
12 changes: 5 additions & 7 deletions app/assets/stylesheets/pages/promo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@
.promo--activate-button {
color: white;
background: #03375D;
font-size: 11px;
font-size: 14px;
font-weight: 600;
width: 100%;
display: inline-block;
border: none;
padding-bottom: 10px;
padding-top: 10px;
margin-top: 1em;
padding: 10px 30px;
&:hover,
&focus {
background-color: #00223B;
Expand Down Expand Up @@ -180,7 +179,7 @@
}
}
.promo--activate-body-container {
margin: 0px 25%;
margin: 0px 10%;
}
.promo--body-text {
color: white;
Expand All @@ -189,7 +188,6 @@
&-alternative {
margin: 0px;
opacity: 1;
line-height: 20px;
letter-spacing: 1px;
font-size: 16px;
padding-bottom: 15px;
Expand Down Expand Up @@ -322,4 +320,4 @@
}
}
}
}
}
10 changes: 10 additions & 0 deletions app/assets/stylesheets/pages/settings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

.in-place-edit {
background: $braveGray-9;
border-radius: $brave-panels-borderRadius;
padding: 18px;

.button.form-group a {
display: inline-block;
}
}
7 changes: 3 additions & 4 deletions app/assets/stylesheets/theme/promo-content.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.promo-content {
&--background {
min-height: 100vh;
background: #0a2d35;
background: linear-gradient(154deg,#2a1fad 19%,#a91b78 100%);
padding-top: 90px;
margin-top: -40px;
padding-bottom: 40px;
background-position: center;
background-size: cover;
Expand All @@ -18,7 +17,7 @@
.footer--promo {
display: table;
width: 100%;
color: $bravePromo-DarkBlue;
color: white;
font-size: 12px;
text-align: center;
padding: 0px;
Expand Down Expand Up @@ -61,4 +60,4 @@
border-width: 1px;
}
}
}
}
38 changes: 37 additions & 1 deletion app/controllers/publishers/promo_registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@ def for_referral_code
current_publisher.promo_registrations.find_by(referral_code: params[:referral_code])
end
render :unauthorized and return if promo_registration.nil?
render json: promo_registration.stats_by_date.to_json
render json: {
stats: promo_registration.aggregate_stats,
data: promo_registration.stats_by_date,
}
end

def overview
start_date = (params[:month]&.to_date || Date.today).at_beginning_of_month
end_date = start_date.at_end_of_month

aggregate_stats = PromoRegistration.stats_for_registrations(
promo_registrations: current_publisher.promo_registrations,
start_date: start_date,
end_date: end_date
)

groups = Eyeshade::Referrals.new.groups
statement = Eyeshade::Referrals.new.statement(publisher: current_publisher, start_date: start_date, end_date: end_date)

groups.each do |group|
group[:count] = statement.select { |s| s[:groupId] == group[:id] }.length
end

# TODO Remove this after November 1st, 2019
legacy_count = aggregate_stats[PromoRegistration::FINALIZED] - statement.length
groups << {
id: SecureRandom.uuid,
name: 'Previous Rate',
amount: "5.00",
currency: "USD",
count: legacy_count.negative? ? 0 : legacy_count,
}

render json: {
groups: groups,
totals: aggregate_stats,
}
end
end
1 change: 1 addition & 0 deletions app/controllers/publishers/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class SettingsController < ApplicationController
before_action :authenticate_publisher!

def index
@publisher = current_publisher
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/publishers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def update
flash[:notice] = I18n.t("publishers.settings.update.alert")
respond_to do |format|
if success
format.json { head :no_content }
format.json { render json: {} }
format.html { redirect_to home_publishers_path }
else
format.json { render(json: { errors: current_publisher.errors }, status: 400) }
Expand Down
26 changes: 9 additions & 17 deletions app/helpers/promos_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def offline_promo_stats
end

def publisher_referral_totals(publisher)
aggregate_stats = PromoRegistration.aggregate_stats(publisher.promo_registrations)
aggregate_stats = PromoRegistration.stats_for_registrations(promo_registrations: publisher.promo_registrations)

{
PromoRegistration::RETRIEVALS => aggregate_stats[PromoRegistration::RETRIEVALS],
Expand All @@ -31,23 +31,15 @@ def publisher_referral_totals(publisher)
end

def publisher_current_referral_totals(publisher)
retrievals = 0
first_runs = 0
finalized = 0
cutoff = Date.today.beginning_of_month
publisher.promo_registrations.each do |promo_registration|
JSON.parse(promo_registration.stats).each do |stat|
if Date.parse(stat["ymd"]) > cutoff
retrievals += stat["retrievals"]
first_runs += stat["first_runs"]
finalized += stat["finalized"]
end
end
end
aggregate_stats = PromoRegistration.stats_for_registrations(
promo_registrations: publisher.promo_registrations,
start_date: Date.today.beginning_of_month
)

{
PromoRegistration::RETRIEVALS => retrievals,
PromoRegistration::FIRST_RUNS => first_runs,
PromoRegistration::FINALIZED => finalized,
PromoRegistration::RETRIEVALS => aggregate_stats[PromoRegistration::RETRIEVALS],
PromoRegistration::FIRST_RUNS => aggregate_stats[PromoRegistration::FIRST_RUNS],
PromoRegistration::FINALIZED => aggregate_stats[PromoRegistration::FINALIZED],
}
end

Expand Down
Loading

0 comments on commit 469f99b

Please sign in to comment.