<commit_before>﻿namespace MindTouch

open log4net
open MindTouch.Dream
open System.Collections.Generic

module YouTrack =
    type t(hostname : string, username, password) =
        let logger = LogManager.GetLogger typedefof<t>
        let api =  Plug.New(new XUri(hostname)).WithCredentials(username, password)

        member this.IssuesValidator (issues : seq<string>) =
            logger.DebugFormat("IssuesValidator with '{0}'", issues)
            not << Seq.isEmpty <| this.FilterOutNotExistentIssues issues

        member this.FilterOutNotExistentIssues (issues : seq<string>) =
            issues
            |> Seq.filter (fun issue ->
                logger.DebugFormat("Will try to validate '{0}'", issue)
                let validatedIssues = new List<string>()
                try
                    this.IssueExists(issue)
                with
                    | :? DreamResponseException as ex -> logger.DebugFormat("Failed to retrieve issue '{0}', the response was '{1}', with message '{2}'", issue, ex.Response.Status, ex.Message); false
                    | ex -> logger.DebugFormat("Failed to retrieve the issue '{0}', the message was '{1}'", issue, ex.Message); false)

        member this.GetIssue (issue : string) =
            api.At("rest", "issue", issue).WithHeader("Accept", MimeType.JSON.ToString()).Get()

        member this.IssueExists (issue : string) =
            api.At("rest", "issue", issue, "exists").WithHeader("Accept", MimeType.JSON.ToString()).Get().Status = DreamStatus.Ok<commit_msg>Add the issue verification for youtrack<commit_after>﻿namespace MindTouch

open log4net
open MindTouch.Dream
open System.Collections.Generic
open System

module YouTrack =
    type t(hostname : string, username, password) =
        let logger = LogManager.GetLogger typedefof<t>
        let api =  Plug.New(new XUri(hostname)).WithCredentials(username, password)

        member this.IssuesValidator (issues : seq<string>) =
            logger.DebugFormat("IssuesValidator with '{0}'", issues)
            not << Seq.isEmpty <| this.FilterOutNotExistentIssues issues

        member this.FilterOutNotExistentIssues (issues : seq<string>) =
            issues
            |> Seq.filter (fun issue ->
                logger.DebugFormat("Will try to validate '{0}'", issue)
                let validatedIssues = new List<string>()
                try
                    this.IssueExists(issue)
                with
                    | :? DreamResponseException as ex -> logger.DebugFormat("Failed to retrieve issue '{0}', the response was '{1}', with message '{2}'", issue, ex.Response.Status, ex.Message); false
                    | ex -> logger.DebugFormat("Failed to retrieve the issue '{0}', the message was '{1}'", issue, ex.Message); false)

        member this.GetIssue (issue : string) =
            api.At("rest", "issue", issue).WithHeader("Accept", MimeType.JSON.ToString()).Get()

        member this.IssueExists (issue : string) =
            api.At("rest", "issue", issue, "exists").WithHeader("Accept", MimeType.JSON.ToString()).Get().Status = DreamStatus.Ok

        member this.VerifyIssue (issue : string) (release : string) (comment : string) =
            api.At("rest", "issue", issue, "execute")
                .With("command", String.Format("In Release: {0}&State: Verified", release))
                .With("comment", comment)
                .WithHeader("Accept", MimeType.JSON.ToString())
                .Post()
{'fraction_non_alphanumeric': 0.12917146144994246, 'fraction_numerical': 0.004890678941311853, 'mean_word_length': 2.566153846153846, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '3849306', 'n_tokens_mistral': 929, 'n_tokens_neox': 901, 'n_words': 245}