<commit_before>import * as React from "react"
import * as Relay from "react-relay"
import styled from "styled-components"
import Artwork from "./artwork/index"

export interface GridProps extends RelayProps, React.HTMLProps<ArtworkGrid> {
  columnCount?: number,
  sectionMargin?: number,
  itemMargin?: number,
}

export class ArtworkGrid extends React.Component<GridProps, null> {
  public static defaultProps: Partial<GridProps>

  sectionedArtworks() {
    const sectionedArtworks: ArtworkRelayProps[][] = []
    const sectionRatioSums = []
    const artworks = this.props.artworks ? this.props.artworks.edges : []

    for (let i = 0; i < this.props.columnCount; i++) {
      sectionedArtworks.push([])
      sectionRatioSums.push(0)
    }

    artworks.forEach(artworkEdge => {
      const artwork = artworkEdge.node

      // There are artworks without images and other ‘issues’. Like Force we’re just going to reject those for now.
      // See: https://github.com/artsy/eigen/issues/1667
      if (artwork.image) {
        // Find section with lowest *inverted* aspect ratio sum, which is the shortest column.<commit_msg>Add infinite scroll callback<commit_after>import * as React from "react"
import * as Relay from "react-relay"
import styled from "styled-components"
import Artwork from "./artwork/index"

interface Props extends RelayProps, React.HTMLProps<ArtworkGrid> {
  columnCount?: number,
  sectionMargin?: number,
  itemMargin?: number,
  onLoadMore?: any,
}

interface State {
  loading: boolean,
}

export class ArtworkGrid extends React.Component<Props, State> {
  public static defaultProps: Partial<Props>

  componentDidMount() {
    window.onscroll = () => {
      if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
        if (this.props.onLoadMore) {
          this.props.onLoadMore()
        }
      }
    }
  }

  sectionedArtworks() {
    const sectionedArtworks: ArtworkRelayProps[][] = []
    const sectionRatioSums = []
    const artworks = this.props.artworks ? this.props.artworks.edges : []

    for (let i = 0; i < this.props.columnCount; i++) {
      sectionedArtworks.push([])
      sectionRatioSums.push(0)
    }

    artworks.forEach(artworkEdge => {
      const artwork = artworkEdge.node

      // There are artworks without images and other ‘issues’. Like Force we’re just going to reject those for now.
      // See: https://github.com/artsy/eigen/issues/1667
      if (artwork.image) {
        // Find section with lowest *inverted* aspect ratio sum, which is the shortest column.
{'fraction_non_alphanumeric': 0.11045828437132785, 'fraction_numerical': 0.004700352526439483, 'mean_word_length': 3.4034482758620688, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '5085790', 'n_tokens_mistral': 765, 'n_tokens_neox': 752, 'n_words': 212}