dataset.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.Dataset = DS.Model.extend({
  20. name: DS.attr('string'),
  21. sourceClusterName: DS.attr('string'),
  22. targetClusterName: DS.attr('string'),
  23. sourceDir: DS.attr('string'),
  24. targetDir: DS.attr('string'),
  25. datasetJobs: DS.hasMany('App.DataSetJob'),
  26. status: function () {
  27. var jobs = this.get('datasetJobs').toArray();
  28. if (jobs.someProperty('status', 'RUNNING')) {
  29. return 'RUNNING';
  30. } else if (jobs.someProperty('status', 'SUSPENDED')) {
  31. return 'SUSPENDED';
  32. } else {
  33. return 'SCHEDULED';
  34. }
  35. }.property('datasetJobs', 'datasetJobs.@each.status'),
  36. statusFormatted: function (){
  37. return this.get('status').toLowerCase().capitalize();
  38. }.property('status'),
  39. isRunning: function () {
  40. return this.get('status') === 'RUNNING';
  41. }.property('status'),
  42. isSuspended: function () {
  43. return this.get('status') === 'SUSPENDED';
  44. }.property('status'),
  45. isScheduled: function () {
  46. return this.get('status') === 'SCHEDULED';
  47. }.property('status'),
  48. //Last succeeded date. Will be calculated later.
  49. lastSucceededDate: function () {
  50. return '';
  51. }.property(),
  52. //Next instance to run. Will be calculated later.
  53. nextInstance: function () {
  54. return '';
  55. }.property(),
  56. //Class name for dataset health status indicator
  57. healthClass: function () {
  58. var jobs = this.get('datasetJobs').toArray();
  59. jobs = jobs.filterProperty('status', 'FAILED').concat(jobs.filterProperty('status', 'SUCCESSFUL'));
  60. jobs.sort(function (a, b) {
  61. return a.get('endDate') - b.get('endDate');
  62. });
  63. return jobs.length && jobs[0].get('status') === 'FAILED' ? 'health-status-DEAD-RED' : 'health-status-LIVE';
  64. }.property('datasetJobs', 'datasetJobs.@each.status')
  65. });
  66. App.Dataset.FIXTURES = [];