Skip to content

Instantly share code, notes, and snippets.

@alexandremcosta
Created September 25, 2017 14:50
Show Gist options
  • Save alexandremcosta/351bd7aa0171e27e54f42c9e7ec12e86 to your computer and use it in GitHub Desktop.
Save alexandremcosta/351bd7aa0171e27e54f42c9e7ec12e86 to your computer and use it in GitHub Desktop.
component.vue
<script>
import YieldService from '@/services/yieldService'
export default {
name: 'portfolio-summary',
props: ['farms'],
methods: {
totalArea: function () {
return this.farms.reduce((a, b) => a + b.areaUsed, 0)
},
totalProduced: function () {
return this.farms.reduce((promisse, farm) => {
return promisse.then((sum) =>
return YieldService.get(farm.product, farm.polygon[0][0], farm.polygon[0][1]).then((value) => {
return sum + farm.areaUsed * value['ton_per_hectare']['avg']
})
)
}, 0)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment