浏览代码

Flatten application hash

Instead of properties hashes within application hash we now prepends
the hash keys so the values are accessible at `property_1_uprn`...
pull/38/head
Graeme Porteous 5 年前
父节点
当前提交
779f0f8d91
共有 1 个文件被更改,包括 15 次插入4 次删除
  1. +15
    -4
      lib/uk_planning_scraper/application.rb

+ 15
- 4
lib/uk_planning_scraper/application.rb 查看文件

@@ -22,7 +22,7 @@ module UKPlanningScraper
attr_accessor :properties

def to_hash
{
base = {
scraped_at: @scraped_at,
authority_name: @authority_name,
council_reference: @council_reference,
@@ -39,10 +39,21 @@ module UKPlanningScraper
alternative_reference: @alternative_reference,
appeal_status: @appeal_status,
appeal_decision: @appeal_decision,
property_count: @property_count,
property_detail_urls: @property_detail_urls,
properties: @properties
property_count: @property_count
}

@property_detail_urls.each_with_index do |url, idx|
base["property_detail_url_#{idx + 1}".to_sym] = url
end if @property_detail_urls

@properties.each_with_index do |property, idx|
property_hash = property.to_hash
property_hash.transform_keys! { |k| "property_#{idx + 1}_#{k}".to_sym }

base.merge!(property_hash)
end if @properties

base
end

def valid?


正在加载...
取消
保存