<commit_before>/* eslint-disable */
var sessionId = getUrlParameter('id');

var sessionVue = new Vue({
  el: '#sessionVue',
  data: {
    agenda: null,
    session: null,
    speakers: null,
    favorites: []
  },
  created: function () {
    this.fetchData()
  },
  methods: {
    fetchData: function () {
      var self = this;
      fetch('assets/devfest.json').then(function(response) {
        return response.json();
      }).then(function(json) {
        // get agenda
        self.agenda = json.agenda;
        // get session
        self.session = json.sessions.filter(function(session) {
          return session.id === parseInt(sessionId);
        })[0];
        // get speakers
        if (self.session) {
          var sessionSpeakers = self.session.speakers;
          self.speakers = json.speakers.filter(function(speaker) {
            return sessionSpeakers.indexOf(parseInt(speaker.id)) !== -1 ;
          });
        }
      });

      fetch('api/v1/stars/get?login=ben').then(function(response) {
        return response.json();
      }).then(function(json) {
        self.favorites = json.favs;
      });
    },
    getTrackColor: getTrackColor,
    getTypeColor: getTypeColor,
    isFavorite: function(id, favs) {
      console.log('isFavorite')
      console.log(id)
      console.log(favs)
      if (favs) {
        return favs.indexOf(id) !== -1
      } else {
        return false
      }
    }
  },
  events: {
    'toggle-favorite': function (id, favorite) {
      console.log('event toggle-favorite')
      console.log(id)
      console.log(favorite)
      if (this.favorites) {
        var index = this.favorites.indexOf(id);
        var newFavs = []
        if (index !== -1 && !favorite) {
          newFavs = this.favorites.splice(index, 1);
        } else {
          newFavs = this.favorites.push(id);
        }
        this.favorites = newFavs;
        console.log(newFavs)
        fetch('api/v1/stars/put?login=ben&favs=' + JSON.stringify(newFavs));
      }
    }
  }
});<commit_msg>test 2 gestion des favoris<commit_after>/* eslint-disable */
var sessionId = getUrlParameter('id');

var sessionVue = new Vue({
  el: '#sessionVue',
  data: {
    agenda: null,
    session: null,
    speakers: null,
    favorites: []
  },
  created: function () {
    this.fetchData()
  },
  methods: {
    fetchData: function () {
      var self = this;
      fetch('assets/devfest.json').then(function(response) {
        return response.json();
      }).then(function(json) {
        // get agenda
        self.agenda = json.agenda;
        // get session
        self.session = json.sessions.filter(function(session) {
          return session.id === parseInt(sessionId);
        })[0];
        // get speakers
        if (self.session) {
          var sessionSpeakers = self.session.speakers;
          self.speakers = json.speakers.filter(function(speaker) {
            return sessionSpeakers.indexOf(parseInt(speaker.id)) !== -1 ;
          });
        }
      });

      fetch('api/v1/stars/get?login=ben').then(function(response) {
        return response.json();
      }).then(function(json) {
        self.favorites = json.favs;
      });
    },
    getTrackColor: getTrackColor,
    getTypeColor: getTypeColor,
    isFavorite: function(id, favs) {
      console.log('isFavorite')
      console.log(id)
      console.log(favs)
      if (favs) {
        return favs.indexOf(id) !== -1
      } else {
        return false
      }
    }
  },
  events: {
    'toggle-favorite': function (id, favorite) {
      console.log('event toggle-favorite')
      console.log(id)
      console.log(favorite)
      if (this.favorites) {
        var index = this.favorites.indexOf(id);
        var newFavs = []
        if (index !== -1 && !favorite) {
          newFavs = this.favorites.splice(index, 1);
        } else {
          newFavs = this.favorites.push(id);
        }
        this.favorites = newFavs;
        console.log(newFavs)
        fetch('api/v1/stars/put?login=ben&favs=' + JSON.stringify(newFavs)).then(function(response) {
          console.log(response);
        })
      }
    }
  }
});
{'fraction_non_alphanumeric': 0.1465308102862688, 'fraction_numerical': 0.00363901018922853, 'mean_word_length': 2.0768656716417913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1421313', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1338, 'n_words': 227}