aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts/parts/sidebar_user_stats.coffee
blob: 2b3f078fa71d2c3628066a8b0f95c72a31ef2ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Parts.sidebar_user_stats = ->
  vm = new Vue
    el: ".user-stats"
    data:
      stats: null
      screen_name: Helpers.user_screen_name()
      loading: true
    computed:
      average: ->
        Math.round(this.stats.reactions_count / this.stats.tweets_count * 100) / 100

  superagent
    .get "/i/api/users/stats?screen_name=" + Helpers.user_screen_name()
    .accept "json"
    .end (err, res) ->
      vm.stats = res.body
      vm.loading = false