Created
January 26, 2011 01:46
-
-
Save acuizon/796068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def opts_by_city | |
@city = City.find_by_slug(params[:city_slug]) | |
@for_tax = false | |
@for_street = false | |
@for_search = false | |
@all = [] | |
if params[:geo] =~ /tax/ | |
@geo = params[:geo].split("_").last | |
@for_tax = true | |
@url = @geo.eql?("condos") ? "/taxes/by_development" : "/taxes/by_#{@geo.singularize}" | |
elsif params[:geo] =~ /street_/ | |
@geo = params[:geo].split("_").last | |
@for_street = true | |
elsif params[:geo] =~ /about_/ | |
@geo = params[:geo].split("_").last | |
@for_about = true | |
@url = @geo.eql?("condos") ? "/condos/development" : "/#{@geo}" | |
elsif params[:geo] =~ /search_/ | |
@geo = params[:geo].split("_").last | |
@for_search = true | |
else | |
@geo = params[:geo] | |
@url = @geo.eql?("condos") ? "/condos/development" : "/#{@geo}" | |
end | |
if @city.present? | |
@all = case @geo | |
when "condos" | |
Development.all(:select => "id, name", :conditions => ["city_id = ?", @city.id], :order => "name ASC") | |
when "neighborhoods" | |
@city.neighborhoods.all(:select => "name, slug") | |
when "subdivisions" | |
@city.subdivisions.all(:select => "name, slug", :order => "name ASC") | |
when "tracts" | |
@city.tracts.all(:select => "name, slug", :order => "name ASC") | |
when "streets" | |
Block.find_streets_for_table(@city, :limit => 25) rescue [] | |
end | |
@text = (@all || []).empty? ? "No #{@geo.singularize.capitalize} found" : "Select a #{@geo.singularize.capitalize} in #{@city.name}" | |
else | |
@text = @geo.singularize.capitalize | |
end | |
if @for_search | |
output = @all.map {|a| "<option value = '#{a.formal_street}'>#{a.formal_street}</option>" }.insert(0, "<option>Select Street</option>") | |
else | |
output = @all.map {|a| "<option value = #{@for_street ? streets_group_path(:group => 'cities', :id => @city.slug, :slug => a) : (@for_about ? [@url, a.slug, "about"].join("/") : [@url, a.slug].join("/"))}>#{@geo.eql?("streets") ? a.formal_street : a.name}</option>" }.insert(0, "<option>#{@text}</option>") | |
end | |
if @for_street | |
output << "<option value = #{streets_by_group_path(:group => 'cities', :slug => @city.slug)}>All #{@city.name} Streets</option>" if @city.present? | |
end | |
respond_to do |format| | |
format.js { render :js => output } | |
end | |
end | |
def city_combo | |
@target = @city = City.find_by_slug!(params[:city_id]) | |
@slug = @target.id | |
if params[:school_id] | |
@combo_group = 'schools' | |
@combo = @school = School.find(params[:school_id]) | |
@filter = { :city_id => @city.id, @school.school_grouping.to_sym => @school.id } | |
elsif params[:zip_id] | |
@combo_group = 'zips' | |
@combo = @zip = Zip.find(params[:zip_id]) | |
@filter = { :city_id => @city.id, :zip => @zip.id } | |
end | |
@neighborhoods = Neighborhood.find_faceted(@filter) | |
@subdivisions = Subdivision.find_faceted(@filter) | |
@developments = Development.find_faceted(@filter, :order => "name") | |
@recent_sales = Sale.recent_type_by_combo(:sales, @city, @combo) | |
@recent_foreclosed = Sale.recent_type_by_combo(:foreclosed, @city, @combo, 5) | |
@recent_stories = Story.lnr.send("for_city_and_#{@combo.class.to_s.downcase}", @city, @combo).limit(4) | |
@recent_notes = Note.find_all_by_combo(@city, @combo, {:limit => 7}) | |
@pop_stories = Story.send("for_city_and_#{@combo.class.to_s.downcase}", @city, @combo).most_viewed(15) | |
@most_taxed = Property.for_city(@city).send("for_#{@combo.class.to_s.downcase}", @combo).all(:order => "property_tax DESC", :limit => 10) | |
@streets = Street.send("for_city_and_#{@combo.class.to_s.downcase}", @city, @combo) | |
@listings = Listing.send("for_city_and_#{@combo.class.to_s.downcase}", @city, @combo).all(:limit => 10, :order => 'price DESC') | |
@tag = Tag.find_by_slug('photo_gallery') || Tag.find_by_slug('architecture') | |
if @tag.present? | |
@gallery = @tag.stories("AND stories.city_id = #{@target.id} ORDER BY published DESC LIMIT 1") | |
else | |
@gallery = [] | |
end | |
@schools = School.by_city(@city) | |
@zips = Zip.by_city(@city) | |
@map = create_map(@target) | |
end | |
def about | |
@city = @target = City.find_by_slug!(params[:id]) | |
@total_count = @target.qty_total | |
@cities = if @city.name.match(/#{MARKET}-/) | |
[] | |
else | |
City.by_region(@target.region_id) | |
end | |
@zips = @target.zips | |
@schools = @target.schools | |
@tracts = @target.tracts | |
@politicals = @target.politicals | |
@all_city_count = City.count | |
@region_city_count = @cities.size | |
@all_school_count = School.count | |
@region_school_count = @target.region.respond_to?(:schools) && !@target.region.schools.empty? ? @target.region.schools.size : 0 | |
@counties = @target.counties | |
@county_data = [] | |
@counties.each do |county| | |
count = @target.properties.count(:conditions => ["county_id = ?", county.id]) | |
market_agg = MarketAggregate.counties.period_length('T').find_by_place_id(county.id) | |
@county_data << { | |
:name => county.name, | |
:slug => county_to_param(county.id, county.name), | |
:county_count => count, | |
:county_pct => (count.to_f / @total_count.to_f) * 100, | |
:market_agg => market_agg, | |
:listings_med => county.listings_med | |
} | |
end | |
@single_count = @target.qty_singlefam | |
@single_pct = (@single_count.to_f / @total_count.to_f) * 100 | |
@condo_count = @target.qty_condo_total | |
@condo_pct = (@condo_count.to_f / @total_count.to_f) * 100 | |
@largest_subs = @target.subdivisions.all(:select => "name, qty_total, slug", :order => "qty_total DESC", :limit => 3) | |
@market_agg = MarketAggregate.cities.period_length('T').find_by_place_id(@target.id) | |
return render_404 if @market_agg.blank? | |
@region_market_agg = MarketAggregate.regions.period_length('T').find_by_place_id(@target.region_id) | |
@all_market_agg = MarketAggregate.full.period_length('T').first | |
@median_region_rank = @market_agg.rank('all_med', {:conditions => "place_id IN (#{@cities.collect(&:id).join(',')})"}) if @cities.present? | |
@median_all_rank = @market_agg.rank('all_med') | |
@forerate_region_rank = @market_agg.rank('fore_rate', {:conditions => "place_id IN (#{@cities.collect(&:id).join(',')})"}) if @cities.present? | |
@forerate_all_rank = @market_agg.rank('fore_rate') | |
city_prop_ids = @target.properties.collect(&:id) | |
if Configuration.disable_sale_price? | |
@listings_med = @target.listings_med | |
@listings_region_med = @target.region.respond_to?(:listings_med) ? @target.region.listings_med : nil | |
@listings_region_rank = @target.tax_rank('listings_med', :by_region => true) | |
@listings_all_rank = @target.tax_rank('listings_med') | |
if @listings_med < 1 | |
@last_listings = Listing.find(:all, :conditions => ["property_id IN (?)", city_prop_ids], :order => "last_modified DESC", :limit => 3) | |
end | |
@highest_listings = Listing.find(:all, | |
:conditions => ["property_id IN (?)", city_prop_ids], | |
:order => "price DESC", | |
:limit => 2) | |
med_min, med_max = get_price_range_in_big_decimal(@listings_med) | |
@region_similar_med = City.find(:all, :select => "name, slug, listings_med", | |
:conditions => ["region_id = ? AND id != ? AND listings_med BETWEEN ? AND ?", @target.region_id, @target.id, med_min, med_max], | |
:order => "listings_med DESC", | |
:limit => 5) | |
@all_similar_med = City.find(:all, :select => "name, slug, listings_med", | |
:conditions => ["id != ? AND listings_med BETWEEN ? AND ?", @target.id, med_min, med_max], | |
:order => "listings_med DESC", | |
:limit => 5) | |
@priciest_subs = Subdivision.find(:all, | |
:conditions => ["city_id = ? AND listings_med > 0", @target.id], | |
:order => "listings_med DESC", | |
:limit => 3) | |
@priciest_devs = Development.find(:all, | |
:conditions => ["city_id = ? AND listings_med > 0", @target.id], | |
:order => "listings_med DESC", | |
:limit => 3) | |
else | |
if @market_agg.all_med < 1 | |
@last_sales = Sale.find(:all, :conditions => ["property_id IN (?)", city_prop_ids], :order => "sale_date DESC", :limit => 3) | |
end | |
if @market_agg.fore_rate == 0 | |
@last_fores = Sale.find(:all, :conditions => ["trans_type IN ('FC', 'FS', 'FB', 'FI') AND property_id IN (?)", city_prop_ids], :order => "sale_date DESC", :limit => 3) | |
end | |
@highest_sales = Sale.find(:all, :select => "sale_date, sale_price, buyer, property_id, parcel_id", | |
:conditions => ["city_id = ?", @target.id], | |
:order => "sale_price DESC", | |
:limit => 2) | |
med_min, med_max = get_price_range_in_big_decimal(@market_agg.all_med) | |
@region_similar_med = City.find(:all, :select => "cities.name, cities.slug, market_aggregates.all_med as median_price", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = cities.id AND place_type = 'City' AND period_len = 'T')"], | |
:conditions => ["cities.region_id = ? AND cities.id != ? AND market_aggregates.all_med BETWEEN ? AND ?", @target.region_id, @target.id, med_min, med_max], | |
:order => "median_price DESC", | |
:limit => 5) | |
@all_similar_med = City.find(:all, :select => "cities.name, cities.slug, market_aggregates.all_med as median_price", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = cities.id AND place_type = 'City' AND period_len = 'T')"], | |
:conditions => ["cities.id != ? AND market_aggregates.all_med BETWEEN ? AND ?", @target.id, med_min, med_max], | |
:order => "median_price DESC", | |
:limit => 5) | |
@priciest_subs = Subdivision.find(:all, :select => "subdivisions.name, subdivisions.slug, market_aggregates.all_med", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = subdivisions.id AND place_type = 'Subdivision' AND period_len = 'T')"], | |
:conditions => ["city_id = ?", @target.id], | |
:order => "market_aggregates.all_med DESC", | |
:limit => 3) | |
@priciest_devs = Development.find(:all, :select => "developments.id, developments.name, market_aggregates.all_med", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = developments.id AND market_aggregates.place_type = 'Development' AND market_aggregates.period_len = 'T')"], | |
:conditions => ["developments.city_id = ? AND market_aggregates.all_med > 0", @target.id], | |
:order => "market_aggregates.all_med DESC", | |
:limit => 3) | |
end | |
@largest_devs = Development.find(:all, :select => "id, name, qty_total", | |
:conditions => ["city_id = ?", @target.id], | |
:order => "qty_total DESC", | |
:limit => 3) | |
tax_min, tax_max = get_price_range_in_big_decimal(@target.median_tax) | |
@region_similar_tax = City.find(:all, :select => "name, slug, median_tax", | |
:conditions => ["cities.region_id = ? AND cities.id != ? AND median_tax BETWEEN ? AND ?", @target.region_id, @target.id, tax_min, tax_max], | |
:order => "median_tax DESC", | |
:limit => 5) | |
@all_similar_tax = City.find(:all, :select => "name, slug, median_tax", | |
:conditions => ["cities.id != ? AND median_tax BETWEEN ? AND ?", @target.id, tax_min, tax_max], | |
:order => "median_tax DESC", | |
:limit => 5) | |
@region_similar_fore_rate = City.find(:all, :select => "cities.name, cities.slug, market_aggregates.fore_rate as foreclosure_rate", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = cities.id AND place_type = 'City' AND period_len = 'T')"], | |
:conditions => ["cities.region_id = ? AND cities.id != ? AND market_aggregates.fore_rate BETWEEN ? AND ?", @target.region_id, @target.id, @market_agg.fore_rate - 0.025, @market_agg.fore_rate + 0.025], | |
:order => "foreclosure_rate DESC", | |
:limit => 5) | |
@all_similar_fore_rate = City.find(:all, :select => "cities.name, cities.slug, market_aggregates.fore_rate as foreclosure_rate", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = cities.id AND place_type = 'City' AND period_len = 'T')"], | |
:conditions => ["cities.id != ? AND market_aggregates.fore_rate BETWEEN ? AND ?", @target.id, @market_agg.fore_rate - 0.025, @market_agg.fore_rate + 0.025], | |
:order => "foreclosure_rate DESC", | |
:limit => 5) | |
@school_data = [] | |
@schools.each do |school| | |
count = @target.properties.count(:conditions => ["school_id = ?", school.id]) | |
if Configuration.disable_sale_price? | |
market_agg = school.listings_med | |
med_region_rank = @target.region ? school.tax_rank('listings_med', :by_region => true) : nil | |
med_all_rank = school.tax_rank('listings_med') | |
else | |
school_ids = @target.region.schools.all(:conditions => ["grouping = 1"]).collect(&:id) if @target.region.respond_to?(:schools) | |
market_agg = MarketAggregate.schools.period_length('T').find_by_place_id(school.id) | |
med_region_rank = @target.region.respond_to?(:schools) && !@target.region.schools.empty? && !school_ids.empty? ? market_agg.try(:rank,'all_med', {:type => "School", :conditions => "place_id IN (#{school_ids.join(',')})"}) : nil | |
med_all_rank = market_agg.try(:rank,'all_med', {:type => "School"}).to_i | |
end | |
city_ids = GeoOverlap.find(:all, :select => "overlap_id", :conditions => ["overlap_type = 'City' AND place_type = 'School' AND place_id = ?", school.id]).collect(&:overlap_id) | |
@school_data << { | |
:name => school.name, | |
:slug => school.slug, | |
:school_count => count, | |
:school_pct => (count.to_f / @total_count.to_f) * 100, | |
:cities_served => City.find(:all, :select => "id, name, slug", :conditions => ["id IN (?) AND id != ?", city_ids, @target.id], :order => "name"), | |
:median_price => market_agg, | |
:median_region_rank => med_region_rank, | |
:median_all_rank => med_all_rank, | |
:median_tax => school.median_tax, | |
:tax_region_rank => school.tax_rank('median_tax', :by_region => true), | |
:tax_all_rank => school.tax_rank('median_tax') | |
} | |
end | |
@top_taxpayers = @target.properties.all(:order => "property_tax DESC", :limit => 2) | |
@most_foreclosed = Subdivision.find(:first, :select => "subdivisions.name, subdivisions.slug, market_aggregates.fore_vol", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = subdivisions.id AND place_type = 'Subdivision' AND period_len = 'T')"], | |
:conditions => ["subdivisions.city_id = ?", @target.id], | |
:order => "market_aggregates.fore_vol DESC") | |
@neighborhoods = @target.neighborhoods | |
@neighborhood_data = [] | |
@neighborhoods.each do |neigh| | |
sub_ids = GeoOverlap.find(:all, :select => "overlap_id", :conditions => ["overlap_type = 'Subdivision' AND place_type = 'Neighborhood' AND place_id = ?", neigh.id]).collect(&:overlap_id) | |
dev_ids = GeoOverlap.find(:all, :select => "overlap_id", :conditions => ["overlap_type = 'Development' AND place_type = 'Neighborhood' AND place_id = ?", neigh.id]).collect(&:overlap_id) | |
count = neigh.properties.size | |
single_pct = (neigh.qty_singlefam.to_f / count.to_f) * 100 | |
condo_pct = (neigh.qty_condo_total.to_f / count.to_f) * 100 | |
market_agg = MarketAggregate.neighborhoods.period_length('T').find_by_place_id(neigh.id) | |
if market_agg.nil? | |
next | |
end | |
largest_subs = neigh.subdivisions.all(:conditions => ["qty_total > 0"], :order => "qty_total DESC", :limit => 3) | |
priciest_subs = Subdivision.find(:all, :select => "subdivisions.id, subdivisions.name, subdivisions.slug, market_aggregates.all_med", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = subdivisions.id AND place_type = 'Subdivision' AND period_len = 'T')"], | |
:conditions => ["subdivisions.id IN (?) AND subdivisions.city_id = ? AND market_aggregates.all_med > 0", sub_ids, @target.id], | |
:order => "market_aggregates.all_med DESC", | |
:limit => 3) | |
largest_devs = Development.find(:all, :select => "id, name, qty_total", | |
:conditions => ["id IN (?) AND city_id = ? AND qty_total > 0", dev_ids, @target.id], | |
:order => "developments.qty_total DESC", | |
:limit => 3) | |
priciest_devs = Development.find(:all, :select => "developments.id, developments.name, market_aggregates.all_med", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = developments.id AND place_type = 'Development' AND period_len = 'T')"], | |
:conditions => ["developments.id IN (?) AND developments.city_id = ? AND market_aggregates.all_med > 0", dev_ids, @target.id], | |
:order => "market_aggregates.all_med DESC", | |
:limit => 3) | |
med_min, med_max = get_price_range_in_big_decimal(market_agg.all_med) | |
region_similar_med = Neighborhood.find(:all, :select => "neighborhoods.name, neighborhoods.slug, market_aggregates.all_med as median_price", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = neighborhoods.id AND place_type = 'Neighborhood' AND period_len = 'T')"], | |
:conditions => ["neighborhoods.region_id = ? AND neighborhoods.id != ? AND market_aggregates.all_med BETWEEN ? AND ?", @target.region_id, neigh.id, med_min, med_max], | |
:order => "median_price DESC", | |
:limit => 5) | |
all_similar_med = Neighborhood.find(:all, :select => "neighborhoods.name, neighborhoods.slug, market_aggregates.all_med as median_price", | |
:joins => ["INNER JOIN market_aggregates ON (market_aggregates.place_id = neighborhoods.id AND place_type = 'Neighborhood' AND period_len = 'T')"], | |
:conditions => ["neighborhoods.id != ? AND market_aggregates.all_med BETWEEN ? AND ?", neigh.id, med_min, med_max], | |
:order => "median_price DESC", | |
:limit => 5) | |
school_data = [] | |
@schools.each do |school| | |
s_count = neigh.properties.count(:conditions => ["school_id = ?", school.id]) | |
s_pct = (s_count.to_f / count.to_f) * 100 | |
school_data << { | |
:name => school.name, | |
:slug => school.slug, | |
:prop_count => s_count, | |
:prop_pct => s_pct | |
} | |
end | |
@neighborhood_data << { | |
:name => neigh.name, | |
:slug => neigh.slug, | |
:prop_count => count, | |
:single_pct => single_pct, | |
:condo_pct => condo_pct, | |
:sales => market_agg.all_vol, | |
:median_price => market_agg.all_med, | |
:foreclosures => market_agg.fore_vol, | |
:fore_rate => market_agg.fore_rate, | |
:property_tax => neigh.median_tax, | |
:largest_subs => largest_subs, | |
:priciest_subs => priciest_subs, | |
:largest_devs => largest_devs, | |
:priciest_devs => priciest_devs, | |
:school_data => school_data, | |
:region_similar => region_similar_med, | |
:all_similar => all_similar_med | |
} | |
end | |
@tract_data = [] | |
@tracts.each do |tract| | |
dev_ids = GeoOverlap.find(:all, :select => "overlap_id", :conditions => ["overlap_type = 'Development' AND place_type = 'Tract' AND place_id = ?", tract.id]).collect(&:overlap_id) | |
sub_ids = GeoOverlap.find(:all, :select => "overlap_id", :conditions => ["overlap_id != 0 AND overlap_type = 'Subdivision' AND place_type = 'Tract' AND place_id = ?", tract.id]).collect(&:overlap_id) | |
prop_count = tract.properties.count(:conditions => ["city_id = ?", @target.id]) | |
prop_pct = (prop_count.to_f / @total_count.to_f) * 100 | |
condos = Development.find(:all, :select => "id, name", | |
:conditions => ["id IN (?) AND city_id = ?", dev_ids, @target.id], | |
:order => "name") | |
market_agg = MarketAggregate.tracts.period_length('T').find_by_place_id(tract.id) | |
@tract_data << { | |
:tract => tract, | |
:prop_count => prop_count, | |
:prop_pct => prop_pct, | |
:sub_count => sub_ids.size, | |
:subdivisions => Subdivision.find(:all, :select => "name, slug", :conditions => ["id IN (?)", sub_ids], :order => "qty_total DESC", :limit => 3), | |
:condos => condos, | |
:median_price => market_agg.all_med, | |
:fore_rate => market_agg.fore_rate | |
} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
host_url = window.location.host; | |
url = 'http://' + host_url + '/ajax_proxy/get/http://feeds.sfgate.com/sfgate/rss/feeds/bayarea'; | |
jQuery.get(url, function(data){ | |
$(data).find("item").slice(0, 5).each(function() { | |
$("#sfgatefeed").append('<p><a href="' + $(this).find('link').text() + '">' + $(this).find('title').text() + "</a></p>"); | |
}); | |
$("#sfgatefeed").append('<p align="right"><a href="http://www.sfgate.com/news" target="_new">More</a>'); | |
}, | |
"xml"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:javascript | |
jQuery(document).ready(function() { | |
jQuery('#pass').removeAttr('disabled'); | |
jQuery('#pass_conf').removeAttr('disabled'); | |
jQuery('#pass').keyup(function() { | |
jQuery('#pass_conf').val(""); | |
len = jQuery(this).val().length; | |
if(len < 4) { | |
jQuery("#pass_status").html(""); | |
jQuery("#pass_conf_status").html(""); | |
jQuery('input[name=reset]').attr('disabled', 'disabled'); | |
} | |
else if(len > 4 && jQuery('#pass_conf').val().length==0){ | |
jQuery("#pass_conf_status").html(""); | |
jQuery('input[name=reset]').attr('disabled', 'disabled'); | |
} | |
else { | |
jQuery("#pass_status").html("<img src='../images/yes.png'></img>"); | |
} | |
}); | |
jQuery('#pass_conf').keyup(function() { | |
pass = jQuery('#pass').val(); | |
pass_conf = jQuery(this).val(); | |
if(pass==pass_conf) { | |
jQuery("#pass_conf_status").html("<img src='../images/yes.png'></img>"); | |
jQuery('input[name=reset]').removeAttr('disabled'); | |
} | |
else { | |
jQuery("#pass_conf_status").html(""); | |
jQuery('input[name=reset]').attr('disabled', 'disabled'); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Political < ActiveRecord::Base | |
include MarketAggregateInfo | |
TYPES = [['U.S. House', 'uscongr'], ['State Senate', 'senate'], ['State House', 'rep']] | |
WILDCARD = [] | |
named_scope :by_type, lambda { |type| { | |
:conditions => [ | |
if type == 'other' | |
if MARKET == 'South Florida' | |
"grouping = 1 AND name REGEXP '(county)'" | |
elsif MARKET == 'Chicago' | |
"grouping = 4 AND name REGEXP '(ward)'" | |
else | |
"grouping = 4 AND name != ''" | |
end | |
elsif type == 'uscongr' | |
"(name REGEXP '(us|u.s.) (house|rep)' OR political_type = '#{type}') AND political_type != 'nil'" | |
elsif type == 'rep' | |
"(name REGEXP '([^(us|u.s.)]|state) (house|rep)' OR political_type = '#{type}') AND political_type != 'nil'" | |
elsif type == 'senate' | |
"(name REGEXP '([^(us|u.s.)]|state) (sen|senate)' OR political_type = '#{type}') AND political_type != 'nil'" | |
else | |
"name != ''" | |
end | |
], | |
:order => "name" | |
} } | |
def tax_rank(field, opts = {}) | |
raise ArgumentError unless self.respond_to?(field) | |
cond = "#{field} >= ?" | |
if opts[:by_region] | |
cond = cond + " AND region_id = #{self.region_id}" | |
end | |
if opts[:by_type] | |
cond = cond + " AND political_type = '#{opts[:by_type]}'" | |
end | |
self.class.count(:conditions => [cond, send(field)], :order => "#{field} DESC" ) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- content_for :content_wide do | |
.article | |
%h2.blue.underlined | |
.block_left | |
= "About #{@target.name}" | |
.tright | |
%select.filterSelect= all_cities_options_to_select(:value => "/cities/:slug/about") | |
= render :partial => "shared/about_wikibox_section", :locals => {:hide_cities => true} | |
= "Located in #{@counties.collect {|c| "#{link_to(county_with_state(c.name), county_path(county_to_param(c.id, c.name)))}" }.to_sentence(:last_word_connector => " and ")} #{" and #{MARKET}'s #{link_to @target.region.name, region_show_path(@target.region.slug) }" if @target.region}, #{@target.name} has #{number_with_delimiter(@total_count)} homes." | |
- if @county_data.present? | |
%p | |
= "#{number_to_percentage(@county_data.first[:county_pct], :precision => 2)} (#{number_with_delimiter(@county_data.first[:county_count])}) of the homes in #{@target.name} are located in #{link_to county_with_state(@county_data.first[:name]), county_path(@county_data.first[:slug])}." | |
- if @county_data.size > 1 | |
- @county_data[1..-1].each do |county| | |
= "#{number_to_percentage(county[:county_pct], :precision => 2)} (#{number_with_delimiter(county[:county_count])}) of them are in #{link_to county_with_state(county[:name]), county_path(county[:slug])};" | |
%p | |
- if @single_pct == 0 | |
= "#{number_to_percentage(@condo_pct, :precision => 2)} of all the residential properties in #{@target.name} are condominiums." | |
- elsif @condo_pct == 0 | |
= "#{number_to_percentage(@single_pct, :precision => 2)} of all the residential properties in #{@target.name} are single-family homes." | |
- else | |
= "#{number_to_percentage(@single_pct, :precision => 2)} of all the residential properties in #{@target.name} are single-family homes, #{number_to_percentage(@condo_pct, :precision => 2)} of them are condominiums." | |
%p | |
- if @largest_subs.present? | |
= "The largest subdivisions in #{@target.name} are #{@largest_subs.collect {|s| "#{link_to s.name, subdivision_path(s.slug)} (#{number_with_delimiter(s.qty_total)} homes)" }.to_sentence(:last_word_connector => " and ")}." | |
- if @priciest_subs.present? | |
= "The most expensive ones are #{@priciest_subs.collect {|s| "#{link_to s.name, subdivision_path(s.slug)} (#{number_to_currency((Configuration.disable_sale_price? ? s.listings_med : s.all_med), :precision => 0)})" }.to_sentence(:last_word_connector => " and ")}." | |
%p | |
- if @largest_devs.present? | |
= "The largest condominium developments in #{@target.name} are #{@largest_devs.collect {|d| "#{link_to d.name, development_path(d.slug)} (#{number_with_delimiter(d.qty_total)} homes)" }.to_sentence(:last_word_connector => " and ")}." | |
- if @priciest_devs.present? | |
= "The most expensive ones are #{@priciest_devs.collect {|d| "#{link_to d.name, development_path(d.slug)} (#{number_to_currency((Configuration.disable_sale_price? ? d.listings_med : d.all_med), :precision => 0)})" }.to_sentence(:last_word_connector => " and ")}." | |
= render :partial => "shared/about_home_price_section", :locals => { :text => 'community', :name => @target.class.name.downcase, :url1 => by_city_forsale_path(@target.slug), :url2 => geo_priciest_sales_path(:group => 'cities', :id => @target.slug), :region_count => @region_city_count, :all_count => @all_city_count } | |
= render :partial => "shared/about_school_section" | |
= render :partial => "shared/about_property_tax_section", :locals => { :text => 'community', :name => @target.class.name.downcase, :region_count => @region_city_count, :all_count => @all_city_count } | |
.article | |
%h3.blue.underlined= "Foreclosures in #{@target.name}" | |
- if @market_agg.fore_rate == 0 | |
%p | |
= "There have been no foreclosures in the past 12 months in #{@target.name}." | |
- if @last_fores.present? | |
= "The last recorded foreclosures in #{@target.name} were #{@last_fores.collect {|l| "#{link_to l.property.name, property_path(:parcel_id => l.parcel_id, :slug => l.property.slug)} on #{!l.sale_date.nil? ? l.sale_date.strftime("%b. %e, %Y") : '--'}" }.to_sentence(:last_word_connector => " and ")}." | |
- else | |
- fore_url = "/regions/#{@target.region.slug}/foreclosures/order_by/foreclosure_rate/desc" if @target.region | |
%p | |
= "The foreclosure rate for all homes in #{@target.name} is #{number_to_percentage(100 * @market_agg.fore_rate, :precision => 2)}, ranking #{"#{number_with_delimiter(@forerate_region_rank.ordinalize)} among #{pluralize(number_with_delimiter(@region_city_count), 'community')} in the #{link_to @target.region.name, fore_url} and " if @target.region and @forerate_region_rank} #{number_with_delimiter(@forerate_all_rank.ordinalize)} among all #{pluralize(number_with_delimiter(@all_city_count), 'community')} in #{MARKET} metro covered by BlockShopper." | |
- if @region_similar_fore_rate.present? | |
%p | |
= "In the #{link_to @target.region.name, fore_url}, #{@region_similar_fore_rate.collect {|c| "#{link_to c.name, all_foreclosures_city_path(c.slug)} (#{number_to_percentage(100*c.foreclosure_rate.to_f, :precision => 2)})" }.to_sentence(:last_word_connector => " and ")} are most similar to #{@target.name} in terms of foreclosures." if @target.region | |
- if @all_similar_fore_rate.present? | |
%p | |
= "Across all #{MARKET} metro, #{@all_similar_fore_rate.collect {|c| "#{link_to c.name, all_foreclosures_city_path(c.slug)} (#{number_to_percentage(100*c.foreclosure_rate.to_f, :precision => 2)})" }.to_sentence(:last_word_connector => " and ")} are most similar to #{@target.name}." | |
- if @most_foreclosed.present? | |
%p | |
= "#{@target.name}'s most foreclosed upon subdivision is #{link_to @most_foreclosed.name, all_foreclosures_by_group_path(:group => 'by_subdivision', :slug => @most_foreclosed.slug)}, which has seen #{@most_foreclosed.fore_vol} in the past 12 months. " | |
- if @neighborhood_data.present? | |
.article | |
%h3.blue.underlined= "#{@target.name} neighborhoods" | |
- @neighborhood_data.sort_by {|n| -n[:prop_count] }.each do |n| | |
%dl | |
%dt | |
%p | |
= link_to n[:name], neighborhood_path(n[:slug]) | |
%dd | |
%p | |
= "#{link_to n[:name], neighborhood_path(n[:slug])} includes #{number_with_delimiter(n[:prop_count])} properties," | |
- if n[:single_pct] == 0 | |
= "#{number_to_percentage(n[:condo_pct], :precision => 2)} of which are condominiums." | |
- elsif n[:condo_pct] == 0 | |
= "#{number_to_percentage(n[:single_pct], :precision => 2)} of which are single-family homes." | |
- else | |
= "#{number_to_percentage(n[:single_pct], :precision => 2)} of which are single-family homes and #{number_to_percentage(n[:condo_pct], :precision => 2)} condominiums." | |
%p | |
= "Over the past 12 months, it has seen #{number_with_delimiter(n[:sales])} sales at a median sale price of #{number_to_currency(n[:median_price], :precision => 0)}. #{number_with_delimiter(n[:foreclosures])} of those sales have been foreclosures. #{link_to n[:name], neighborhood_path(n[:slug])}'s foreclosure rate is #{number_to_percentage(100 * n[:fore_rate], :precision => 2)}, its median property tax bill is #{number_to_currency(n[:property_tax], :precision => 0)}." | |
%p | |
- if n[:school_data].present? | |
- nsd = n[:school_data].sort_by {|s| s[:prop_pct].to_f.nan? ? -1 : -s[:prop_pct] } | |
- if nsd.first[:prop_count] > 0 | |
= "#{number_to_percentage(nsd.first[:prop_pct], :precision => 2)} (#{number_with_delimiter(nsd.first[:prop_count])}) of the homes in #{link_to n[:name], neighborhood_path(n[:slug])} are served by #{link_to nsd.first[:name], school_path(nsd.first[:slug])}." | |
- if nsd.size > 1 | |
- nsd[1..-1].each_with_index do |s, i| | |
- if s[:prop_count] > 0 | |
= "#{number_to_percentage(s[:prop_pct], :precision => 2)} (#{number_with_delimiter(s[:prop_count])}) of them are served by #{link_to s[:name], school_path(s[:slug])}." | |
%p | |
- if n[:largest_subs].present? | |
= "The largest subdivisions in #{link_to n[:name], neighborhood_path(n[:slug])} are #{n[:largest_subs].collect {|s| "#{link_to s.name, subdivision_path(s.slug)} (#{number_with_delimiter(s.qty_total)} homes)" }.to_sentence(:last_word_connector => " and ")}." | |
- if n[:priciest_subs].present? | |
= "The most expensive ones are #{n[:priciest_subs].collect {|s| "#{link_to s.name, subdivision_path(s.slug)} (#{number_to_currency(s.all_med, :precision => 0)})" }.to_sentence(:last_word_connector => " and ")}." | |
%p | |
- if n[:largest_devs].present? | |
= "The largest condominium developments in #{link_to n[:name], neighborhood_path(n[:slug])} are #{n[:largest_devs].collect {|d| "#{link_to d.name, development_path(d.slug)} (#{number_with_delimiter(d.qty_total)} homes)" }.to_sentence(:last_word_connector => " and ")}." | |
- if n[:priciest_devs].present? | |
= "The most expensive ones are #{n[:priciest_devs].collect {|d| "#{link_to d.name, development_path(d.slug)} (#{number_to_currency(d.all_med, :precision => 0)})" }.to_sentence(:last_word_connector => " and ")}." | |
%p | |
- if n[:region_similar].present? && @target.region | |
= "In the #{link_to @target.region.name, region_show_path(@target.region.slug)}, the most similarly-priced neighborhoods to #{link_to n[:name], neighborhood_path(n[:slug])} are #{n[:region_similar].collect {|i| "#{link_to i.name, neighborhood_path(i.slug)} (#{number_to_currency(i.median_price, :precision => 0)})" }.to_sentence(:last_word_connector => " and ")}." | |
%p | |
- if n[:all_similar].present? | |
= "Across all #{MARKET} metro, #{n[:all_similar].collect {|i| "#{link_to i.name, neighborhood_path(i.slug)} (#{number_to_currency(i.median_price, :precision => 0)})" }.to_sentence(:last_word_connector => " and ")} are most similar to #{link_to n[:name], neighborhood_path(n[:slug])}." | |
= render :partial => "shared/about_tract_section" | |
.article | |
%h3.blue.underlined | |
- if @target.region | |
= "Communities in #{@target.region.try(:name)}" | |
- else | |
= "Other Communities" | |
%p | |
= "#{@cities.collect {|c| "#{c.id==@target.id ? c.name : link_to(c.name, city_about_path(c.slug))}" }.join(' | ')}" | |
- content_for :right_column do | |
= display_ad('rect', Configuration.market_slug, @target) | |
= top_agents(@target) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment