<commit_before>_         = require 'underscore'
sd        = require('sharify').data
Backbone  = require 'backbone'
Item      = require '../models/item.coffee'

module.exports = class Items extends Backbone.Collection
  url: -> "#{sd.ARTSY_URL}/api/v1/set/#{@id}/items"

  model: (attrs, options) ->
    heuristicType = (attrs) ->
      return attrs.item_type if attrs.item_type?
      return 'Profile' if _.has attrs, 'cover_image'
      undefined

    switch heuristicType(attrs)
      when 'FeaturedLink'
        FeaturedLink = require '../models/featured_link.coffee'
        new FeaturedLink attrs, options
      when 'Profile'
        Profile = require '../models/profile.coffee'
        new Profile attrs, options
      else
        new Item attrs, options

  initialize: (models, options) ->
    { @id } = options
    super
<commit_msg>Allow Items collection to be pageable<commit_after>_                   = require 'underscore'
sd                  = require('sharify').data
Backbone            = require 'backbone'
Item                = require '../models/item.coffee'
PageableCollection  = require 'backbone-pageable'

# Collection of Items for an OrderedSet
module.exports = class Items extends PageableCollection
  mode: 'infinite'
  queryParams:
    currentPage:  'page'
    pageSize:     'size'

  state:
    pageSize: 20

  parseLinks: -> { next: -> } # Appease Backbone Pageable

  url: => "#{sd.ARTSY_URL}/api/v1/set/#{@id}/items"

  model: (attrs, options) ->
    # Add types as needed:
    heuristicType = (attrs) ->
      return attrs.item_type if attrs.item_type?
      return 'Profile' if _.has attrs, 'cover_image'

    switch heuristicType(attrs)
      when 'FeaturedLink'
        FeaturedLink = require '../models/featured_link.coffee'
        new FeaturedLink attrs, options
      when 'Profile'
        Profile = require '../models/profile.coffee'
        new Profile attrs, options
      else
        new Item attrs, options

  initialize: (models, options) ->
    { @id } = options
    super

{'fraction_non_alphanumeric': 0.11133102424542306, 'fraction_numerical': 0.0019792182088075212, 'mean_word_length': 2.5043327556325825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2849032', 'n_tokens_mistral': 616, 'n_tokens_neox': 595, 'n_words': 162}