persistent_data

package
v0.0.0-...-36266b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddReplaySummToPackageSumm

func AddReplaySummToPackageSumm(
	replaySummary *ReplaySummary,
	packageSummary *PackageSummary,
)

AddReplaySummToPackageSumm adds the replay summary to the package summary.

func CheckFileInfoEq

func CheckFileInfoEq(
	fileInfo fs.FileInfo,
	fileInfoToCheck FileInformationToCheck,
) bool

CheckFileInfoEq compares the fs.FileInfo contents with FileInfoToCheck. Returns true if the contents are the same. This is used to verify if the file changed since last processing.

func CreatePackageSummaryFile

func CreatePackageSummaryFile(
	absolutePathOutputDirectory string,
	packageSummaryStruct PackageSummary,
	fileNumber int,
) error

CreatePackageSummaryFile receives packageSummaryStruct and fileNumber then saves the package summary file onto the drive.

func SaveProcessingInfoToFile

func SaveProcessingInfoToFile(
	processingInfoFile *os.File,
	processingInfoStruct ProcessingInfo,
)

SaveProcessingInfoToFile receives a file and marshals/writes processingInfoStruct into the file.

Types

type DownloadedMapsReplaysToFileInfo

type DownloadedMapsReplaysToFileInfo struct {
	DownloadedMapsForFiles map[string]any `json:"downloadedMapsForFiles"`
}

DownloadedMapsReplaysToFileInfo Used to store replays that were processed in previous runs. Holds file information in the values of the map to compare against current files. This is so that the maps for them are not re-downloaded. This is used in a pre-processing step, before the final processing of the replays and data extraction is performed.

func FromSyncMapToDownloadedMapsForReplaysToFileInfo

func FromSyncMapToDownloadedMapsForReplaysToFileInfo(
	syncMap *sync.Map,
) DownloadedMapsReplaysToFileInfo

FromSyncMapToDownloadedMapsForReplaysToFileInfo Converts a sync.Map to a DownloadedMapsReplaysToFileInfo.

func OpenOrCreateDownloadedMapsForReplaysToFileInfo

func OpenOrCreateDownloadedMapsForReplaysToFileInfo(
	filepath string,
	mapsDirectory string,
	files []string,
) (DownloadedMapsReplaysToFileInfo, []string, error)

OpenOrCreateDownloadedMapsForReplaysToFileInfo Initializes and populates a DownloadedMapsReplaysToFileInfo structure.

func (*DownloadedMapsReplaysToFileInfo) AddReplayToProcessed

func (prtm *DownloadedMapsReplaysToFileInfo) AddReplayToProcessed(
	replayPath string,
	fileInfo fs.FileInfo,
)

AddReplayToProcessed adds a replay with its file information to the processed replays. used to check if the replay was processed before.

func (*DownloadedMapsReplaysToFileInfo) CheckIfReplayWasProcessed

func (prtm *DownloadedMapsReplaysToFileInfo) CheckIfReplayWasProcessed(
	replayPath string,
) (FileInformationToCheck, bool)

CheckIfReplayWasProcessed checks if the replay was processed before.

func (*DownloadedMapsReplaysToFileInfo) ConvertToSyncMap

func (prtm *DownloadedMapsReplaysToFileInfo) ConvertToSyncMap() *sync.Map

ConvertToSyncMap Converts a DownloadedMapsReplaysToFileInfo to a sync.Map.

func (*DownloadedMapsReplaysToFileInfo) SaveDownloadedMapsForReplaysFile

func (prtm *DownloadedMapsReplaysToFileInfo) SaveDownloadedMapsForReplaysFile(
	filepath string,
) error

type FileInformationToCheck

type FileInformationToCheck struct {
	LastModified int64 `json:"lastModified"`
	Size         int64 `json:"size"`
}

type GameTimes

type GameTimes struct {
	GameTimes map[string]map[string]int64 `json:"gameTimes"`
}

func NewGameTimes

func NewGameTimes() GameTimes

type MatchupGameTimes

type MatchupGameTimes struct {
	PvPMatchup map[string]int64 `json:"PvPMatchupGameTimes"`
	TvTMatchup map[string]int64 `json:"TvTMatchupGameTimes"`
	ZvZMatchup map[string]int64 `json:"ZvZMatchupGameTimes"`
	PvZMatchup map[string]int64 `json:"PvZMatchupGameTimes"`
	PvTMatchup map[string]int64 `json:"PvTMatchupGameTimes"`
	TvZMatchup map[string]int64 `json:"TvZMatchupGameTimes"`
}

MatchupHistograms aggregates the data that is required to prepare histograms of Matchup vs Game Length

func NewMatchupGameTimes

func NewMatchupGameTimes() MatchupGameTimes

NewMatchupHistograms returns a structure with initialized fields.

type PackageSummary

type PackageSummary struct {
	Summary Summary
}

PackageSummary is a structure contains statistics calculated from replay information that belong to a whole ZIP archive.

func NewPackageSummary

func NewPackageSummary() PackageSummary

NewPackageSummary returns an initialized PackageSummary

type ProcessingInfo

type ProcessingInfo struct {
	ProcessedFiles  []string            `json:"processedFiles"`
	FailedToProcess []map[string]string `json:"failedToProcess"`
}

ProcessingInfo is a structure holding information that is used to create processing.log, which is anonymizedPlayers in a persistent map from toon to unique integer, slice of processed files so that there is a state of all of the processed files.

func CreateProcessingInfoFile

func CreateProcessingInfoFile(
	logsFilepath string,
	fileNumber int,
) (*os.File, ProcessingInfo, error)

CreateProcessingInfoFile receives a fileNumber and creates a processing info file holding the information on which files were processed successfully and which failed.

func NewProcessingInfo

func NewProcessingInfo() ProcessingInfo

NewProcessingInfo returns empty ProcessingIngo struct.

func (*ProcessingInfo) AddToFailed

func (processingInfo *ProcessingInfo) AddToFailed(
	replayFilePath string,
	reason string,
)

AddToFailed adds a replay file path to the list of failed files. Includes a reason for failure.

func (*ProcessingInfo) AddToProcessed

func (processingInfo *ProcessingInfo) AddToProcessed(replayFilePath string)

AddToProcessed adds a replay file path to the list of processed files.

type ReplaySummary

type ReplaySummary struct {
	Summary Summary
}

ReplaySummary contains information calculated from a single replay

func NewReplaySummary

func NewReplaySummary() ReplaySummary

NewReplaySummary returns an initialized ReplaySummary

type Summary

type Summary struct {
	GameVersions     map[string]int64 `json:"gameVersions"`
	GameTimes        map[string]int64 `json:"gameTimes"`
	Maps             map[string]int64 `json:"maps"`
	MapsGameTimes    GameTimes        `json:"mapGameTimes"`
	Races            map[string]int64 `json:"races"`
	Units            map[string]int64 `json:"units"`
	OtherUnits       map[string]int64 `json:"otherUnits"`
	Dates            map[string]int64 `json:"dates"`
	DatesGameTimes   GameTimes        `json:"datesGameTimes"`
	Servers          map[string]int64 `json:"servers"`
	MatchupCount     map[string]int64 `json:"matchupCount"`
	MatchupGameTimes MatchupGameTimes `json:"matchupGameTimes"`
}

Summary is an abstract type used by both ReplaySummary and PackageSummary and contains fields that are used as descriptive statistics

func NewSummary

func NewSummary() Summary

NewSummary returns a Summary structure with initialized fiends

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL