Created
September 25, 2017 14:50
-
-
Save alexandremcosta/351bd7aa0171e27e54f42c9e7ec12e86 to your computer and use it in GitHub Desktop.
component.vue
This file contains hidden or 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
<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