calls_statistics.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. module.exports.name = 'calls_statistics'
  2. module.exports.description = 'Get statistics about all calls'
  3. // Specify this reporter requires a backup.
  4. // The second parameter to func() is now a backup instead of the path to one.
  5. module.exports.requiresBackup = true
  6. // Specify this reporter supports the promises API for allowing chaining of reports.
  7. module.exports.usesPromises = true
  8. // You can also provide an array of functions instead of using `module.exports.func`.
  9. // These functions *should* be independent ranges to ensure reliable execution
  10. module.exports.functions = {
  11. '>=9.0': function (program, backup, resolve, reject) {
  12. // This function would be called for iOS 10+
  13. backup.getCallsStatistics()
  14. .then((items) => {
  15. var result = program.formatter.format(Object.entries(items[0]), {
  16. program: program,
  17. columns: {
  18. 'Key': el => el[0] + '',
  19. 'Value': el => el[1] + ''
  20. }
  21. })
  22. resolve(result)
  23. })
  24. .catch(reject)
  25. },
  26. '>=1.0,<9.0': function (program, backup, resolve, reject) {
  27. // This function would be called for all iOS 9.
  28. backup.getCallsStatisticsiOS7()
  29. .then((items) => {
  30. var result = program.formatter.format(items, {
  31. program: program,
  32. columns: {
  33. 'Key': el => el.key + '',
  34. 'Value': el => el.value + ''
  35. }
  36. })
  37. resolve(result)
  38. })
  39. .catch(reject)
  40. }
  41. }