Skip to content

Instantly share code, notes, and snippets.

@nwoow
Created September 6, 2018 06:39
Show Gist options
  • Save nwoow/4cabf4d8dbd2012c7ee2c0b0675d619c to your computer and use it in GitHub Desktop.
Save nwoow/4cabf4d8dbd2012c7ee2c0b0675d619c to your computer and use it in GitHub Desktop.
def test
ji = [:Sector, :'2011-12', :'2012-13', :'2013-14', :'2014-15', :'2015-16', :'2016-17']
rain_fall_type = params[:rain_fall_type]
views = params[:views]
year = params[:year]
compare = params[:compare]
search = params[:search]
ji1 = [:Sector, :'2011-12', :'2012-13', :'2013-14', :'2014-15', :'2015-16', :'2016-17']
jip = [:'2011-12', :'2012-13', :'2013-14', :'2014-15', :'2015-16', :'2016-17']
if search == 'Primary'
if rain_fall_type == "Agriculture, Forestry and Fishing"
if compare == "None"
search = "None"
rain_fall_type
elsif compare == "All"
rain_fall_type = compare
data = [
"Crops",
"Livestock",
"Forestry and Logging",
"Fishing and Aquaculture",
]
else
search = "None"
rain_fall_type = compare
end
elsif rain_fall_type == "None"
rain_fall_type
data = [
"Primary",
]
else
data = [
"Agriculture, Forestry and Fishing",
"Mining and Quarrying",
]
end
elsif search == 'Secondary'
if rain_fall_type == "None"
rain_fall_type
data = [
"Secondary",
]
else
data = [
"Manufacturing",
"Electricity and Utilitiy Services",
"Construction",
]
end
elsif search == 'Tertiary'
if rain_fall_type == "Trade and Hospitality"
if compare == "None"
search = "None"
rain_fall_type
elsif compare == "All"
rain_fall_type = compare
data = [
"Trade and Hospitality",
"Trade and Repair Services",
]
else
search = "None"
rain_fall_type = compare
data = [
"Trade and Hospitality",
"Trade and Repair Services",
]
end
elsif rain_fall_type == "Transport and Communication"
if compare == "None"
rain_fall_type
elsif compare == "All"
rain_fall_type = compare
data = [
"Railways",
"Road Transport",
"Water Transport",
"Air Transport",
"Services incidental to transport",
"Storage",
"Communication and Broadcasting",
]
else
rain_fall_type = compare
end
elsif rain_fall_type == "None"
rain_fall_type
data = [
"Tertiary",
]
else
data = [
"Trade and Hospitality",
"Transport and Communication",
"Financial Services",
"Real Estate Services",
"Public Administration",
"Other Services",
]
end
elsif search == 'All'
if rain_fall_type == "Agriculture, Forestry and Fishing"
if compare == "None"
search = "None"
rain_fall_type
elsif compare == "All"
rain_fall_type = compare
data = [
"Crops",
"Livestock",
"Forestry and Logging",
"Fishing and Aquaculture",
]
elsif rain_fall_type == "None"
rain_fall_type
data = [
"Tertiary",
"Secondary",
"Primary"
]
else
search = "None"
rain_fall_type = compare
data = [
"Agriculture, Forestry and Fishing",
"Mining and Quarrying",
"Manufacturing",
"Electricity and Utilitiy Services",
"Construction",
"Trade and Hospitality",
"Transport and Communication",
"Financial Services",
"Real Estate Services",
"Public Administration",
"Other Services",
"Tertiary",
"Total GSVA at basic prices",
]
end
elsif rain_fall_type == "Trade and Hospitality"
if compare == "None"
search = "None"
rain_fall_type
elsif compare == "All"
rain_fall_type = compare
data = [
"Trade and Hospitality",
"Trade and Repair Services",
]
else
search = "None"
rain_fall_type = compare
data = [
"Trade and Hospitality",
"Trade and Repair Services",
]
end
elsif rain_fall_type == "Transport and Communication"
if compare == "None"
rain_fall_type
elsif compare == "All"
rain_fall_type = compare
data = [
"Railways",
"Road Transport",
"Water Transport",
"Air Transport",
"Services incidental to transport",
"Storage",
"Communication and Broadcasting",
]
else
rain_fall_type = compare
end
elsif rain_fall_type == "None"
rain_fall_type
data = [
"Tertiary",
"Secondary",
"Primary"
]
else
data = [
"Agriculture, Forestry and Fishing",
"Mining and Quarrying",
"Manufacturing",
"Electricity and Utilitiy Services",
"Construction",
"Trade and Hospitality",
"Transport and Communication",
"Financial Services",
"Real Estate Services",
"Public Administration",
"Other Services",
"Tertiary",
"Total GSVA at basic prices",
]
end
end
if rain_fall_type || views
if views == "Map View"
l = rain_fall_type.gsub(" ","")
if rain_fall_type == "All"
b = AnnualStateDomesticProduct3.map_search("All",compare,year,rain_fall_type)
u = "Total"
a = AnnualStateDomesticProduct3.map(b,params[:year],rain_fall_type,views)
else
b = AnnualStateDomesticProduct3.map_search(params[:search],compare,year,rain_fall_type)
a = AnnualStateDomesticProduct3.map(b,rain_fall_type,year,ji)
end
elsif views == "Table"
b = AnnualStateDomesticProduct3.search(params[:search],compare,year,rain_fall_type)
a = AnnualStateDomesticProduct3.table(b,rain_fall_type,year,ji1,compare,search,data)
else
@AnnualStateDomesticProduct3s = AnnualStateDomesticProduct3.search(params[:search],compare,year,rain_fall_type)
a = AnnualStateDomesticProduct3.query(@AnnualStateDomesticProduct3s,params[:year],rain_fall_type,views,ji,compare,search,data,jip)
end
respond_to do |format|
format.html { render json: a }
end
else
respond_to do |format|
format.html { render json: "error"}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment