<commit_before>package main

import (
	"fmt"
	"log"
	"reflect"
	"time"

	"github.com/Cepave/common/model"
)

func updatedMsg(old map[string]MeasurementsProperty, updated map[string]MeasurementsProperty) string {
	msg := ""
	for k, _ := range updated {
		if !old[k].enabled && updated[k].enabled {
			msg = msg + fmt.Sprint("<", k, " Enabled> ")
		}
		if old[k].enabled && !updated[k].enabled {
			msg = msg + fmt.Sprint("<", k, " Disabled> ")
		}
	}
	return msg
}

func updateMeasurements(command []string) map[string]MeasurementsProperty {
	updated := NewMeasurements()

	for _, cmd := range command {
		if m, ok := updated[cmd]; ok {
			m.enabled = true
			updated[cmd] = m
		}
	}
	return updated
}

func configFromHbsUpdated(newResp model.NqmPingTaskResponse) bool {
	if !reflect.DeepEqual(GetGeneralConfig().hbsResp, newResp) {
		return true
	}
	return false
}

func query() {
	var resp model.NqmPingTaskResponse
	err := rpcClient.Call("NqmAgent.PingTask", req, &resp)
	if err != nil {
		log.Println("[ hbs ] Error on RPC call:", err)
		return
	}

	log.Println("[ hbs ] Response received")
	if !configFromHbsUpdated(resp) {
		return
	}
	GetGeneralConfig().hbsResp = resp

	old := GetGeneralConfig().Measurements
	cmd := GetGeneralConfig().hbsResp.Command
	updated := updateMeasurements(cmd)
	if msg := updatedMsg(old, updated); msg != "" {
		log.Println("[ hbs ]", msg)
	}
	GetGeneralConfig().Measurements = updated

	log.Println("[ hbs ] Configuration updated")
}

func Query() {
	for {
		go query()

		dur := time.Second * time.Duration(GetGeneralConfig().Hbs.Interval)
		time.Sleep(dur)
	}
}<commit_msg>[OWL-663] Code refinement<commit_after>package main

import (
	"fmt"
	"log"
	"reflect"
	"time"

	"github.com/Cepave/common/model"
)

func updatedMsg(old map[string]MeasurementsProperty, updated map[string]MeasurementsProperty) string {
	msg := ""
	for k, _ := range updated {
		if !old[k].enabled && updated[k].enabled {
			msg = msg + fmt.Sprint("<", k, " Enabled> ")
		}
		if old[k].enabled && !updated[k].enabled {
			msg = msg + fmt.Sprint("<", k, " Disabled> ")
		}
	}
	return msg
}

func updateMeasurements(command []string) map[string]MeasurementsProperty {
	updated := NewMeasurements()

	for _, cmd := range command {
		if m, ok := updated[cmd]; ok {
			m.enabled = true
			updated[cmd] = m
		}
	}
	return updated
}

func configFromHbsUpdated(newResp model.NqmPingTaskResponse) bool {
	if !reflect.DeepEqual(GetGeneralConfig().hbsResp, newResp) {
		return true
	}
	return false
}

func query() {
	var resp model.NqmPingTaskResponse
	err := rpcClient.Call("NqmAgent.PingTask", req, &resp)
	if err != nil {
		log.Println("[ hbs ] Error on RPC call:", err)
		return
	}
	log.Println("[ hbs ] Response received")
	if !configFromHbsUpdated(resp) {
		return
	}

	GetGeneralConfig().hbsResp = resp

	old := GetGeneralConfig().Measurements
	cmd := GetGeneralConfig().hbsResp.Command
	updated := updateMeasurements(cmd)
	GetGeneralConfig().Measurements = updated

	if msg := updatedMsg(old, updated); msg != "" {
		log.Println("[ hbs ]", msg)
	}
	log.Println("[ hbs ] Configuration updated")
}

func Query() {
	for {
		go query()

		dur := time.Second * time.Duration(GetGeneralConfig().Hbs.Interval)
		time.Sleep(dur)
	}
}
{'fraction_non_alphanumeric': 0.15129950495049505, 'fraction_numerical': 0.0009282178217821782, 'mean_word_length': 4.181089743589744, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3325143', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1149, 'n_words': 256}