define([
  'extensions/views/view',
  'common/views/visualisations/multi_stat_item/single_stat_item/headline',
  'common/views/visualisations/multi_stat_item/single_stat_item/delta',
  'stache!common/templates/visualisations/user-satisfaction',
  'Mustache'
],
function (View, HeadlineItemView, DeltaItemView, template) {
  var UserSatisfactionView = View.extend({

    template: template,
    sparkline: true,

    initialize: function () {

      View.prototype.initialize.apply(this, arguments);

      var valueAttr = this.collection.options.valueAttr;
      var percentAttr = valueAttr + '_percent';
 
      this.stat = {
        'attr': percentAttr
      };
      
      this.collection.first().get('values').each(function (d) {
        var val = d.get(valueAttr);
        var percent = this.getScoreAsPercentage(val);
        d.set(percentAttr, percent);
      }, this);

    },

    getScoreAsPercentage: function (score) {
      var maxScore = 5, minScore = 1;
      return (maxScore - score) / (maxScore - minScore);
    },

    
    views: function () {
      return {
        '.single-stat-headline': {
          view: HeadlineItemView,
          options: function () {
            return {
              stat: this.stat,
              valueAttr: this.stat.attr,
              timeAttr: '_timestamp',
              isPercent: true
            };
          }
        },
        '.single-stat-delta': {
          view: DeltaItemView,
          options: function () {
            return {
              stat: this.stat,
              collection: this.collection,
              valueAttr: this.stat.attr,
              timeAttr: '_timestamp',
              delta: 1,
              deltaPeriod: 'months'
            };
          }
        }
      };

    }

  });

  return UserSatisfactionView;

});

@@ -240,22 +240,8 @@
 ion'
-,%0A  'Mustache'
 %0A%5D,%0A
@@ -372,29 +372,8 @@
 ate,
-%0A    sparkline: true,
 %0A%0A  

Remove unused options from user satisfaction view