<commit_before>import * as Type from 'ember-graphql-adapter/types';
import Ember from 'ember';

class Parser {
  constructor({normalizeCaseFn, parseSelectionSet}) {
    this.agenda = [];
    this.normalizeCaseFn = normalizeCaseFn;
    this.parseSelectionSet = parseSelectionSet;
    this.visited = [];
  }

  parse(model, store, operation, rootField) {
    if (this.parseSelectionSet) {
      this.agenda.push({ name: model.modelName, model, field: rootField });

      while (this.agenda.length > 0) {
        let current = this.agenda.shift();
        this.visited.push(current.name);

        let currentModel = current.model;
        let currentField = current.field;

        currentField.selectionSet.push(new Type.Field('id'));

        /*jshint loopfunc: true */
        currentModel.eachAttribute((attr) => {
          let field = this._buildField(attr);
          currentField.selectionSet.push(field);
        });

        currentModel.eachRelationship((relName, relationship) => {
          let field;
          let { type, options } = relationship;

          if (options.async) {
            field = this._buildAsyncRelationship(relName, relationship);
          } else {
            let relModel = store.modelFor(type);
            if (!this.visited.includes(relName)) {
              field = new Type.Field(
                this.normalizeCaseFn(relName),
                null,
                new Type.ArgumentSet(),
                new Type.SelectionSet()
              );
              this.agenda.push({ name: relName, model: relModel, field });
            }
          }
          if (field) {
            currentField.selectionSet.push(field);
          }
        });
      }
    } else {
      rootField.selectionSet.push(new Type.Field('id'));
    }

    operation.selectionSet.push(rootField);<commit_msg>.includes is not yet widely supported<commit_after>import * as Type from 'ember-graphql-adapter/types';
import Ember from 'ember';

class Parser {
  constructor({normalizeCaseFn, parseSelectionSet}) {
    this.agenda = [];
    this.normalizeCaseFn = normalizeCaseFn;
    this.parseSelectionSet = parseSelectionSet;
    this.visited = [];
  }

  parse(model, store, operation, rootField) {
    if (this.parseSelectionSet) {
      this.agenda.push({ name: model.modelName, model, field: rootField });

      while (this.agenda.length > 0) {
        let current = this.agenda.shift();
        this.visited.push(current.name);

        let currentModel = current.model;
        let currentField = current.field;

        currentField.selectionSet.push(new Type.Field('id'));

        /*jshint loopfunc: true */
        currentModel.eachAttribute((attr) => {
          let field = this._buildField(attr);
          currentField.selectionSet.push(field);
        });

        currentModel.eachRelationship((relName, relationship) => {
          let field;
          let { type, options } = relationship;

          if (options.async) {
            field = this._buildAsyncRelationship(relName, relationship);
          } else {
            let relModel = store.modelFor(type);
            if (this.visited.indexOf(relName) === -1) {
              field = new Type.Field(
                this.normalizeCaseFn(relName),
                null,
                new Type.ArgumentSet(),
                new Type.SelectionSet()
              );
              this.agenda.push({ name: relName, model: relModel, field });
            }
          }
          if (field) {
            currentField.selectionSet.push(field);
          }
        });
      }
    } else {
      rootField.selectionSet.push(new Type.Field('id'));
    }

    operation.selectionSet.push(rootField);
{'fraction_non_alphanumeric': 0.11933821535123407, 'fraction_numerical': 0.0008136696501220504, 'mean_word_length': 2.0733333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1625109', 'n_tokens_mistral': 1028, 'n_tokens_neox': 999, 'n_words': 195}