Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/sidekiq-7.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
forsbergplustwo authored Sep 21, 2023
2 parents 976f994 + af6b66c commit c7b8ac5
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The app in this repo was recently upgraded to Rails 7. If you had the earlier ve
```
bin/rails db:migrate
bin/rails db:encryption:init
bin/rails create_initial_import
bin/rails create_initial_imports
bin/rails migrate_partner_api_credentials
```

Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/polaris_overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@
.Polaris-HorizontalGrid {
grid-template-columns: repeat(1, minmax(0, 1fr))
}

.Polaris-LegacyStack.filter-stack {
margin-left: 0;
}
}
6 changes: 3 additions & 3 deletions app/javascript/controllers/globe_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ export default class extends Controller {
// HELPER FUNCTIONS

async setUserLocation() {
// Using http://ip-api.com/json/
const response = await get("http://ip-api.com/json/?fields=countryCode");
// Using https://ip-api.com/json/
const response = await get("https://api.country.is");
if (response.ok) {
const locationData = await response.json;
this.myLocationValue = locationData.countryCode;
this.myLocationValue = locationData.country;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class ApplicationMailer < ActionMailer::Base
private

def default_from
Rails.application.credentials[:action_mailer][:email_from_address]
Rails.application.credentials[Rails.env.to_sym][:action_mailer][:email_from_address]
end
end
1 change: 1 addition & 0 deletions app/models/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Import < ApplicationRecord
scope :in_progress, -> { where(status: %i[scheduled importing calculating]) }

def schedule
return unless draft?
scheduled!
ImportPaymentsJob.perform_later(import: self)
end
Expand Down
1 change: 0 additions & 1 deletion app/models/import/adaptor/csv_file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "zip"
require "csvreader"

class Import::Adaptor::CsvFile
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= polaris_empty_state(
heading: "A free metrics dashboard for Shopify Partners",
classes: "empty-state",
image: image_path("empty_state/AnalyticsMinor"),
image: image_path("empty_state/AnalyticsMinor.svg"),
) do |state| %>

<% state.with_primary_action(url: new_user_registration_path) { "Sign up" } %>
Expand Down
7 changes: 5 additions & 2 deletions app/views/imports/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@
<% end %>

<% end %>
<br>
<%= tag.div style: "width: 80%; height: 800px; margin: 0 auto; opacity: 0; transition: opacity 3s ease-in-out;",

<% if @import.csv_file_source? %>
<%= polaris_spacer(vertical: :base) %>
<%= tag.div style: "width: 80%; height: 800px; margin: 0 auto; opacity: 0; transition: opacity 3s ease-in-out;",
data: {
controller: "globe",
globe_target: "container",
globe_fetch_url_value: import_globe_path(@import),
} %>
<% end %>

<%= render "modals/destroy",
id: "destroy-modal",
Expand Down
2 changes: 1 addition & 1 deletion app/views/metrics/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<%= polaris_vertical_stack(gap: "6") do %>

<%= polaris_stack(alignment: :center) do |stack| %>
<%= polaris_stack(alignment: :center, classes: "filter-stack") do |stack| %>

<% stack.with_item(fill:true) do %>
<%= render "filter", filter: @filter, app_titles: @app_titles %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_empty_state.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= polaris_empty_state(
heading: t(".title", resource: resource_name_for(resource, true)),
classes: "empty-state",
image: image_path("empty_state/ImportMinor"),
image: image_path("empty_state/ImportMinor.svg"),
) do |state| %>

<% state.with_primary_action(url: new_import_path) { "New import" } %>
Expand Down
2 changes: 2 additions & 0 deletions config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: partner_metrics_production
ssl_params:
verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>
17 changes: 16 additions & 1 deletion config/credentials.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,35 @@ development:
username:
password:
email_from_address:

sendgrid:
api_key:
cloudflare:
account_id:
access_key_id:
secret_access_key:
bucket:
test:
secret_key_base:
action_mailer:
username:
password:
email_from_address:
sendgrid:
api_key:
cloudflare:
account_id:
access_key_id:
secret_access_key:
bucket:

production:
secret_key_base:
action_mailer:
username:
password:
email_from_address:
sendgrid:
api_key:
cloudflare:
account_id:
access_key_id:
Expand Down
2 changes: 1 addition & 1 deletion config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mGRLkQ8haPVqu3prCsxRTrnpFhO5WCIiCNSo6TilHmyzLSbfe+z4wiqIsbSVzHtdZA6aAE+2P4f14O745E8NsnZJaj+8Iop+Agln87Wa5zzfQ6sNvOAJK06fJIfwOkoo/rvG4S6zvDP3vSgGac/n9dcstKE2gCHrK3UB07K9HZ3BPoiyeGm/JYJUxoz3Secd5UsLF1c1BEkJMtIunwj/862YI/8Db+VBfGk3AbMc3gdIMhLzkvSsxDb8L3fLN+h2zRHGL+N5pk+KuSSpfA2UKSjTInlBSxBq2fK44hpuc1bhkaQWBlneP8iv1yy3itlO5nStLnsWXqe7kDqhLb1CwA3JOJ9fzAYHSBzHOmBfBuhrtWh/1w9A90fOgSO4S2MqClhDcS1ELx2fClY47tW2RfjUpyngb43GhK+oBf8feix3kNfTruzQwohAYUgW52rmanBO41Z5wytfYH+VnYMe8yRqflmYNrfJswlOBhxofYFQy4Y8/8Tp9b/zfVt+Yt+9nXyATg/m9S3hS1OVkAHrFvkCNnCQLhmY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QEEHVXsqu/sz3JD8VUvt81801CgBmdV65sLmM733Zl4s71N9trTU/JcHkRlTdBISxNlCVRRwqTqLn24d3LFHjruZFokDLE6ALN5fFkgGwts63F+IoURDqiVymIoUFKX/SGvvOo25/8Qo8OfwCpDc--iTXmcHtzsIHTXXnk--RXkWKUk/pyl/uqk3pPuIvg==
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
config.action_mailer.default_url_options = { host: "localhost:4000" }
config.action_mailer.asset_host = "http://localhost:4000"
config.action_mailer.smtp_settings = {
from: Rails.application.credentials.dig(:action_mailer, :from_email_address),
from: Rails.application.credentials[Rails.env.to_sym][:action_mailer][:from_email_address],
}

# Print deprecation notices to the Rails logger.
Expand Down
8 changes: 4 additions & 4 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
config.log_tags = [ :request_id ]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
Expand All @@ -67,9 +67,9 @@
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
config.action_mailer.default_url_options = {host: "partnermetrics.io"}
app.config.action_mailer.delivery_method = :sendgrid_actionmailer
app.config.action_mailer.sendgrid_actionmailer_settings = {
api_key: Rails.application.credentials[:sendgrid][:api_key],
config.action_mailer.delivery_method = :sendgrid_actionmailer
config.action_mailer.sendgrid_actionmailer_settings = {
api_key: Rails.application.credentials[Rails.env.to_sym][:sendgrid][:api_key],
raise_delivery_errors: true
}

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.precompile += %w( .svg )
13 changes: 13 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Sidekiq.configure_server do |config|
config.redis = {
url: ENV["REDIS_URL"],
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
}
end

Sidekiq.configure_client do |config|
config.redis = {
url: ENV["REDIS_URL"],
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
}
end
8 changes: 4 additions & 4 deletions config/storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ local:
# Cloudflare tutorial: https://kirillplatonov.com/posts/activestorage-cloudflare-r2/
cloudflare:
service: S3
endpoint: https://<%= Rails.application.credentials[:cloudflare_account_id] %>.r2.cloudflarestorage.com
access_key_id: <%= Rails.application.credentials[:cloudflare_access_key_id] %>
secret_access_key: <%= Rails.application.credentials[:cloudflare_secret_access_key] %>
endpoint: https://<%= Rails.application.credentials[Rails.env.to_sym][:cloudflare][:account_id] %>.r2.cloudflarestorage.com
access_key_id: <%= Rails.application.credentials[Rails.env.to_sym][:cloudflare][:access_key_id] %>
secret_access_key: <%= Rails.application.credentials[Rails.env.to_sym][:cloudflare][:secret_access_key] %>
region: auto
bucket: <%= Rails.application.credentials[:cloudflare_bucket] %>
bucket: <%= Rails.application.credentials[Rails.env.to_sym][:cloudflare][:bucket] %>

# amazon:
# service: S3
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/create_initial_imports.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ desc "Creates the inital import for all users, so all historical payments and me
task create_initial_imports: :environment do
User.find_each do |user|
import = user.imports.create!(
source: Import.sources[:shopify_payments_api]
source: Import.sources[:shopify_payments_api],
status: Import.statuses[:completed]
)
user.metrics.update_all(import_id: import.id) if user.metrics.any?
user.payments.update_all(import_id: import.id) if user.payments.any?
import.completed!
end
end
2 changes: 1 addition & 1 deletion lib/tasks/create_partner_api_credentials.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ task create_partner_api_credentials: :environment do
User.find_each do |user|
if user.partner_api_access_token.present? && user.partner_api_organization_id.present? && !user.partner_api_errors&.include?("Unauthorized")
if user.partner_api_credential.blank?
user.create_partner_api_credential!(
user.create_partner_api_credential(
organization_id: user.partner_api_organization_id,
access_token: user.partner_api_access_token
)
Expand Down

0 comments on commit c7b8ac5

Please sign in to comment.