<commit_before>using System;
using System.Text;
using WordPressPCL.Models;

namespace WordPressPCL.Utility
{
    public class QueryBuilder
    {
        private string url;
        public int Page { get; set; }
        public int Per_Page { get; set; }
        public int Offset { get; set; }
        public WordPressPCL.Models.OrderBy OrderBy { get; set; }
        public bool Embed { get; set; }
        public QueryBuilder(string url = null)
        {
            this.url = url;
            this.Page = 1;
            this.Per_Page = 10;
            this.Offset = 0;
            this.OrderBy = OrderBy.date;
            this.Embed = false;
        }

        internal QueryBuilder SetRootUrl(string _url) 
        {
            this.url = _url;
            return this;
        }

        public override string ToString()
        {
            if (String.IsNullOrEmpty(this.url)) return string.Empty;
            else
            {
                StringBuilder sb = new StringBuilder(url);
                if (Page > 1)
                {
                    sb.Append(appendQuery(this.url, PAGE_QUERYSTRING));
                    sb.Append(this.Page);
                }
                if (Embed)
                {
                    sb.Append(appendQuery(this.url, EMBED_QUERYSTRING));
                }
                if (Per_Page != 10)
                {
                    sb.Append(appendQuery(this.url, PER_PAGE_QUERYSTRING));
                    sb.Append(this.Per_Page);
                }
                if (Offset > 0)
                {
                    sb.Append(appendQuery(this.url, OFFSET_QUERYSTRING));
                    sb.Append(this.Offset);
                }
                if (OrderBy != OrderBy.date)
                {
                    sb.Append(appendQuery(this.url, ORDER_BY_QUERYSTRING));
                    sb.Append(Convert.ToInt32(this.OrderBy));
                }
                return sb.ToString();
            }
        }

        private string appendQuery(string url, string queryString)
        {
            return (url.Contains(QUESTION_MARK) ? AMPERSAND : QUESTION_MARK) + queryString + EQUALS_SYMBOL;
        }

        #region constants
        private const string PAGE_QUERYSTRING = "page";
        private const string EMBED_QUERYSTRING = "_embed";        
        private const string PER_PAGE_QUERYSTRING = "per_page";        
        private const string OFFSET_QUERYSTRING = "offset";        
        private const string ORDER_BY_QUERYSTRING = "orderby";
        private const string QUESTION_MARK = "?";
        private const string AMPERSAND = "&";
        private const string EQUALS_SYMBOL = "=";
        #endregion

    }<commit_msg>fixed query-build (& vs ?) issue<commit_after>using System;
using System.Text;
using WordPressPCL.Models;

namespace WordPressPCL.Utility
{
    public class QueryBuilder
    {
        private string url;
        public int Page { get; set; }
        public int Per_Page { get; set; }
        public int Offset { get; set; }
        public WordPressPCL.Models.OrderBy OrderBy { get; set; }
        public bool Embed { get; set; }
        public QueryBuilder(string url = null)
        {
            this.url = url;
            this.Page = 1;
            this.Per_Page = 10;
            this.Offset = 0;
            this.OrderBy = OrderBy.date;
            this.Embed = false;
        }

        internal QueryBuilder SetRootUrl(string _url) 
        {
            this.url = _url;
            return this;
        }

        public override string ToString()
        {
            if (String.IsNullOrEmpty(this.url)) return string.Empty;
            else
            {
                StringBuilder sb = new StringBuilder(url);
                if (Page > 1)
                {
                    sb.Append(appendQuery(this.url, PAGE_QUERYSTRING));
                    sb.Append(this.Page);
                }
                if (Embed)
                {
                    sb.Append(appendQuery(sb.ToString(), EMBED_QUERYSTRING));
                }
                if (Per_Page != 10)
                {
                    sb.Append(appendQuery(sb.ToString(), PER_PAGE_QUERYSTRING));
                    sb.Append(this.Per_Page);
                }
                if (Offset > 0)
                {
                    sb.Append(appendQuery(sb.ToString(), OFFSET_QUERYSTRING));
                    sb.Append(this.Offset);
                }
                if (OrderBy != OrderBy.date)
                {
                    sb.Append(appendQuery(sb.ToString(), ORDER_BY_QUERYSTRING));
                    sb.Append(Convert.ToInt32(this.OrderBy));
                }
                return sb.ToString();
            }
        }

        private string appendQuery(string url, string queryString)
        {
            return (url.Contains(QUESTION_MARK) ? AMPERSAND : QUESTION_MARK) + queryString + EQUALS_SYMBOL;
        }

        #region constants
        private const string PAGE_QUERYSTRING = "page";
        private const string EMBED_QUERYSTRING = "_embed";        
        private const string PER_PAGE_QUERYSTRING = "per_page";        
        private const string OFFSET_QUERYSTRING = "offset";        
        private const string ORDER_BY_QUERYSTRING = "orderby";
        private const string QUESTION_MARK = "?";
        private const string AMPERSAND = "&";
        private const string EQUALS_SYMBOL = "=";
        #endregion

    }
{'fraction_non_alphanumeric': 0.08717195815746008, 'fraction_numerical': 0.0036703982382088455, 'mean_word_length': 1.4019391802556191, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6870387', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1401, 'n_words': 319}