Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. //INCORRECT VIM
  2. var ServiceRequest = {
  3. // Change the status of given service to given status
  4. changeServiceStatus: function changeServiceStatus (service, status, option) {
  5. request.post(option(service.componentid, status) , function(error) {
  6. if (error) {
  7. return console.error('Got an error:',error);
  8. }
  9. console.log(service.name + ' has changed status to ' + status);
  10. });
  11. },
  12.  
  13. // GET request to grab latest results from given test and update status with the
  14. // statusio request
  15. update: function update (option, service) {
  16. request.get(option(service.endpoint), function(error, response, body) {
  17. if (error) {
  18. return console.error('Got an error:',error);
  19. }
  20. var parsed = JSON.parse(body);
  21.  
  22. //Updates status based on Runscope result
  23. if (parsed.data.result !== 'fail') {
  24. changeServiceStatus(service, 100, options.status_update);
  25. }
  26. else {
  27. changeServiceStatus(service, 500, options.status_update);
  28. }
  29. });
  30. };
  31. }
  32.  
  33.  
  34. //CORRECT WEBSTORM
  35. var ServiceRequest = {
  36. // Change the status of given service to given status
  37. changeServiceStatus: function changeServiceStatus(service, status, option) {
  38. request.post(option(service.componentid, status), function(error) {
  39. if (error) {
  40. return console.error('Got an error:', error);
  41. }
  42. console.log(service.name + ' has changed status to ' + status);
  43. });
  44. },
  45.  
  46. // GET request to grab latest results from given test and update status with the
  47. // statusio request
  48. update: function update(option, service) {
  49. request.get(option(service.endpoint), function(error, response, body) {
  50. if (error) {
  51. return console.error('Got an error:', error);
  52. }
  53. var parsed = JSON.parse(body);
  54.  
  55. //Updates status based on Runscope result
  56. if (parsed.data.result !== 'fail') {
  57. changeServiceStatus(service, 100, options.status_update);
  58. }
  59. else {
  60. changeServiceStatus(service, 500, options.status_update);
  61. }
  62. });
  63. }
  64. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement