<commit_before>Backbone = require 'backbone'
template = -> require('../../templates/sections/cv.jade') arguments...
sd = require('sharify').data
ArtworkRailView = require '../../../../components/artwork_rail/client/view.coffee'

module.exports = class BiographyView extends Backbone.View

  subViews: []

  initialize: ->
    @listenTo @model.related().shows, 'sync', @render
    @listenTo @model.related().articles, 'sync', @render

  postRender: ->
    @subViews.push new ArtworkRailView
      $el: @$(".artist-artworks-rail")
      collection: @model.related().artworks
      title: "Works by #{@model.get('name')}"
      viewAllUrl: "#{@model.href()}/works"
      imageHeight: 180

  render: ->
    { shows, articles } = @model.related()
    articles = articles.models
    fairBooths = _.map shows.select (show) ->
      show.isFairBooth()

    soloShows = shows.select (show) ->
      show.isSolo() and not show.isFairBooth()

    groupShows = shows.select (show) ->
      show.isGroup() and not show.isFairBooth()

    unless shows.length || articles.length
      @$el.html "<div class='loading-spinner'></div>"
      return this
    @$el.html template { articles, fairBooths, soloShows, groupShows }
    _.defer => @postRender()
    this

  remove: ->
    _.invoke @subViews, 'remove'<commit_msg>call super in remove<commit_after>Backbone = require 'backbone'
template = -> require('../../templates/sections/cv.jade') arguments...
sd = require('sharify').data
ArtworkRailView = require '../../../../components/artwork_rail/client/view.coffee'

module.exports = class BiographyView extends Backbone.View

  subViews: []

  initialize: ->
    @listenTo @model.related().shows, 'sync', @render
    @listenTo @model.related().articles, 'sync', @render

  postRender: ->
    @subViews.push new ArtworkRailView
      $el: @$(".artist-artworks-rail")
      collection: @model.related().artworks
      title: "Works by #{@model.get('name')}"
      viewAllUrl: "#{@model.href()}/works"
      imageHeight: 180

  render: ->
    { shows, articles } = @model.related()
    articles = articles.models
    fairBooths = _.map shows.select (show) ->
      show.isFairBooth()

    soloShows = shows.select (show) ->
      show.isSolo() and not show.isFairBooth()

    groupShows = shows.select (show) ->
      show.isGroup() and not show.isFairBooth()

    unless shows.length || articles.length
      @$el.html "<div class='loading-spinner'></div>"
      return this
    @$el.html template { articles, fairBooths, soloShows, groupShows }
    _.defer => @postRender()
    this

  remove: ->
    super
    _.invoke @subViews, 'remove'
{'fraction_non_alphanumeric': 0.16317194052611514, 'fraction_numerical': 0.002287457110179184, 'mean_word_length': 3.119309262166405, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '2347359', 'n_tokens_mistral': 857, 'n_tokens_neox': 822, 'n_words': 179}