Skip to content

Commit

Permalink
Merge pull request #349 from TechforgoodCAST/develop
Browse files Browse the repository at this point in the history
Remove profile and resolve #342
  • Loading branch information
suninthesky authored Aug 7, 2017
2 parents 9863554 + 793e92b commit 376b6d7
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 626 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Metrics/LineLength:
- config/**/**
- lib/tasks/**
- app/admin/**
- app/models/profile.rb # TODO: deprecated
- test/**/** # TODO: deprecated

Metrics/MethodLength:
Expand Down
18 changes: 2 additions & 16 deletions app/admin/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
h3 'Non-profits'
h5 'Recipients'
h1 number_with_delimiter Recipient.joins(:users).all.count
h5 'Profiles'
h1 number_with_delimiter Profile.joins(:organisation).all.count
h5 'Proposals'
h1 number_with_delimiter Proposal.all.count
end

span class: 'blank_slate' do
Expand Down Expand Up @@ -52,8 +52,6 @@
h3 'Funders'
h5 'funds_checked'
h1 number_with_delimiter Recipient.sum(:funds_checked)
h5 'Proposals'
h1 number_with_delimiter Proposal.all.count
end

span class: 'blank_slate' do
Expand Down Expand Up @@ -88,12 +86,6 @@ def recipient_count_by_month
Recipient.joins(:users).group_by_month('users.created_at', last: 8).count
end

def profile_count
Profile.where(state: 'complete')
.select(:organisation_id)
.group_by_week(:created_at, week_start: :mon, last: 8).count
end

def unlock_count(count)
Recipient.where(funds_checked: count)
.group_by_week(:created_at, week_start: :mon, last: 8).count
Expand Down Expand Up @@ -208,12 +200,6 @@ def percentage(count, i)
td count[1].positive? ? percentage(count, i) : '-'
end
end
tr do
td 'Profiles'
profile_count.each_with_index do |count, i|
td count[1].positive? ? percentage(count, i) : '-'
end
end
end
end
end
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion app/cells/proposal_form/beneficiaries.slim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

.label.question-padding Which genders?
.question-padding
= f.input :gender, collection: Profile::GENDERS, input_html: { class: 'large uk-width-1-1' }
= f.input :gender, collection: Proposal::GENDERS, input_html: { class: 'large uk-width-1-1' }
= f.error :gender, class: 'error-message'

hr
Expand Down
3 changes: 1 addition & 2 deletions app/cells/proposal_form_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def multiple_countries
end

def load_districts # TODO: refactor
@recipient_country = Country.find_by(alpha2: recipient.country) ||
recipient.profiles.first.countries.first
@recipient_country = Country.find_by alpha2: recipient.country
@district_ids = @recipient_country
.districts.order(:region, :name).map do |d|
[
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/signup_proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ def new
if @proposal # NOTE: if invalid legacy proposal
@proposal.state = 'transferred'
else
@proposal = SignupProposal.new(@recipient).build_or_transfer
@proposal = @recipient.proposals.new(
# TODO: avoid db call
countries: [Country.find_by(alpha2: @recipient.country)]
)
end
end

Expand Down
1 change: 0 additions & 1 deletion app/models/age_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class AgeGroup < ApplicationRecord
].freeze

has_and_belongs_to_many :proposals
has_and_belongs_to_many :profiles # TODO: deprecated

validates :label, :age_from, :age_to, presence: true
validates :label, uniqueness: true
Expand Down
1 change: 0 additions & 1 deletion app/models/beneficiary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class Beneficiary < ApplicationRecord
].freeze

has_and_belongs_to_many :proposals
has_and_belongs_to_many :profiles # TODO: deprecated

validates :label, :sort, :category, presence: true
validates :label, :sort, uniqueness: true
Expand Down
1 change: 0 additions & 1 deletion app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class Country < ApplicationRecord
has_many :districts

has_and_belongs_to_many :proposals
has_and_belongs_to_many :profiles # TODO: deprecated

has_and_belongs_to_many :funds
has_many :funders, -> { distinct }, through: :funds
Expand Down
1 change: 0 additions & 1 deletion app/models/district.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class District < ApplicationRecord
belongs_to :country

has_and_belongs_to_many :proposals
has_and_belongs_to_many :profiles # TODO: deprecated

has_and_belongs_to_many :funds
has_many :funders, -> { distinct }, through: :funds
Expand Down
1 change: 0 additions & 1 deletion app/models/implementation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Implementation < ApplicationRecord
].freeze

has_and_belongs_to_many :proposals
has_and_belongs_to_many :profiles # TODO: deprecated

validates :label, presence: true
end
3 changes: 0 additions & 3 deletions app/models/implementor.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/models/organisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class Organisation < ApplicationRecord
has_one :subscription, dependent: :destroy
has_many :users, dependent: :destroy

has_many :profiles, dependent: :destroy # TODO: deprecated

geocoded_by :search_address
after_validation :geocode,
if: :street_address_changed?,
Expand Down
120 changes: 0 additions & 120 deletions app/models/profile.rb

This file was deleted.

100 changes: 0 additions & 100 deletions app/services/signup_proposal.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/metrics/_daily_chart.html.haml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
= line_chart [{name: "Users", data: User.user.group_by_day(:created_at, week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "Non-profits", data: Recipient.joins(:users).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "Profiles", data: Profile.group_by_day(:created_at, week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "1 unlock", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 1).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "2 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 2).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "3 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 3).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "Proposals", data: Proposal.all.group_by_day('created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}], height: '400px'
= line_chart [{name: "Users", data: User.user.group_by_day(:created_at, week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "Non-profits", data: Recipient.joins(:users).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "1 unlock", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 1).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "2 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 2).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "3 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 3).group_by_day('users.created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}, {name: "Proposals", data: Proposal.all.group_by_day('created_at', week_start: :mon, range: 2.weeks.ago..Time.now).count}], height: '400px'
2 changes: 1 addition & 1 deletion app/views/metrics/_weekly_chart.html.haml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
= line_chart [{name: "Users", data: User.user.group_by_week(:created_at, week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "Non-profits", data: Recipient.joins(:users).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "Profiles", data: Profile.group_by_week(:created_at, week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "1 unlock", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 1).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "2 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 2).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "3 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 3).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "Proposals", data: Proposal.all.group_by_week('created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}], height: '400px'
= line_chart [{name: "Users", data: User.user.group_by_week(:created_at, week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "Non-profits", data: Recipient.joins(:users).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "1 unlock", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 1).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "2 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 2).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "3 unlocks", data: Recipient.joins(:users).where('recipient_funder_accesses_count = ?', 3).group_by_week('users.created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}, {name: "Proposals", data: Proposal.all.group_by_week('created_at', week_start: :mon, range: 12.weeks.ago..Time.now).count}], height: '400px'
1 change: 0 additions & 1 deletion app/views/signup_recipients/edit.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
= stylesheet_link_tag 'chosen'
= stylesheet_link_tag 'overrides/chosen_overrides'
= javascript_include_tag 'signup'
= javascript_include_tag 'profiles'

= render partial: 'signup/subnav', locals: { current_step: 0 }

Expand Down
1 change: 0 additions & 1 deletion app/views/signup_recipients/new.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
= stylesheet_link_tag 'chosen'
= stylesheet_link_tag 'overrides/chosen_overrides'
= javascript_include_tag 'signup'
= javascript_include_tag 'profiles'

:javascript
mixpanel.track("View New Organisation Page");
Expand Down
1 change: 0 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Application < Rails::Application
organisations.js
pages.js
password_resets.js
profiles.js
proposals.js
recipients.js
signup.js
Expand Down
Loading

0 comments on commit 376b6d7

Please sign in to comment.