<commit_before>package nail

import (
	"github.com/antihax/evedata/internal/datapackages"

	"github.com/antihax/evedata/internal/gobcoder"
	nsq "github.com/nsqio/go-nsq"
)

func init() {
	AddHandler("structure", func(s *Nail, consumer *nsq.Consumer) {
		consumer.AddHandler(s.wait(nsq.HandlerFunc(s.structureHandler)))
	})
}

func (s *Nail) structureHandler(message *nsq.Message) error {
	b := datapackages.Structure{}
	err := gobcoder.GobDecoder(message.Body, &b)
	if err != nil {
		return err
	}

	// Push into the denormalized table. This table is volatile.
	err = s.doSQL(`INSERT INTO staStations
		(stationID, solarSystemID, corporationID, stationName, x, y, z, constellationID, regionID)
		VALUES(?,?,?,?,?,?,?,evedata.constellationIDBySolarSystem(solarSystemID),evedata.regionIDBySolarSystem(solarSystemID))
		ON DUPLICATE KEY UPDATE stationName=VALUES(stationName),solarSystemID=VALUES(solarSystemID),corporationID=VALUES(corporationID),
		x=VALUES(x),y=VALUES(y),z=VALUES(z),constellationID=evedata.constellationIDBySolarSystem(VALUES(solarSystemID)),regionID=evedata.regionIDBySolarSystem(VALUES(solarSystemID));`,
		b.StructureID, b.Structure.SolarSystemId, b.Structure.OwnerId, b.Structure.Name, b.Structure.Position.X, b.Structure.Position.Y, b.Structure.Position.Z)
	if err != nil {
		return err
	}

	// Insert into our table for tracking.
	err = s.doSQL(`INSERT INTO evedata.structures
		(stationID, solarSystemID, stationName, x, y, z, ownerID, typeID, updated)
		VALUES(?,?,?,?,?,?,?,?, UTC_TIMESTAMP())
		ON DUPLICATE KEY UPDATE stationName=VALUES(stationName),solarSystemID=VALUES(solarSystemID),ownerID=VALUES(ownerID),typeID=VALUES(typeID),
		x=VALUES(x),y=VALUES(y),z=VALUES(z);`,
		b.StructureID, b.Structure.SolarSystemId, b.Structure.Name,
		b.Structure.Position.X, b.Structure.Position.Y, b.Structure.Position.Z,
		b.Structure.OwnerId, b.Structure.TypeId)

	return err<commit_msg>Tick updated<commit_after>package nail

import (
	"github.com/antihax/evedata/internal/datapackages"

	"github.com/antihax/evedata/internal/gobcoder"
	nsq "github.com/nsqio/go-nsq"
)

func init() {
	AddHandler("structure", func(s *Nail, consumer *nsq.Consumer) {
		consumer.AddHandler(s.wait(nsq.HandlerFunc(s.structureHandler)))
	})
}

func (s *Nail) structureHandler(message *nsq.Message) error {
	b := datapackages.Structure{}
	err := gobcoder.GobDecoder(message.Body, &b)
	if err != nil {
		return err
	}

	// Push into the denormalized table. This table is volatile.
	err = s.doSQL(`INSERT INTO staStations
		(stationID, solarSystemID, corporationID, stationName, x, y, z, constellationID, regionID)
		VALUES(?,?,?,?,?,?,?,evedata.constellationIDBySolarSystem(solarSystemID),evedata.regionIDBySolarSystem(solarSystemID))
		ON DUPLICATE KEY UPDATE stationName=VALUES(stationName),solarSystemID=VALUES(solarSystemID),corporationID=VALUES(corporationID),
		x=VALUES(x),y=VALUES(y),z=VALUES(z),constellationID=evedata.constellationIDBySolarSystem(VALUES(solarSystemID)),regionID=evedata.regionIDBySolarSystem(VALUES(solarSystemID));`,
		b.StructureID, b.Structure.SolarSystemId, b.Structure.OwnerId, b.Structure.Name, b.Structure.Position.X, b.Structure.Position.Y, b.Structure.Position.Z)
	if err != nil {
		return err
	}

	// Insert into our table for tracking.
	err = s.doSQL(`INSERT INTO evedata.structures
		(stationID, solarSystemID, stationName, x, y, z, ownerID, typeID, updated)
		VALUES(?,?,?,?,?,?,?,?, UTC_TIMESTAMP())
		ON DUPLICATE KEY UPDATE stationName=VALUES(stationName),solarSystemID=VALUES(solarSystemID),ownerID=VALUES(ownerID),typeID=VALUES(typeID),
		x=VALUES(x),y=VALUES(y),z=VALUES(z),updated=UTC_TIMESTAMP();`,
		b.StructureID, b.Structure.SolarSystemId, b.Structure.Name,
		b.Structure.Position.X, b.Structure.Position.Y, b.Structure.Position.Z,
		b.Structure.OwnerId, b.Structure.TypeId)

	return err
{'fraction_non_alphanumeric': 0.14654498044328554, 'fraction_numerical': 0.0, 'mean_word_length': 6.611111111111111, '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': '6582340', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1397, 'n_words': 218}