<commit_before>using System;
using System.Linq;
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Services;

namespace JsonApiDotNetCore.Internal.Query
{
    public class RelatedAttrFilterQuery : BaseFilterQuery
    {
        private readonly IJsonApiContext _jsonApiContext;
        
        public RelatedAttrFilterQuery(
            IJsonApiContext jsonApiCopntext,
            FilterQuery filterQuery)
        {
            _jsonApiContext = jsonApiCopntext;
            var filterQueryAttribute = filterQuery.Attribute;
            var relationshipSubSpans = new SpanSplitter(ref filterQueryAttribute, '.');
            var relationship1 = relationshipSubSpans[0].ToString();
            var relationship2 = relationshipSubSpans[1].ToString();
            var relationship = GetRelationship(relationshipSubSpans[0].ToString());
            if (relationship == null)
                throw new JsonApiException(400, $"{relationship2} is not a valid relationship on {relationship1}.");

            var attribute = GetAttribute(relationship, relationship2);

            if (attribute == null)
                throw new JsonApiException(400, $"'{filterQuery.Attribute}' is not a valid attribute.");

            if (attribute.IsFilterable == false)
                throw new JsonApiException(400, $"Filter is not allowed for attribute '{attribute.PublicAttributeName}'.");

            FilteredRelationship = relationship;<commit_msg>#258 Removes extra ToString() on the span and fixes naming to be more accurate<commit_after>using System;
using System.Linq;
using JsonApiDotNetCore.Models;
using JsonApiDotNetCore.Services;

namespace JsonApiDotNetCore.Internal.Query
{
    public class RelatedAttrFilterQuery : BaseFilterQuery
    {
        private readonly IJsonApiContext _jsonApiContext;
        
        public RelatedAttrFilterQuery(
            IJsonApiContext jsonApiCopntext,
            FilterQuery filterQuery)
        {
            _jsonApiContext = jsonApiCopntext;
            var filterQueryAttribute = filterQuery.Attribute;
            var filterQuerySubSpans = new SpanSplitter(ref filterQueryAttribute, '.');
            var subSpan1 = filterQuerySubSpans[0].ToString();
            var subSpan2 = filterQuerySubSpans[1].ToString();
            var relationship = GetRelationship(subSpan1);
            if (relationship == null)
                throw new JsonApiException(400, $"{subSpan2} is not a valid relationship on {subSpan1}.");

            var attribute = GetAttribute(relationship, subSpan2);

            if (attribute == null)
                throw new JsonApiException(400, $"'{filterQuery.Attribute}' is not a valid attribute.");

            if (attribute.IsFilterable == false)
                throw new JsonApiException(400, $"Filter is not allowed for attribute '{attribute.PublicAttributeName}'.");

            FilteredRelationship = relationship;
{'fraction_non_alphanumeric': 0.07806563039723662, 'fraction_numerical': 0.012780656303972366, 'mean_word_length': 2.8561917443408786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2141837', 'n_tokens_mistral': 722, 'n_tokens_neox': 687, 'n_words': 188}