Skip to content

Commit

Permalink
Loans: signing_date not null, Divisions: second level
Browse files Browse the repository at this point in the history
Loans: signing_date not null, Divisions: second level
  • Loading branch information
pol-ak committed May 28, 2024
1 parent c181939 commit eed6912
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/controllers/api/v1/divisions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module Api
module V1
class DivisionsController < ApplicationController
def index
seed_commons_id = Division.find_by(name: "Seed Commons").id
divisions = Division.includes(address: [:country, :geo_state]).where(parent_id: seed_commons_id, public: true)
#seed_commons_id = Division.find_by(name: "Seed Commons").id
seed_commons_division_ids = Division.find_by(name: "Seed Commons").self_and_descendants.pluck(:id)
#divisions = Division.includes(address: [:country, :geo_state]).where(parent_id: seed_commons_id, public: true)
divisions = Division.includes(address: [:country, :geo_state]).where(parent_id: seed_commons_division_ids, public: true)
render json: divisions.map { |division| format_division(division) }
end

Expand Down
6 changes: 5 additions & 1 deletion app/controllers/api/v1/loans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ module V1
class LoansController < ApplicationController
def index
seed_commons_division_ids = Division.find_by(name: "Seed Commons").descendants.where(public: true).pluck(:id)
loans = Loan.includes(:division, organization: [address: [:country, :geo_state]]).where(division_id: seed_commons_division_ids).where.not(public_level_value: "hidden")
#loans = Loan.includes(:division, organization: [address: [:country, :geo_state]]).where(division_id: seed_commons_division_ids).where.not(public_level_value: "hidden")
loans = Loan.includes(:division, organization: [address: [:country, :geo_state]])
.where(division_id: seed_commons_division_ids)
.where.not(public_level_value: "hidden")
.where.not(signing_date: nil)
render json: loans.map { |loan| format_loan(loan) }
end

Expand Down

0 comments on commit eed6912

Please sign in to comment.