<commit_before>package triage

import (
	"context"
	"log"
	"net/http"
	"time"

	"github.com/google/go-github/github"
)

func New(client *github.Client, labelsofInterest []string) Triager {
	return Triager{
		Client:           client,
		LabelsOfInterest: labelsofInterest,
		repoTypeCache:    map[string][]IssueGrouping{},
	}
}

type Triager struct {
	Client           *github.Client
	LabelsOfInterest []string

	repoTypeCache map[string][]IssueGrouping
}

func (t Triager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	repo := r.FormValue("repo")
	if repo == "" {
		repo = "jekyll/jekyll"
	}

	issueType := r.FormValue("type")
	if issueType == "" {
		issueType = "all"
	}

	label := r.FormValue("label")
	// If blank, then we pull all of them.

	err := triageTmpl.Execute(w, t.getTemplateInfo(repo, issueType, label))
	if err != nil {
		w.Write([]byte(err.Error()))
	}
}

func (t *Triager) getTemplateInfo(repo, issueType, label string) templateInfo {
	key := repo + "____" + issueType
	if _, ok := t.repoTypeCache[key]; !ok {
		t.repoTypeCache[key] = t.fetchIssues(repo, issueType)
	}

	desiredGroupings := []IssueGrouping{}
	if label == "" {
		desiredGroupings = t.repoTypeCache[key]
	} else {
		for _, labelGrouping := range t.repoTypeCache[key] {<commit_msg>Give us a reset mechanism<commit_after>package triage

import (
	"context"
	"log"
	"net/http"
	"time"

	"github.com/google/go-github/github"
)

func New(client *github.Client, labelsofInterest []string) *Triager {
	return &Triager{
		Client:           client,
		LabelsOfInterest: labelsofInterest,
		repoTypeCache:    map[string][]IssueGrouping{},
	}
}

type Triager struct {
	Client           *github.Client
	LabelsOfInterest []string

	repoTypeCache map[string][]IssueGrouping
}

func (t *Triager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if r.FormValue("reset") != "" {
		t.repoTypeCache = map[string][]IssueGrouping{}
		log.Println("resetting repoTypeCache...")
		http.Redirect(w, r, "/triage", 302)
		return
	}

	repo := r.FormValue("repo")
	if repo == "" {
		repo = "jekyll/jekyll"
	}

	issueType := r.FormValue("type")
	if issueType == "" {
		issueType = "all"
	}

	label := r.FormValue("label")
	// If blank, then we pull all of them.

	err := triageTmpl.Execute(w, t.getTemplateInfo(repo, issueType, label))
	if err != nil {
		w.Write([]byte(err.Error()))
	}
}

func (t *Triager) getTemplateInfo(repo, issueType, label string) templateInfo {
	key := repo + "____" + issueType
	if _, ok := t.repoTypeCache[key]; !ok {
		t.repoTypeCache[key] = t.fetchIssues(repo, issueType)
	}

	desiredGroupings := []IssueGrouping{}
	if label == "" {
		desiredGroupings = t.repoTypeCache[key]
	} else {
		for _, labelGrouping := range t.repoTypeCache[key] {
{'fraction_non_alphanumeric': 0.15274725274725276, 'fraction_numerical': 0.001098901098901099, 'mean_word_length': 4.0762081784386615, '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': '3693962', 'n_tokens_mistral': 1038, 'n_tokens_neox': 979, 'n_words': 211}