<commit_before>#!/usr/bin/env python
# jira.py - Dump out list of eligible next JIRA tickets. This is my sketch/burn/monkeypatch copy of DS Team's jira ticket reader.
# RUN THIS WITH next-ticket (or don't, I'm not your real Dad)
import argparse

from bad_tickets import BadTicket, BadTickets
from dataservices import jira
import json
import os

def get_bad_tickets():
    try:
        with open(os.path.expanduser("~/jira-bad-tickets.json")) as file:
            return json.loads(file.read())["tickets"]
    except FileNotFoundError:
        return []


def find_ready_for_dev():
    # ticket_number = input('Epic ticket number with children tickets (ex: DS-879): ')
    # if ticket_number == '':
    #     ticket_number = 'DS-879'
    ticket_number = 'DS-879'

    jira_client = jira.Jira()
    fields = 'issuelinks,status'
    finished = None
    start_at = 0
    dave_count = 0
    dave_max = 10
    bad_tickets = BadTickets()
    bad_ticket_ids = bad_tickets.ids()
    # print(bad_ticket_ids)

    while not finished:
        # print("Querying JIRA")
        tickets = jira_client.find_issue_by_epic_id(ticket_number, fields=fields, start_at=start_at)
        # print(f"FOUND {len(tickets)} TICKETS!")
        for ticket in tickets['issues']:
            # print(ticket['key'])
            ready = True
            issuelinks = ticket['fields']['issuelinks']
            for issue in issuelinks:
                if 'inwardIssue' in issue:
                    if issue['inwardIssue']['fields']['status']['statusCategory']['name'] != 'Done' or ticket['fields']['status']['statusCategory']['name'] != 'To Do':
                        ready = False

            # if ticket["key"] in bad_tickets <-- can we hijack the "in" operator?
            #
            # bad_ticket = bad_tickets.find(ticket["key"])
            # if bad_ticket is not None:
            #     print(f"skipping ticket {bad_ticket.id} because {bad_ticket.reason}")
            bad_ticket = bad_tickets.find_ticket(ticket["key"])
            #if ticket["key"] in bad_ticket_ids:<commit_msg>Allow recently-unblocked tickets<commit_after>#!/usr/bin/env python
# jira.py - Dump out list of eligible next JIRA tickets. This is my sketch/burn/monkeypatch copy of DS Team's jira ticket reader.
# RUN THIS WITH next-ticket (or don't, I'm not your real Dad)
import argparse

from bad_tickets import BadTicket, BadTickets
from dataservices import jira
import json
import os

def get_bad_tickets():
    try:
        with open(os.path.expanduser("~/jira-bad-tickets.json")) as file:
            return json.loads(file.read())["tickets"]
    except FileNotFoundError:
        return []


def find_ready_for_dev():
    # ticket_number = input('Epic ticket number with children tickets (ex: DS-879): ')
    # if ticket_number == '':
    #     ticket_number = 'DS-879'
    ticket_number = 'DS-879'

    jira_client = jira.Jira()
    fields = 'issuelinks,status'
    finished = None
    start_at = 0
    dave_count = 0
    dave_max = 10
    bad_tickets = BadTickets()
    bad_ticket_ids = bad_tickets.ids()
    # print(bad_ticket_ids)

    while not finished:
        # print("Querying JIRA")
        tickets = jira_client.find_issue_by_epic_id(ticket_number, fields=fields, start_at=start_at)
        # print(f"FOUND {len(tickets)} TICKETS!")
        for ticket in tickets['issues']:
            # print(ticket['key'])
            ready = True
            issuelinks = ticket['fields']['issuelinks']
            for issue in issuelinks:
                if 'inwardIssue' in issue:
                    if issue['inwardIssue']['fields']['status']['name'] not in ('Closed', 'In Review') or ticket['fields']['status']['statusCategory']['name'] != 'To Do':
                        ready = False

            # if ticket["key"] in bad_tickets <-- can we hijack the "in" operator?
            #
            # bad_ticket = bad_tickets.find(ticket["key"])
            # if bad_ticket is not None:
            #     print(f"skipping ticket {bad_ticket.id} because {bad_ticket.reason}")
            bad_ticket = bad_tickets.find_ticket(ticket["key"])
            #if ticket["key"] in bad_ticket_ids:
{'fraction_non_alphanumeric': 0.12071463061323032, 'fraction_numerical': 0.006277160791887977, 'mean_word_length': 2.6826666666666665, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1279262', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1262, 'n_words': 325}