You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.0 KiB

  1. const request = require('request-promise')
  2. const _ = require('lodash')
  3. module.exports = {
  4. Query: {
  5. async contribute() { return {} }
  6. },
  7. ContributeQuery: {
  8. async contributors(obj, args, context, info) {
  9. const resp = await request({
  10. uri: 'https://opencollective.com/wikijs/members/all.json',
  11. json: true
  12. })
  13. return _.filter(resp, c => {
  14. return c.role === 'BACKER' && c.totalAmountDonated > 0
  15. }).map(c => ({
  16. company: _.get(c, 'company', '') || '',
  17. currency: _.get(c, 'currency', 'USD') || 'USD',
  18. description: _.get(c, 'description', '') || '',
  19. id: _.get(c, 'MemberId', 0),
  20. image: _.get(c, 'image', '') || '',
  21. name: _.get(c, 'name', 'Anonymous') || '',
  22. profile: _.get(c, 'profile', ''),
  23. tier: _.toLower(_.get(c, 'tier', 'backers')),
  24. totalDonated: _.get(c, 'totalAmountDonated', 0),
  25. twitter: _.get(c, 'twitter', '') || '',
  26. website: _.get(c, 'website', '') || ''
  27. }))
  28. }
  29. }
  30. }