<commit_before>package lt.markmerkk

import lt.markmerkk.UserSettings
import lt.markmerkk.utils.LogFormatters
import net.rcarz.jiraclient.Issue
import net.rcarz.jiraclient.JiraException
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import rx.Observable
import rx.Subscriber

/**
 * Created by mariusmerkevicius on 1/23/16.
 */
class JiraSearchSubscriberImpl(
        private val jiraClientProvider: JiraClientProvider,
        private val userSettings: UserSettings,
        private val searchFields: String = "*all",
        private var jql: String = ""
) : JiraSearchSubscriber, Observable.OnSubscribe<Issue.SearchResult> {

    override fun call(subscriber: Subscriber<in Issue.SearchResult>) {
        try {
            if (jql.isNullOrEmpty()) throw IllegalArgumentException("JQL is empty!")
            logger.info("Doing search: " + jql)
            var startAt = 0
            val max = 50
            var total: Int
            do {
                if (subscriber.isUnsubscribed)
                    break

                val sr = jiraClientProvider.client().searchIssues(jql, searchFields, max, startAt)
                if (sr == null) throw IllegalStateException("result is empty")
                if (sr.issues == null) throw IllegalStateException("result is empty")
                if (sr.issues.size == 0) throw IllegalStateException("result is empty")
                logger.info("Found ${sr.issues.size} issues.")
                subscriber.onNext(sr)

                startAt += sr.max
                total = sr.total
            } while (startAt < total)
            subscriber.onCompleted()
        } catch (e: IllegalStateException) {
            logger.info("Jira search ${e.message}")
            subscriber.onCompleted()
        } catch (e: IllegalArgumentException) {
            logger.error("Jira search error: ${e.message}")
            subscriber.onError(e)
        } catch (e: JiraException) {
            logger.error("Jira error: ${e.message}")
            subscriber.onError(e)
        }
    }

    override fun workedIssuesObservable(start: Long, end: Long): Observable<Issue.SearchResult> {
        return Observable.create(
                JiraSearchSubscriberImpl(
                        jiraClientProvider = jiraClientProvider,
                        userSettings = userSettings,
                        jql = jqlForWorkIssuesFromDateObservable(start, end),
                        searchFields = "*all"
                )
        )
    }

    override fun userIssuesObservable(): Observable<Issue.SearchResult> {
        return Observable.create(
                JiraSearchSubscriberImpl(
                        jiraClientProvider = jiraClientProvider,
                        userSettings = userSettings,
                        jql = userSettings.issueJql,
                        searchFields = "summary,project,created,updated"
                )
        )
    }

    fun jqlForWorkIssuesFromDateObservable(
            start: Long,
            end: Long
    ): String {
        val startFormat = LogFormatters.shortFormatDate.print(start)
        val endFormat = LogFormatters.shortFormatDate.print(end)
        return "(worklogDate >= \"$startFormat\" && worklogDate <= \"$endFormat\")" +
                " AND " +
                "(assignee = currentUser() OR reporter = currentUser() OR watcher = currentUser())"
    }

    companion object {
        private val logger: Logger = LoggerFactory.getLogger("JiraSearchJQL")
    }

}
<commit_msg>Finish up on subtask extended info<commit_after>package lt.markmerkk

import lt.markmerkk.UserSettings
import lt.markmerkk.utils.LogFormatters
import net.rcarz.jiraclient.Issue
import net.rcarz.jiraclient.JiraException
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import rx.Observable
import rx.Subscriber

/**
 * Created by mariusmerkevicius on 1/23/16.
 */
class JiraSearchSubscriberImpl(
        private val jiraClientProvider: JiraClientProvider,
        private val userSettings: UserSettings,
        private val searchFields: String = "*all",
        private var jql: String = ""
) : JiraSearchSubscriber, Observable.OnSubscribe<Issue.SearchResult> {

    override fun call(subscriber: Subscriber<in Issue.SearchResult>) {
        try {
            if (jql.isNullOrEmpty()) throw IllegalArgumentException("JQL is empty!")
            logger.info("Doing search: " + jql)
            var startAt = 0
            val max = 50
            var total: Int
            do {
                if (subscriber.isUnsubscribed)
                    break

                val sr = jiraClientProvider.client().searchIssues(jql, searchFields, max, startAt)
                if (sr == null) throw IllegalStateException("result is empty")
                if (sr.issues == null) throw IllegalStateException("result is empty")
                if (sr.issues.size == 0) throw IllegalStateException("result is empty")
                logger.info("Found ${sr.issues.size} issues.")
                subscriber.onNext(sr)

                startAt += sr.max
                total = sr.total
            } while (startAt < total)
            subscriber.onCompleted()
        } catch (e: IllegalStateException) {
            logger.info("Jira search ${e.message}")
            subscriber.onCompleted()
        } catch (e: IllegalArgumentException) {
            logger.error("Jira search error: ${e.message}")
            subscriber.onError(e)
        } catch (e: JiraException) {
            logger.error("Jira error: ${e.message}")
            subscriber.onError(e)
        }
    }

    override fun workedIssuesObservable(start: Long, end: Long): Observable<Issue.SearchResult> {
        return Observable.create(
                JiraSearchSubscriberImpl(
                        jiraClientProvider = jiraClientProvider,
                        userSettings = userSettings,
                        jql = jqlForWorkIssuesFromDateObservable(start, end),
                        searchFields = "*all"
                )
        )
    }

    override fun userIssuesObservable(): Observable<Issue.SearchResult> {
        return Observable.create(
                JiraSearchSubscriberImpl(
                        jiraClientProvider = jiraClientProvider,
                        userSettings = userSettings,
                        jql = userSettings.issueJql,
                        searchFields = "summary,project,created,updated,parent,issuetype"
                )
        )
    }

    fun jqlForWorkIssuesFromDateObservable(
            start: Long,
            end: Long
    ): String {
        val startFormat = LogFormatters.shortFormatDate.print(start)
        val endFormat = LogFormatters.shortFormatDate.print(end)
        return "(worklogDate >= \"$startFormat\" && worklogDate <= \"$endFormat\")" +
                " AND " +
                "(assignee = currentUser() OR reporter = currentUser() OR watcher = currentUser())"
    }

    companion object {
        private val logger: Logger = LoggerFactory.getLogger("JiraSearchJQL")
    }

}

{'fraction_non_alphanumeric': 0.09207161125319693, 'fraction_numerical': 0.00312588803637397, 'mean_word_length': 2.002986348122867, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '3226231', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1814, 'n_words': 407}