<commit_before>import React from 'react';
import apiClient from 'panoptes-client/lib/api-client';
import HomePageSection from './generic-section';
import { Link } from 'react-router';
import ProjectCard from '../../partials/project-card';

const MyBuildsSection = React.createClass({
  propTypes: {
    onClose: React.PropTypes.func.isRequired,
  },

  contextTypes: {
    user: React.PropTypes.object.isRequired,
  },

  getDefaultProps() {
    return {
      onClose: () => {},
    };
  },

  getInitialState() {
    return {
      loading: false,
      error: null,
      projects: [],
      avatars: {},
    };
  },

  componentDidMount() {
    this.fetchProjects(this.context.user);
  },

  componentWillReceiveProps(nextProps, nextContext) {
    if (nextContext.user !== this.context.user) {
      this.fetchProjects(nextContext.user);
    }
  },

  fetchProjects() {
    this.setState({
      loading: true,
      error: null,
      avatars: {},
    });

    apiClient.type('projects').get({
      current_user_roles: ['owner'],
      sort: '-updated_at',
    })
    .then((projects) => {
      this.setState({
        projects,
      });
    })
    .catch((error) => {
      this.setState({
        error: error,
        projects: [],
      });
    })
    .then(() => {
      this.setState({
        loading: false,
      });
    });
  },

  render() {
    return (
      <HomePageSection
        title="My builds"
        loading={this.state.loading}
        error={this.state.error}
        onClose={this.props.onClose}
      >
        <div className="home-page-section__sub-header">
          <Link to="/lab" className="outlined-button">See all</Link>
        </div>

        {this.state.projects.length === 0 && (
          <div className="home-page-section__header-label">
            <p> You have no builds. </p>
          </div>
        )}

        <div className="project-card-list">
          {this.state.projects.map((project) => {
            return <ProjectCard key={project.id} project={project} href={`/lab/${project.id}`} />;
          })}
        </div>
      </HomePageSection>
    );
  },
});

export default MyBuildsSection;
<commit_msg>use the linked avatar resource for my projects <commit_after>import React from 'react';
import apiClient from 'panoptes-client/lib/api-client';
import HomePageSection from './generic-section';
import { Link } from 'react-router';
import ProjectCard from '../../partials/project-card';

const MyBuildsSection = React.createClass({
  propTypes: {
    onClose: React.PropTypes.func.isRequired,
  },

  contextTypes: {
    user: React.PropTypes.object.isRequired,
  },

  getDefaultProps() {
    return {
      onClose: () => {},
    };
  },

  getInitialState() {
    return {
      loading: false,
      error: null,
      projects: [],
      avatars: {},
    };
  },

  componentDidMount() {
    this.fetchProjects(this.context.user);
  },

  componentWillReceiveProps(nextProps, nextContext) {
    if (nextContext.user !== this.context.user) {
      this.fetchProjects(nextContext.user);
    }
  },

  fetchProjects() {
    this.setState({
      loading: true,
      error: null,
      avatars: {},
    });

    apiClient.type('projects').get({
      current_user_roles: ['owner'],
      sort: '-updated_at',
      include: ['avatar']
    })
    .then((projects) => {
      this.setState({
        projects,
      });
      projects.map((project) => {
        if (project.links.avatar.id) {
          apiClient.type('avatars').get(project.links.avatar.id)
          .catch(() => {
            return null;
          })
          .then((avatar) => {
            const newState = Object.assign({}, this.state.avatars);
            newState[project.id] = avatar;
            this.setState({
              avatars: newState
            });
          });
        }
      });
    })
    .catch((error) => {
      this.setState({
        error: error,
        projects: [],
      });
    })
    .then(() => {
      this.setState({
        loading: false,
      });
    });
  },

  render() {
    return (
      <HomePageSection
        title="My builds"
        loading={this.state.loading}
        error={this.state.error}
        onClose={this.props.onClose}
      >
        <div className="home-page-section__sub-header">
          <Link to="/lab" className="outlined-button">See all</Link>
        </div>

        {this.state.projects.length === 0 && (
          <div className="home-page-section__header-label">
            <p> You have no builds. </p>
          </div>
        )}

        <div className="project-card-list">
          {this.state.projects.map((project) => {
            const avatarSrc = !!this.state.avatars[project.id] ? this.state.avatars[project.id].src : null;
            return <ProjectCard key={project.id} project={project} imageSrc={avatarSrc} href={`/lab/${project.id}`} />;
          })}
        </div>
      </HomePageSection>
    );
  },
});

export default MyBuildsSection;

{'fraction_non_alphanumeric': 0.16160193197826525, 'fraction_numerical': 0.0004024954719259408, 'mean_word_length': 2.1023720349563044, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 42, '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': '7374937', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1510, 'n_words': 255}