-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from cliftonmcintosh/meat-and-livestock
Thanks, @cliftonmcintosh. Sorry about the delay.
- Loading branch information
Showing
8 changed files
with
734 additions
and
94 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from collections import OrderedDict | ||
|
||
from wazimap.data.utils import get_stat_data | ||
|
||
MEAT_RECODES = OrderedDict([ | ||
('BUFF', 'Water Buffalo'), | ||
('CHEVON', 'Goat'), | ||
('CHICKEN', 'Chicken'), | ||
('DUCK', 'Duck'), | ||
('MUTTON', 'Mutton'), | ||
('PORK', 'Pork') | ||
]) | ||
|
||
LIVESTOCK_RECODES = OrderedDict([ | ||
('BUFFALOES', 'Water Buffalo'), | ||
('CATTLE', 'Cattle'), | ||
('DUCKS', 'Ducks'), | ||
('FOWL', 'Fowl'), | ||
('GOATS', 'Goats'), | ||
('PIGS', 'Pigs'), | ||
('SHEEP', 'Sheep') | ||
]) | ||
|
||
|
||
def get_agriculture_profile(geo_code, geo_level, session): | ||
agriculture_data = {'area_has_data': False} | ||
|
||
if geo_level != 'vdc': | ||
|
||
meat_dist, total_meat = get_stat_data( | ||
'meat type', geo_level, geo_code, session, | ||
recode=dict(MEAT_RECODES), | ||
percent=False, | ||
order_by='-total') | ||
|
||
livestock_dist, total_livestock = get_stat_data( | ||
'livestock type', geo_level, geo_code, session, | ||
recode=dict(LIVESTOCK_RECODES), | ||
percent=False, | ||
order_by='-total') | ||
|
||
agriculture_data = dict( | ||
is_vdc=False, | ||
area_has_data=True, | ||
meat_distribution=meat_dist, | ||
total_meat={ | ||
'name': 'Metric tons of meat produced', | ||
'values': {'this': total_meat} | ||
}, | ||
livestock_distribution=livestock_dist, | ||
total_livestock={ | ||
'name': 'Number of livestock', | ||
'values': {'this': total_livestock} | ||
}, | ||
) | ||
|
||
return agriculture_data |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<article id="agriculture" class="clearfix"> | ||
{% if agriculture.area_has_data == True %} | ||
<header class="section-contents"> | ||
<h1>Agriculture</h1> | ||
</header> | ||
<div class="section-container"> | ||
<section class="clearfix stat-row"> | ||
<h2><a class="permalink" href="#agriculture-total-livestock" | ||
id="agriculture-total-livestock">Livestock | ||
<i class="fa fa-link"></i></a></h2> | ||
<div class="column-third"> | ||
{% include 'profile/_blocks/_stat_list.html' with stat=agriculture.total_livestock stat_type='number' %} | ||
</div> | ||
<div class="column-two-thirds" | ||
id="chart-histogram-agriculture-livestock_distribution" | ||
data-stat-type="number" | ||
data-chart-title="Livestock"></div> | ||
<small>Source: <br> | ||
<a target="_blank" | ||
href="http://moad.gov.np/public/uploads/1142453195-STATISTIC%20AGRICULTURE%20BOOK_2016.pdf">Ministry | ||
of Agricultural Development Statistical Information on | ||
Nepalese Agriculture 2072/73</a> (PDF) | ||
<br> | ||
</small> | ||
</section> | ||
<section class="clearfix stat-row"> | ||
<h2><a class="permalink" href="#agriculture-total-meat" | ||
id="agriculture-total-meat">Meat Production | ||
<i class="fa fa-link"></i></a></h2> | ||
<div class="column-third"> | ||
{% include 'profile/_blocks/_stat_list.html' with stat=agriculture.total_meat stat_type='number' %} | ||
</div> | ||
<div class="column-two-thirds" | ||
id="chart-histogram-agriculture-meat_distribution" | ||
data-stat-type="number" | ||
data-chart-title="Metric tons of meat produced"></div> | ||
<small>Source: <br> | ||
<a target="_blank" | ||
href="http://moad.gov.np/public/uploads/1142453195-STATISTIC%20AGRICULTURE%20BOOK_2016.pdf">Ministry | ||
of Agricultural Development Statistical Information on | ||
Nepalese Agriculture 2072/73</a> (PDF) | ||
<br> | ||
</small> | ||
</section> | ||
</div> | ||
{% endif %} | ||
</article> |
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