stats

package
v0.0.0-...-eaf9504 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OtherNotes = `
## Data Collection
### Code

You can find the code in the following file: [wows.go](https://github.com/wows-tools/wows-stats/blob/main/backend/wows.go).

### Methodology

To collect player statistics, the code utilizes the [WoWs API provided by Wargaming](https://developers.wargaming.net/).

However, due to limitations in the API, it is not possible to retrieve a complete list of all players directly. Instead, a search endpoint is available, which allows searching for players based on a nickname prefix. The prefix must have a minimum length of 3 characters, and the API returns a maximum of 100 profiles sorted alphabetically.

To overcome these limitations, a creative algorithm is implemented with the following steps:

1. Start with the shortest prefix '000' (the first prefix alphabetically).
2. Perform a search using the current prefix.
3. If the search result contains fewer than 100 players:
   - If the prefix ends with the last character in the alphabet ("` + "`" + `_` + "`" + `"), reduce the prefix size by 1 and move to the next prefix.
   - If the prefix does not end with the last character, set the prefix to the first len(current_prefix) + 1 characters of the last entry's nickname from the search result and move to the next prefix.
4. Repeat steps 2-3 until the prefix loops back to '000\*'.

Once all the players are retrieved using this method, an iteration is performed to gather additional details such as the number of battles, account creation date, etc. Clans are also scanned.

Additionally, the code includes a clean-up process to identify and remove potential QA/test accounts created by Wargaming. These accounts exhibit similar nickname patterns and identical statistics. Examples of these patterns are "pt\*tpt," "lp\_ru\_prod\*," and "auto\_\*." On the European server alone, there are approximately 330,000 such accounts.

The implementation of this algorithm is complex and error-prone. However, the code has successfully collected the following player counts (as of 2023/05/24) which looks consistent:

- EU: 7,058,091 players
- NA: 3,576,287 players
- ASIA: 3,894,958 players

Please note that running the complete data collection process for each server takes a considerable amount of time, approximately 1 to 2 days per server.

### Collect/Report Genation Frequency

This project collects data and generate the present report once per month, toward the end of the month.

## About the CIS -> EU migration

Apparently, accounts which were migration from CIS to EU where migrated in full, including account creation date.

This means that charts related to accounts on the EU server are actually:

* EU + migrated portion of CIS before September 2022
* EU alone after September 2022 (with the influx of CIS players)

This is why no spikes are visible around that time.

Clans were recreated fresh however.

## Final Notes

This project is on going and still early on. New charts will be added, problematic charts will be deleted and existing charts tweaked/improved.

This project will also improve over time by having a data history. One of its big flaw currently is the lack of historic data, which leads to numerous approximations.

With historic data, these approximations will partially disappear over time.
`
	SeePrevious = `
### Description

See Previous chart(s) description.
`
)
View Source
const (
	ModChart = "chart"
	ModPage  = "page"
)
View Source
const (
	ActivePlayersMonthlyMethodology = `` /* 760-byte string literal not displayed */

)
View Source
const (
	ActivePlayersPieMethodology = `` /* 483-byte string literal not displayed */

)
View Source
const (
	BarChartByRandomBattlesMethodology = `` /* 535-byte string literal not displayed */

)
View Source
const (
	DistributionByWinRateMethodology = `` /* 2613-byte string literal not displayed */

)
View Source
const (
	DivVsSoloWRMethodology = `` /* 735-byte string literal not displayed */

)
View Source
const (
	MonthlyBattleEstimationMethodology = `` /* 1558-byte string literal not displayed */

)
View Source
const (
	PieClanProfilesMethodology = `` /* 295-byte string literal not displayed */

)
View Source
const (
	PieHiddenProfilesMethodology = `` /* 308-byte string literal not displayed */

)
View Source
const (
	PlayerGainLossBarMethodology = `` /* 1292-byte string literal not displayed */

)
View Source
const (
	PlayerGainLossBarNetMethodology = `` /* 1391-byte string literal not displayed */

)
View Source
const (
	PlayerGainLossBarNetMethodology2000 = `
### Description

TODO

### Code

TODO

### Methodology

TODO

### Caveats

TODO
`
)
View Source
const (
	PlayerGainLossBarNetWithBattlesMethodoloy = `` /* 1190-byte string literal not displayed */

)
View Source
const (
	PlayerGainLossBarNetWithBattlesMethodoloy2000 = `
### Description

TODO

### Code

TODO

### Methodology

TODO

### Caveats

TODO
`
)
View Source
const (
	PlayerGainLossBarWithBattlesMethodoloy = `` /* 1511-byte string literal not displayed */

)
View Source
const (
	PlayerStartStopChartMethodology = `` /* 1019-byte string literal not displayed */

)
View Source
const (
	WinRateByBattlesMethodology = `` /* 536-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func MustTemplate

func MustTemplate(name string, contents []string) *template.Template

MustTemplate creates a new template with the given name and parsed contents.

Types

type Charter

type Charter interface {
	Type() string
	GetAssets() opts.Assets
	FillDefaultValues()
	Validate()
}

Charter represents a chart value which provides its type, assets and can be validated.

type Layout

type Layout string
const (
	PageNoneLayout   Layout = "none"
	PageCenterLayout Layout = "center"
	PageFlexLayout   Layout = "flex"
)

type Markdown

type Markdown struct {
	MDText string
}

func NewMarkdown

func NewMarkdown(text string) Markdown

func (Markdown) FillDefaultValues

func (md Markdown) FillDefaultValues()

func (Markdown) GetAssets

func (Markdown) GetAssets() opts.Assets

no need for these functions

func (Markdown) Type

func (Markdown) Type() string

func (Markdown) Validate

func (Markdown) Validate()

type Page

type Page struct {
	Renderer
	opts.Initialization
	opts.Assets

	ChartRows [][]interface{}
	Layout    Layout
}

Page represents a page chart.

func NewPage

func NewPage() *Page

NewPage creates a new page.

func (*Page) AddRow

func (page *Page) AddRow(charts ...Charter) *Page

AddCharts adds new charts to the page.

func (*Page) SetLayout

func (page *Page) SetLayout(layout Layout) *Page

SetLayout sets the layout of the Page.

func (*Page) Validate

func (page *Page) Validate()

Validate validates the given configuration.

type Renderer

type Renderer interface {
	Render(w io.Writer) error
}

func NewPageRender

func NewPageRender(c interface{}, before ...func()) Renderer

NewPageRender returns a render implementation for Page.

type StatsServer

type StatsServer struct {
	Logger *zap.SugaredLogger
	DB     *gorm.DB
	Output string
	Realm  string
}

func NewStatsServer

func NewStatsServer(output string, logger *zap.SugaredLogger, db *gorm.DB, realm string) *StatsServer

func (*StatsServer) ActivePlayersMonthly

func (server *StatsServer) ActivePlayersMonthly() *charts.Line

func (*StatsServer) ActivePlayersPie

func (server *StatsServer) ActivePlayersPie() *charts.Pie

func (*StatsServer) BarChartByRandomBattles

func (server *StatsServer) BarChartByRandomBattles() *charts.Bar

func (*StatsServer) DistributionByWinRate

func (server *StatsServer) DistributionByWinRate(minBattles int, step float64) *charts.Line

minBattles: Minimum number of battles step: size for win rate increments

func (*StatsServer) DivVsSoloWR

func (server *StatsServer) DivVsSoloWR() *charts.Scatter

func (*StatsServer) GenerateReport

func (server *StatsServer) GenerateReport()

func (*StatsServer) MonthlyBattleEstimation

func (server *StatsServer) MonthlyBattleEstimation() *charts.Line

func (*StatsServer) PieClanProfiles

func (server *StatsServer) PieClanProfiles() *charts.Pie

func (*StatsServer) PieHiddenProfiles

func (server *StatsServer) PieHiddenProfiles() *charts.Pie

func (*StatsServer) PlayerGainLossBar

func (server *StatsServer) PlayerGainLossBar(minBattles int) []*charts.Bar

func (*StatsServer) PlayerStartStopChart

func (server *StatsServer) PlayerStartStopChart() *charts.Bar3D

func (*StatsServer) WinRateByBattles

func (server *StatsServer) WinRateByBattles() *charts.Bar

Jump to

Keyboard shortcuts

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