<commit_before>package main

import (
	"encoding/json"
	"io"
	"net/http"
	"strconv"
)

// Send a message to GCM
func send(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	tokens := r.PostForm["tokens"]
	jsonStr := r.PostFormValue("payload")

	go func() {
		incrementPending()
		sendMessageToGCM(tokens, jsonStr)
	}()

	// Return immediately
	output := "ok\n"
	w.Header().Set("Content-Type", "text/html")
	w.Header().Set("Content-Length", strconv.Itoa(len(output)))
	io.WriteString(w, output)
}

// Return a run report for this process
func getReport(w http.ResponseWriter, r *http.Request) {
	runReportMutex.Lock()
	a, _ := json.Marshal(runReport)
	runReportMutex.Unlock()
	b := string(a)
	io.WriteString(w, b)
}

// Return all currently collected canonical reports from GCM
func getCanonicalReport(w http.ResponseWriter, r *http.Request) {
	ids := map[string][]canonicalReplacement{"canonical_replacements": canonicalReplacements}
	a, _ := json.Marshal(ids)
	b := string(a)
	io.WriteString(w, b)

	// Clear out canonicals
	go func() {
		canonicalReplacementsMutex.Lock()
		defer canonicalReplacementsMutex.Unlock()
		canonicalReplacements = nil
	}()

	go func() {
		runReportMutex.Lock()
		defer runReportMutex.Unlock()
		runReport.Canonicals = 0
	}()
}<commit_msg>Don't clear out canonicals reporting number after canonical report is retrieved<commit_after>package main

import (
	"encoding/json"
	"io"
	"net/http"
	"strconv"
)

// Send a message to GCM
func send(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	tokens := r.PostForm["tokens"]
	jsonStr := r.PostFormValue("payload")

	go func() {
		incrementPending()
		sendMessageToGCM(tokens, jsonStr)
	}()

	// Return immediately
	output := "ok\n"
	w.Header().Set("Content-Type", "text/html")
	w.Header().Set("Content-Length", strconv.Itoa(len(output)))
	io.WriteString(w, output)
}

// Return a run report for this process
func getReport(w http.ResponseWriter, r *http.Request) {
	runReportMutex.Lock()
	a, _ := json.Marshal(runReport)
	runReportMutex.Unlock()
	b := string(a)
	io.WriteString(w, b)
}

// Return all currently collected canonical reports from GCM
func getCanonicalReport(w http.ResponseWriter, r *http.Request) {
	ids := map[string][]canonicalReplacement{"canonical_replacements": canonicalReplacements}
	a, _ := json.Marshal(ids)
	b := string(a)
	io.WriteString(w, b)

	// Clear out canonicals
	go func() {
		canonicalReplacementsMutex.Lock()
		defer canonicalReplacementsMutex.Unlock()
		canonicalReplacements = nil
	}()
}
{'fraction_non_alphanumeric': 0.1428003182179793, 'fraction_numerical': 0.0003977724741447892, 'mean_word_length': 4.862470862470863, 'pattern_counts': {'":': 2, '<': 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': '4754929', 'n_tokens_mistral': 895, 'n_tokens_neox': 874, 'n_words': 195}