{"modulePath":"github.com/cncf/devstatscode","version":"v0.7.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package devstatscode\n\n## Constants\n\n```go\nconst Abuse string = \"abuse\"\n```\nAbuse - common constant string\n\n```go\nconst All string = \"all\"\n```\nAll - common constant string\n\n```go\nconst DefaultDataDir string = \"/etc/gha2db/\"\n```\nDefaultDataDir - common constant string\n\n```go\nconst Devstats string = \"devstats\"\n```\nDevstats - common constant string\n\n```go\nconst DevstatsCode string = \"devstatscode\"\n```\nDevstatsCode - common constant string\n\n```go\nconst EngineIsClosedError string = \"engine is closed\"\n```\nEngineIsClosedError - common constant string\n\n```go\nconst GHA string = \"gha\"\n```\nGHA - common constant string\n\n```go\nconst GHAAdmin string = \"gha_admin\"\n```\nGHAAdmin - common constant string\n\n```go\nconst HideCfgFile string = \"hide/hide.csv\"\n```\nHideCfgFile - common constant string\n\n```go\nconst InvalidCatalogName string = \"invalid_catalog_name\"\n```\nInvalidCatalogName - common constant string\n\n```go\nconst Kubernetes string = \"kubernetes\"\n```\nKubernetes - common constant string\n\n```go\nconst LocalGitScripts string = \"./git/\"\n```\nLocalGitScripts - common constant string\n\n```go\nconst Localhost string = \"localhost\"\n```\nLocalhost - common constant string\n\n```go\nconst Merged string = \"merged\"\n```\nMerged - common constant string\n\n```go\nconst Metrics string = \"metrics/\"\n```\nMetrics - common constant string\n\n```go\nconst Nil string = \"(nil)\"\n```\nNil - common constant string\n\n```go\nconst NotFound string = \"not_found\"\n```\nNotFound - common constant string\n\n```go\nconst Now string = \"now\"\n```\nNow - common constant string\n\n```go\nconst Null string = \"null\"\n```\nNull - common constant string\n\n```go\nconst Password string = \"password\"\n```\nPassword - common constant string\n\n```go\nconst Quarter string = \"quarter\"\n```\nQuarter - common constant string\n\n```go\nconst Retry string = \"retry\"\n```\nRetry - common constant string\n\n```go\nconst TimeCol string = \"time\"\n```\nTimeCol - common constant string\n\n```go\nconst TimeoutError string = \"{\\\"error\\\":\\\"timeout\\\"}\\n\"\n```\nTimeoutError - common constant string\n\n```go\nconst Today string = \"today\"\n```\nToday - common constant string\n\n```go\nconst Unset string = \"{{unset}}\"\n```\nUnset - common constant string\n\n## Functions\n\n```go\nfunc ActorHit(ctx *Ctx, actorName string) bool\n```\nActorHit - are we intereste din this actor?\n\n```go\nfunc ActorIDOrNil(actPtr *Actor) interface{}\n```\nActorIDOrNil - return Actor ID from pointer or nil\n\n```go\nfunc ActorLoginOrNil(actPtr *Actor, maybeHide func(string) string) interface{}\n```\nActorLoginOrNil - return Actor Login from pointer or nil\n\n```go\nfunc AddNIntervals(dt time.Time, n int, nextIntervalStart, prevIntervalStart func(time.Time) time.Time) time.Time\n```\nAddNIntervals adds (using nextIntervalStart) or subtracts (using prevIntervalStart) N itervals to the given date Functions Next/Prev can use Hour, Day, Week, Month, Quarter, Year functions (defined in this module) or other custom defined functions With \\`func(time.Time) time.Time\\` signature\n\n```go\nfunc AddTSPoint(ctx *Ctx, pts *TSPoints, pt TSPoint)\n```\nAddTSPoint add single point to the batch\n\n```go\nfunc ArtificialEvent(c *sql.DB, ctx *Ctx, cfg *IssueConfig) (err error)\n```\nArtificialEvent - create artificial API event (but from the past)\n\n```go\nfunc ArtificialPREvent(c *sql.DB, ctx *Ctx, cfg *IssueConfig, pr *github.PullRequest) (err error)\n```\nArtificialPREvent - create artificial API event (PR state for now())\n\n```go\nfunc BoolOrNil(boolPtr *bool) interface{}\n```\nBoolOrNil - return either nil or value of boolPtr\n\n```go\nfunc CleanUTF8(str string) string\n```\nCleanUTF8 - clean UTF8 string to containg only Pq allowed runes\n\n```go\nfunc ClearDBLogs()\n```\nClearDBLogs clears logs older by defined period (in context.go) It clears logs on \\`devstats\\` database\n\n```go\nfunc CommentIDOrNil(commPtr *Comment) interface{}\n```\nCommentIDOrNil - return Comment ID from pointer or nil\n\n```go\nfunc CompareFloat64Ptr(p1, p2 *float64) bool\n```\nCompareFloat64Ptr - compares two string pointers returns true if both pointers are null or both are non null and point to floats with the same value (with epsilon)\n\n```go\nfunc CompareIntPtr(p1, p2 *int) bool\n```\nCompareIntPtr - compares two int pointers returns true if both pointers are null or both are non null and point to integers with the same value\n\n```go\nfunc CompareStringPtr(p1, p2 *string) bool\n```\nCompareStringPtr - compares two string pointers returns true if both pointers are null or both are non null and point to strings with the same content\n\n```go\nfunc ComputePeriodAtThisDate(ctx *Ctx, period string, idt time.Time, hist bool) bool\n```\nComputePeriodAtThisDate - for some longer periods, only recalculate them on specific dates/times see: time\\_test.go\n\n```go\nfunc CreateDatabaseIfNeeded(ctx *Ctx) bool\n```\nCreateDatabaseIfNeeded - creates requested database if not exists Returns true if database was not existing existed and created dropped\n\n```go\nfunc CreateDatabaseIfNeededExtended(ctx *Ctx, extraParams string) bool\n```\nCreateDatabaseIfNeededExtended - creates requested database if not exists Returns true if database was not existing existed and created dropped Allows specifying additional database parameters\n\n```go\nfunc CreateTable(tdef string) string\n```\nCreateTable is used to replace DB specific parts of Create Table SQL statement\n\n```go\nfunc DatabaseExists(ctx *Ctx, closeConn bool) (exists bool, c *sql.DB)\n```\nDatabaseExists - checks if database stored in context exists If closeConn is true - then it closes connection after checking if database exists If closeConn is false, then it returns open connection to default database \"postgres\"\n\n```go\nfunc DayStart(dt time.Time) time.Time\n```\nDayStart - return time rounded to current day start\n\n```go\nfunc DeleteArtificialEvent(c *sql.DB, ctx *Ctx, cfg *IssueConfig) (err error)\n```\nDeleteArtificialEvent - create artificial API event (but from the past)\n\n```go\nfunc DeleteArtificialPREvent(c *sql.DB, ctx *Ctx, cfg *IssueConfig) (err error)\n```\nDeleteArtificialPREvent - create artificial API event (but from the past)\n\n```go\nfunc DescriblePeriodInHours(hrs float64) (desc string)\n```\nDescriblePeriodInHours - return string description of a time period given in hours\n\n```go\nfunc DropDatabaseIfExists(ctx *Ctx) bool\n```\nDropDatabaseIfExists - drops requested database if exists Returns true if database existed and was dropped\n\n```go\nfunc EnvReplace(prefix, suffix string) map[string]string\n```\nEnvReplace - replace all environment variables starting with \"prefix\" with contents of variables with \"suffix\" added - if defined If prefix is \"DB\\_\" and suffix is \"\\_SRC\" then: So if there is \"DB\\_HOST\\_SRC\" variable defined - it will replace \"DB\\_HOST\" and so on\n\n```go\nfunc EnvRestore(env map[string]string)\n```\nEnvRestore - restores all environment variables given in the map\n\n```go\nfunc ExecCommand(ctx *Ctx, cmdAndArgs []string, env map[string]string) (string, error)\n```\nExecCommand - execute command given by array of strings with eventual environment map\n\n```go\nfunc ExecSQL(con *sql.DB, ctx *Ctx, query string, args ...interface{}) (sql.Result, error)\n```\nExecSQL executes given SQL on Postgres DB (and return single state result, that doesn't need to be closed)\n\n```go\nfunc ExecSQLTx(con *sql.Tx, ctx *Ctx, query string, args ...interface{}) (sql.Result, error)\n```\nExecSQLTx executes given SQL on Postgres DB (and return single state result, that doesn't need to be closed) It is for running inside transaction\n\n```go\nfunc ExecSQLTxWithErr(con *sql.Tx, ctx *Ctx, query string, args ...interface{}) sql.Result\n```\nExecSQLTxWithErr wrapper to ExecSQLTx that exists on error It is for running inside transaction\n\n```go\nfunc ExecSQLWithErr(con *sql.DB, ctx *Ctx, query string, args ...interface{}) sql.Result\n```\nExecSQLWithErr wrapper to ExecSQL that exists on error\n\n```go\nfunc FatalNoLog(err error) string\n```\nFatalNoLog displays error message (if error present) and exits program, should be used for very early init state\n\n```go\nfunc FatalOnError(err error) string\n```\nFatalOnError displays error message (if error present) and exits program\n\n```go\nfunc Fatalf(f string, a ...interface{})\n```\nFatalf - it will call FatalOnError using fmt.Errorf with args provided\n\n```go\nfunc FirstIntOrNil(intPtrs []*int) interface{}\n```\nFirstIntOrNil - return either nil or value of intPtr\n\n```go\nfunc ForkeeIDOrNil(forkPtr *Forkee) interface{}\n```\nForkeeIDOrNil - return Forkee ID from pointer or nil\n\n```go\nfunc ForkeeNameOrNil(forkPtr *Forkee) interface{}\n```\nForkeeNameOrNil - return Forkee Name from pointer or nil\n\n```go\nfunc ForkeeOldIDOrNil(forkPtr *ForkeeOld) interface{}\n```\nForkeeOldIDOrNil - return ForkeeOld ID from pointer or nil\n\n```go\nfunc GHClient(ctx *Ctx) (ghCtx context.Context, clients []*github.Client)\n```\nGHClient - get GitHub client\n\n```go\nfunc GetDateAgo(con *sql.DB, ctx *Ctx, from time.Time, ago string) (tm time.Time)\n```\nGetDateAgo returns date: 'from' - 'n hours/days' etc.\n\n```go\nfunc GetFloatFromInterface(i interface{}) (float64, bool)\n```\nGetFloatFromInterface if an interface is of numeric type, return its value as float64\n\n```go\nfunc GetHidden(configFile string) map[string]string\n```\nGetHidden - return list of shas to replace\n\n```go\nfunc GetIntervalFunctions(intervalAbbr string, allowUnknown bool) (interval string, n int, intervalStart, nextIntervalStart, prevIntervalStart func(time.Time) time.Time)\n```\nGetIntervalFunctions - return interval name, interval number, interval start, next, prev function from interval abbr: h|d2|w3|m4|q|y w3 = 3 weeks, q2 = 2 quarters, y = year (1), d7 = 7 days (not the same as w), m3 = 3 months (not the same as q)\n\n```go\nfunc GetRateLimits(gctx context.Context, ctx *Ctx, gcs []*github.Client, core bool) (int, []int, []int, []time.Duration)\n```\nGetRateLimits - returns all and remaining API points and duration to wait for reset when core=true - returns Core limits, when core=false returns Search limits\n\n```go\nfunc GetRecentRepos(c *sql.DB, ctx *Ctx, dtFrom time.Time) (repos []string, rids []int64)\n```\nGetRecentRepos - get list of repos active last day\n\n```go\nfunc GetTagValues(con *sql.DB, ctx *Ctx, name, key string) (ret []string)\n```\nGetTagValues returns tag values for a given key\n\n```go\nfunc GetThreadsNum(ctx *Ctx) int\n```\nGetThreadsNum returns the number of available CPUs If environment variable GHA2DB\\_ST is set it retuns 1 It can be used to debug single threaded verion It runs on 95% CPU power by default\n\n```go\nfunc HandlePossibleError(err error, cfg, info string) string\n```\nHandlePossibleError - display error specific message, detect rate limit and abuse\n\n```go\nfunc HashArray(ia []interface{}) string\n```\nHashArray takes \\[]interface{} and returns hash string from given keys from map\n\n```go\nfunc HashObject(iv map[string]interface{}, keys []string) string\n```\nHashObject takes map\\[string]interface{} and keys from \\[]string and returns hash string from given keys from map\n\n```go\nfunc HashStrings(strs []string) int\n```\nHashStrings - returns unique Hash for strings array This value is supposed to be used as ID (negative) to mark it was artificially generated\n\n```go\nfunc HourStart(dt time.Time) time.Time\n```\nHourStart - return time rounded to current hour start\n\n```go\nfunc InsertIgnore(query string) string\n```\nInsertIgnore - will return insert statement with ignore option specific for DB\n\n```go\nfunc IntOrNil(intPtr *int) interface{}\n```\nIntOrNil - return either nil or value of intPtr\n\n```go\nfunc IsProjectDisabled(ctx *Ctx, proj string, yamlDisabled bool) bool\n```\nIsProjectDisabled - checks if project is disabled or not: fullName comes from makeOldRepoName for pre-2015 data! yamlDisabled (this is from projects.yaml - can be true or false) it also checks context (which can override \\`disabled: true\\` from projects.yaml) +pro1,-pro2 creates map {\"pro1\":true, \"pro2\":false}\n\n```go\nfunc IssueIDOrNil(issuePtr *Issue) interface{}\n```\nIssueIDOrNil - return Issue ID from pointer or nil\n\n```go\nfunc MakeOldRepoName(repo *ForkeeOld) string\n```\nMakeOldRepoName - before 2015 repository name should be Organization/Name (if Organization present) or just Name\n\n```go\nfunc MakeUniqueSort(ary []string) (outAry []string)\n```\nMakeUniqueSort - make string array unique \u0026 sorted\n\n```go\nfunc MapFromString(str string) map[string]string\n```\nMapFromString - returns maps from string formatted as map\\[k1:v1 k2:v2 k3:v3 ...]\n\n```go\nfunc MaybeHideFunc(shas map[string]string) func(string) string\n```\nMaybeHideFunc - use closure as a data storage\n\n```go\nfunc Mgetc(ctx *Ctx) string\n```\nMgetc waits for single key press and return character pressed\n\n```go\nfunc MilestoneIDOrNil(milPtr *Milestone) interface{}\n```\nMilestoneIDOrNil - return Milestone ID from pointer or nil\n\n```go\nfunc MonthStart(dt time.Time) time.Time\n```\nMonthStart - return time rounded to current month start\n\n```go\nfunc NValue(index int) string\n```\nNValue will return $n\n\n```go\nfunc NValues(n int) string\n```\nNValues will return values($1, $2, .., $n)\n\n```go\nfunc NegatedBoolOrNil(boolPtr *bool) interface{}\n```\nNegatedBoolOrNil - return either nil or negated value of boolPtr\n\n```go\nfunc NextDayStart(dt time.Time) time.Time\n```\nNextDayStart - return time rounded to next day start\n\n```go\nfunc NextHourStart(dt time.Time) time.Time\n```\nNextHourStart - return time rounded to next hour start\n\n```go\nfunc NextMonthStart(dt time.Time) time.Time\n```\nNextMonthStart - return time rounded to next month start\n\n```go\nfunc NextQuarterStart(dt time.Time) time.Time\n```\nNextQuarterStart - return time rounded to next quarter start\n\n```go\nfunc NextWeekStart(dt time.Time) time.Time\n```\nNextWeekStart - return time rounded to next week start\n\n```go\nfunc NextYearStart(dt time.Time) time.Time\n```\nNextYearStart - return time rounded to next year start\n\n```go\nfunc NormalizeName(str string) string\n```\nNormalizeName - clean DB string from \", ', -, /, ., \" \",), (, ], \\[ trim leading and trailing space, lowercase Normalize Unicode characters\n\n```go\nfunc ObjectToJSON(obj interface{}, fn string)\n```\nObjectToJSON - serialize given object as JSON\n\n```go\nfunc ObjectToYAML(obj interface{}, fn string)\n```\nObjectToYAML - serialize given object as YAML\n\n```go\nfunc OrgIDOrNil(orgPtr *Org) interface{}\n```\nOrgIDOrNil - return Org ID from pointer or nil\n\n```go\nfunc OrgLoginOrNil(orgPtr *Org) interface{}\n```\nOrgLoginOrNil - return Org ID from pointer or nil\n\n```go\nfunc PeriodParse(perStr string) (dur time.Duration, ok bool)\n```\nPeriodParse - tries to parse period\n\n```go\nfunc PgConn(ctx *Ctx) *sql.DB\n```\nPgConn Connects to Postgres database\n\n```go\nfunc PgConnDB(ctx *Ctx, dbName string) *sql.DB\n```\nPgConnDB Connects to Postgres database (with specific DB name) uses database 'dbname' instead of 'PgDB'\n\n```go\nfunc PrepareQuickRangeQuery(sql, period, from, to string) string\n```\nPrepareQuickRangeQuery Perpares query using either ready \\`period\\` string or using \\`from\\` and \\`to\\` strings Values to replace are specially encoded {{period:alias.column}} Can either replace with: (alias.column \u003e= now() - 'period'::interval) Or (alias.column \u003e= 'from' and alias.column \\\u003c 'to')\n\n```go\nfunc PrettyPrintJSON(jsonBytes []byte) []byte\n```\nPrettyPrintJSON - pretty formats raw JSON bytes\n\n```go\nfunc PrevDayStart(dt time.Time) time.Time\n```\nPrevDayStart - return time rounded to prev day start\n\n```go\nfunc PrevHourStart(dt time.Time) time.Time\n```\nPrevHourStart - return time rounded to prev hour start\n\n```go\nfunc PrevMonthStart(dt time.Time) time.Time\n```\nPrevMonthStart - return time rounded to prev month start\n\n```go\nfunc PrevQuarterStart(dt time.Time) time.Time\n```\nPrevQuarterStart - return time rounded to prev quarter start\n\n```go\nfunc PrevWeekStart(dt time.Time) time.Time\n```\nPrevWeekStart - return time rounded to prev week start\n\n```go\nfunc PrevYearStart(dt time.Time) time.Time\n```\nPrevYearStart - return time rounded to prev year start\n\n```go\nfunc Printf(format string, args ...interface{}) (n int, err error)\n```\nPrintf is a wrapper around Printf(...) that supports logging.\n\n```go\nfunc ProcessAnnotations(ctx *Ctx, annotations *Annotations, startDate, joinDate *time.Time)\n```\nProcessAnnotations Creates IfluxDB annotations and quick\\_series\n\n```go\nfunc ProcessTag(con *sql.DB, es *ES, ctx *Ctx, tg *Tag, replaces [][]string)\n```\nProcessTag - insert given Tag into Postgres TSDB\n\n```go\nfunc ProgressInfo(i, n int, start time.Time, last *time.Time, period time.Duration, msg string)\n```\nProgressInfo display info about progress: i/n if current time \u003e= last + period If displayed info, update last\n\n```go\nfunc PullRequestIDOrNil(prPtr *PullRequest) interface{}\n```\nPullRequestIDOrNil - return PullRequest ID from pointer or nil\n\n```go\nfunc QuarterStart(dt time.Time) time.Time\n```\nQuarterStart - return time rounded to current month start\n\n```go\nfunc QueryRowSQL(con *sql.DB, ctx *Ctx, query string, args ...interface{}) *sql.Row\n```\nQueryRowSQL executes given SQL on Postgres DB (and returns single row)\n\n```go\nfunc QueryRowSQLTx(tx *sql.Tx, ctx *Ctx, query string, args ...interface{}) *sql.Row\n```\nQueryRowSQLTx executes given SQL on Postgres DB (and returns single row)\n\n```go\nfunc QuerySQL(con *sql.DB, ctx *Ctx, query string, args ...interface{}) (*sql.Rows, error)\n```\nQuerySQL executes given SQL on Postgres DB (and returns rowset that needs to be closed)\n\n```go\nfunc QuerySQLTx(con *sql.Tx, ctx *Ctx, query string, args ...interface{}) (*sql.Rows, error)\n```\nQuerySQLTx executes given SQL on Postgres DB (and returns rowset that needs to be closed) It is for running inside transaction\n\n```go\nfunc QuerySQLTxWithErr(con *sql.Tx, ctx *Ctx, query string, args ...interface{}) *sql.Rows\n```\nQuerySQLTxWithErr wrapper to QuerySQLTx that exists on error It is for running inside transaction\n\n```go\nfunc QuerySQLWithErr(con *sql.DB, ctx *Ctx, query string, args ...interface{}) *sql.Rows\n```\nQuerySQLWithErr wrapper to QuerySQL that exists on error\n\n```go\nfunc ReadFile(ctx *Ctx, path string) ([]byte, error)\n```\nReadFile tries to read any filename, but have a fallback it attempts to replace current project name with shared: /proj/ -\u003e /shared/ This is to allow reading files that can be shared between projects\n\n```go\nfunc ReleaseIDOrNil(relPtr *Release) interface{}\n```\nReleaseIDOrNil - return Release ID from pointer or nil\n\n```go\nfunc RepoHit(ctx *Ctx, fullName string, forg, frepo map[string]struct{}) bool\n```\nRepoHit - are we interested in this org/repo ?\n\n```go\nfunc RepoIDOrNil(repoPtr *Repo) interface{}\n```\nRepoIDOrNil - return Repo ID from pointer or nil\n\n```go\nfunc RepoNameOrNil(repoPtr *Repo) interface{}\n```\nRepoNameOrNil - return Repo Name from pointer or nil\n\n```go\nfunc SkipEmpty(arr []string) []string\n```\nSkipEmpty - skip one element arrays contining only empty string This is what strings.Split() returns for empty input We expect empty array or empty map returned in such cases\n\n```go\nfunc Slugify(arg string) string\n```\nSlugify replace all whitespace with \"-\", remove all non-word letters downcase\n\n```go\nfunc StringOrNil(strPtr *string) interface{}\n```\nStringOrNil - return either nil or value of strPtr\n\n```go\nfunc StringsMapToArray(f func(string) string, strArr []string) []string\n```\nStringsMapToArray this is a function that calls given function for all array items and returns array of items processed by this func Example call: lib.StringsMapToArray(func(x string) string { return strings.TrimSpace(x) }, \\[]string{\" a\", \" b \", \"c \"})\n\n```go\nfunc StringsMapToSet(f func(string) string, strArr []string) map[string]struct{}\n```\nStringsMapToSet this is a function that calls given function for all array items and returns set of items processed by this func Example call: lib.StringsMapToSet(func(x string) string { return strings.TrimSpace(x) }, \\[]string{\" a\", \" b \", \"c \"})\n\n```go\nfunc StringsSetKeys(set map[string]struct{}) []string\n```\nStringsSetKeys - returns all keys from string map\n\n```go\nfunc StripUnicode(str string) string\n```\nStripUnicode strip non-unicode and control characters from a string From: [https://rosettacode.org/wiki/Strip\\_control\\_codes\\_and\\_extended\\_characters\\_from\\_a\\_string#Go](https://rosettacode.org/wiki/Strip_control_codes_and_extended_characters_from_a_string#Go)\n\n```go\nfunc Structure(ctx *Ctx)\n```\nStructure creates full database structure, indexes, views/summary tables etc\n\n```go\nfunc SyncIssuesState(gctx context.Context, gc []*github.Client, ctx *Ctx, c *sql.DB, issues map[int64]IssueConfigAry, prs map[int64]github.PullRequest, manual bool)\n```\nSyncIssuesState synchonizes issues states manual:\n\n\tfalse: normal devstats sync cron mode using 'ghapi2db' tool\n\ttrue: manual sync using 'sync_issues' tool\n\n```go\nfunc TableColumnExists(con *sql.DB, ctx *Ctx, tableName, columnName string) bool\n```\nTableColumnExists - checks if a given table's has a given column\n\n```go\nfunc TableExists(con *sql.DB, ctx *Ctx, tableName string) bool\n```\nTableExists - checks if a given table exists\n\n```go\nfunc TimeOrNil(timePtr *time.Time) interface{}\n```\nTimeOrNil - return either nil or value of timePtr\n\n```go\nfunc TimeParseAny(dtStr string) time.Time\n```\nTimeParseAny - attempts to parse time from string YYYY-MM-DD HH:MI:SS Skipping parts from right until only YYYY id left\n\n```go\nfunc ToGHADate(dt time.Time) string\n```\nToGHADate - return time formatted as YYYY-MM-DD-H\n\n```go\nfunc ToYMDDate(dt time.Time) string\n```\nToYMDDate - return time formatted as YYYY-MM-DD\n\n```go\nfunc ToYMDHDate(dt time.Time) string\n```\nToYMDHDate - return time formatted as YYYY-MM-DD HH\n\n```go\nfunc ToYMDHMSDate(dt time.Time) string\n```\nToYMDHMSDate - return time formatted as YYYY-MM-DD HH:MI:SS\n\n```go\nfunc TruncStringOrNil(strPtr *string, maxLen int) interface{}\n```\nTruncStringOrNil - return either nil or value of strPtr truncated to maxLen chars\n\n```go\nfunc TruncToBytes(str string, size int) string\n```\nTruncToBytes - truncates text to \\\u003c= size bytes (note that this can be a lot less UTF-8 runes)\n\n```go\nfunc WeekStart(dt time.Time) time.Time\n```\nWeekStart - return time rounded to current week start Assumes first week day is Sunday\n\n```go\nfunc WriteTSPoints(ctx *Ctx, con *sql.DB, pts *TSPoints, mergeSeries string, mut *sync.Mutex)\n```\nWriteTSPoints write batch of points to postgresql use mergeSeries = \"name\" to put all series in \"name\" table, and create \"series\" column that conatins all point names.\n\n\twithout merge, alee names will create separate tables.\n\nuse non-null mut when you are using this function from multiple threads that write to the same series name at the same time\n\n\tuse non-null mut only then.\n\nNo more giant lock approach here, but it is up to user to spcify call context, especially 2 last parameters!\n\n```go\nfunc YearStart(dt time.Time) time.Time\n```\nYearStart - return time rounded to current month start\n\n## Types\n\n```go\ntype Actor struct {\n\tID    int    `json:\"id\"`\n\tLogin string `json:\"login\"`\n\tName  string `json:\"-\"`\n}\n```\nActor - GHA Actor structure Name is unexported and not used by JSON load/save But is used when importing affiliations from cncf/gitdm:github\\_users.json\n\n```go\ntype AllProjects struct {\n\tProjects map[string]Project `yaml:\"projects\"`\n}\n```\nAllProjects contain all projects data\n\n```go\ntype Annotation struct {\n\tName        string\n\tDescription string\n\tDate        time.Time\n}\n```\nAnnotation contain each annotation data\n\n```go\ntype Annotations struct {\n\tAnnotations []Annotation\n}\n```\nAnnotations contain list of annotations\n\n```go\nfunc GetAnnotations(ctx *Ctx, orgRepo, annoRegexp string) (annotations Annotations)\n```\nGetAnnotations queries uses \\`git\\` to get \\`orgRepo\\` all tags list for all tags and returns those matching \\`annoRegexp\\`\n\n```go\nfunc GetFakeAnnotations(startDate, joinDate time.Time) (annotations Annotations)\n```\nGetFakeAnnotations - returns 'startDate - joinDate' and 'joinDate - now' annotations\n\n```go\ntype AnnotationsByDate []Annotation\n```\nAnnotationsByDate annotations Sort interface\n\n```go\nfunc (a AnnotationsByDate) Len() int\n```\n\n```go\nfunc (a AnnotationsByDate) Less(i, j int) bool\n```\n\n```go\nfunc (a AnnotationsByDate) Swap(i, j int)\n```\n\n```go\ntype AnyArray []interface{}\n```\nAnyArray - holds array of interface{} - just a shortcut\n\n```go\ntype Asset struct {\n\tID            int       `json:\"id\"`\n\tCreatedAt     time.Time `json:\"created_at\"`\n\tUpdatedAt     time.Time `json:\"updated_at\"`\n\tName          string    `json:\"name\"`\n\tLabel         *string   `json:\"label\"`\n\tUploader      Actor     `json:\"uploader\"`\n\tContentType   string    `json:\"content_type\"`\n\tState         string    `json:\"state\"`\n\tSize          int       `json:\"size\"`\n\tDownloadCount int       `json:\"download_count\"`\n}\n```\nAsset - GHA Asset structure\n\n```go\ntype Author struct {\n\tName  string `json:\"name\"`\n\tEmail string `json:\"email\"`\n}\n```\nAuthor - GHA Commit Author structure\n\n```go\ntype Branch struct {\n\tSHA   string  `json:\"sha\"`\n\tUser  *Actor  `json:\"user\"`\n\tRepo  *Forkee `json:\"repo\"` // This is confusing, but actually GHA has \"repo\" fields that holds \"forkee\" structure\n\tLabel string  `json:\"label\"`\n\tRef   string  `json:\"ref\"`\n}\n```\nBranch - GHA Branch structure\n\n```go\ntype Comment struct {\n\tID                  int       `json:\"id\"`\n\tBody                string    `json:\"body\"`\n\tCreatedAt           time.Time `json:\"created_at\"`\n\tUpdatedAt           time.Time `json:\"updated_at\"`\n\tUser                Actor     `json:\"user\"`\n\tCommitID            *string   `json:\"commit_id\"`\n\tOriginalCommitID    *string   `json:\"original_commit_id\"`\n\tDiffHunk            *string   `json:\"diff_hunk\"`\n\tPosition            *int      `json:\"position\"`\n\tOriginalPosition    *int      `json:\"original_position\"`\n\tPath                *string   `json:\"path\"`\n\tPullRequestReviewID *int      `json:\"pull_request_review_id\"`\n\tLine                *int      `json:\"line\"`\n}\n```\nComment - GHA Comment structure\n\n```go\ntype Commit struct {\n\tSHA      string `json:\"sha\"`\n\tAuthor   Author `json:\"author\"`\n\tMessage  string `json:\"message\"`\n\tDistinct bool   `json:\"distinct\"`\n}\n```\nCommit - GHA Commit structure\n\n```go\ntype Ctx struct {\n\tDataDir             string                       // From GHA2DB_DATADIR, default /etc/gha2db/\n\tDebug               int                          // From GHA2DB_DEBUG Debug level: 0-no, 1-info, 2-verbose, including SQLs, default 0\n\tCmdDebug            int                          // From GHA2DB_CMDDEBUG Commands execution Debug level: 0-no, 1-only output commands, 2-output commands and their output, 3-output full environment as well, default 0\n\tGitHubDebug         int                          // From GHA2DB_GITHUB_DEBUG debug GitHub rate limits\n\tDryRun              bool                         // From GHA2DB_DRY_RUN, import_affs tool - stop before doing any updates\n\tJSONOut             bool                         // From GHA2DB_JSON gha2db: write JSON files? default false\n\tDBOut               bool                         // From GHA2DB_NODB gha2db: write to SQL database, default true\n\tST                  bool                         // From GHA2DB_ST true: use single threaded version, false: use multi threaded version, default false\n\tNCPUs               int                          // From GHA2DB_NCPUS, set to override number of CPUs to run, this overwrites GHA2DB_ST, default 0 (which means do not use it)\n\tPgHost              string                       // From PG_HOST, default \"localhost\"\n\tPgPort              string                       // From PG_PORT, default \"5432\"\n\tPgDB                string                       // From PG_DB, default \"gha\"\n\tPgUser              string                       // From PG_USER, default \"gha_admin\"\n\tPgPass              string                       // From PG_PASS, default \"password\"\n\tPgSSL               string                       // From PG_SSL, default \"disable\"\n\tIndex               bool                         // From GHA2DB_INDEX Create DB index? default false\n\tTable               bool                         // From GHA2DB_SKIPTABLE Create table structure? default true\n\tTools               bool                         // From GHA2DB_SKIPTOOLS Create DB tools (like views, summary tables, materialized views etc)? default true\n\tMgetc               string                       // From GHA2DB_MGETC Character returned by mgetc (if non empty), default \"\"\n\tQOut                bool                         // From GHA2DB_QOUT output all SQL queries?, default false\n\tCtxOut              bool                         // From GHA2DB_CTXOUT output all context data (this struct), default false\n\tLogTime             bool                         // From GHA2DB_SKIPTIME, output time with all lib.Printf(...) calls, default true, use GHA2DB_SKIPTIME to disable\n\tDefaultStartDate    time.Time                    // From GHA2DB_STARTDT, default `2012-07-01 00:00 UTC`, expects format \"YYYY-MM-DD HH:MI:SS\", can be set in `projects.yaml` via `start_date:`, value from projects.yaml (if set) has the highest priority.\n\tForceStartDate      bool                         // From GHA2DB_STARTDT_FORCE, default false\n\tLastSeries          string                       // From GHA2DB_LASTSERIES, use this TSDB series to determine last timestamp date, default \"events_h\"\n\tSkipTSDB            bool                         // From GHA2DB_SKIPTSDB gha2db_sync tool, skip TS DB processing? for calc_metric it skips final series write, default false\n\tSkipPDB             bool                         // From GHA2DB_SKIPPDB gha2db_sync tool, skip Postgres DB processing (gha2db part) default false\n\tResetTSDB           bool                         // From GHA2DB_RESETTSDB sync tool, regenerate all TS points? default false\n\tResetRanges         bool                         // From GHA2DB_RESETRANGES sync tool, regenerate all past quick ranges? default false\n\tExplain             bool                         // From GHA2DB_EXPLAIN runq tool, prefix query with \"explain \" - it will display query plan instead of executing real query, default false\n\tOldFormat           bool                         // From GHA2DB_OLDFMT gha2db tool, if set then use pre 2015 GHA JSONs format\n\tExact               bool                         // From GHA2DB_EXACT gha2db tool, if set then orgs list provided from commandline is used as a list of exact repository full names, like \"a/b,c/d,e\", if not only full names \"a/b,x/y\" can be treated like this, names without \"/\" are either orgs or repos.\n\tLogToDB             bool                         // From GHA2DB_SKIPLOG all tools, if set, DB logging into Postgres table `gha_logs` in `devstats` database will be disabled\n\tLocal               bool                         // From GHA2DB_LOCAL many tools, if set it will use data files prefixed with \"./\" to use local ones. Otherwise it will search for data files in /etc/gha2db.\n\tLocalCmd            bool                         // From GHA2DB_LOCAL_CMD many tools, if set it will call other tools prefixed with \"./\" to use locally compiled ones. Otherwise it will call binaries without prefix (so it will use those in $PATH).\n\tMetricsYaml         string                       // From GHA2DB_METRICS_YAML gha2db_sync tool, set other metrics.yaml file, default is \"metrics/{{project}}metrics.yaml\"\n\tTagsYaml            string                       // From GHA2DB_TAGS_YAML tags tool, set other tags.yaml file, default is \"metrics/{{project}}/tags.yaml\"\n\tColumnsYaml         string                       // From GHA2DB_COLUMNS_YAML tags tool, set other columns.yaml file, default is \"metrics/{{project}}/columns.yaml\"\n\tVarsYaml            string                       // From GHA2DB_VARS_YAML db_vars tool, set other vars.yaml file (full path), default is \"metrics/{{project}}/vars.yaml\"\n\tVarsFnYaml          string                       // From GHA2DB_VARS_FN_YAML db_vars tool, set other vars.yaml file (final file name without path), default is \"vars.yaml\"\n\tSkipDatesYaml       string                       // From GHA2DB_SKIP_DATES_YAML gha2db tool, set other skip_dates.yaml file, default is \"skip_dates.yaml\"\n\tGitHubOAuth         string                       // From GHA2DB_GITHUB_OAUTH ghapi2db tool, if not set reads from /etc/github/oauth file, set to \"-\" to force public access.\n\tClearDBPeriod       string                       // From GHA2DB_MAXLOGAGE gha2db_sync tool, maximum age of devstats.gha_logs entries, default \"1 week\"\n\tTrials              []int                        // From GHA2DB_TRIALS, all Postgres related tools, retry periods for \"too many connections open\" error\n\tWebHookRoot         string                       // From GHA2DB_WHROOT, webhook tool, default \"/hook\", must match .travis.yml notifications webhooks\n\tWebHookPort         string                       // From GHA2DB_WHPORT, webhook tool, default \":1982\", note that webhook listens using http:1982, but we use apache on https:2982 (to enable https protocol and proxy requests to http:1982)\n\tWebHookHost         string                       // From GHA2DB_WHHOST, webhook tool, default \"127.0.0.1\" (this can be localhost to disable access by IP, we use Apache proxy to enable https and then apache only need 127.0.0.1)\n\tCheckPayload        bool                         // From GHA2DB_SKIP_VERIFY_PAYLOAD, webhook tool, default true, use GHA2DB_SKIP_VERIFY_PAYLOAD=1 to manually test payloads\n\tFullDeploy          bool                         // From GHA2DB_SKIP_FULL_DEPLOY, webhook tool, default true, use GHA2DB_SKIP_FULL_DEPLOY=1 to ignore \"[deploy]\" requests that call `./devel/deploy_all.sh`.\n\tDeployBranches      []string                     // From GHA2DB_DEPLOY_BRANCHES, webhook tool, default \"master\" - comma separated list\n\tDeployStatuses      []string                     // From GHA2DB_DEPLOY_STATUSES, webhook tool, default \"Passed,Fixed\", - comma separated list\n\tDeployResults       []int                        // From GHA2DB_DEPLOY_RESULTS, webhook tool, default \"0\", - comma separated list\n\tDeployTypes         []string                     // From GHA2DB_DEPLOY_TYPES, webhook tool, default \"push\", - comma separated list\n\tProjectRoot         string                       // From GHA2DB_PROJECT_ROOT, webhook tool, no default, must be specified to run webhook tool\n\tExecFatal           bool                         // default true, set this manually to false to avoid lib.ExecCommand calling os.Exit() on failure and return error instead\n\tExecQuiet           bool                         // default false, set this manually to true to have quite exec failures (for example `get_repos` git-clones or git-pulls on errors).\n\tExecOutput          bool                         // default false, set to true to capture commands STDOUT\n\tProject             string                       // From GHA2DB_PROJECT, gha2db_sync default \"\", You should set it to something like \"kubernetes\", \"prometheus\" etc.\n\tTestsYaml           string                       // From GHA2DB_TESTS_YAML ./dbtest.sh tool, set other tests.yaml file, default is \"tests.yaml\"\n\tReposDir            string                       // From GHA2DB_REPOS_DIR get_repos tool, default \"~/devstats_repos/\"\n\tProcessRepos        bool                         // From GHA2DB_PROCESS_REPOS get_repos tool, enable processing (cloning/pulling) all devstats repos, default false\n\tProcessCommits      bool                         // From GHA2DB_PROCESS_COMMITS get_repos tool, enable update/create mapping table: commit - list of file that commit refers to, default false\n\tExternalInfo        bool                         // From GHA2DB_EXTERNAL_INFO get_repos tool, enable outputing data needed by external tools (cncf/gitdm), default false\n\tProjectsCommits     string                       // From GHA2DB_PROJECTS_COMMITS get_repos tool, set list of projects for commits analysis instead of analysing all, default \"\" - means all\n\tPropagateOnlyVar    bool                         // From GHA2DB_PROPAGATE_ONLY_VAR, if set the it will check ONLY=\"a b c\" env variable and propagate it into other project filter variables if they're not set, for example GHA2DB_PROJECTS_COMMITS\n\tProjectsYaml        string                       // From GHA2DB_PROJECTS_YAML, many tools - set main projects file, default \"projects.yaml\"\n\tCompanyAcqYaml      string                       // From GHA2DB_COMPANY_ACQ_YAML, import_affs tool, set non-standard \"companies.yaml\" file\n\tProjectsOverride    map[string]bool              // From GHA2DB_PROJECTS_OVERRIDE, get_repos and ./devstats tools - for example \"-pro1,+pro2\" means never sync pro1 and always sync pro2 (even if disabled in `projects.yaml`).\n\tAffiliationsJSON    string                       // From GHA2DB_AFFILIATIONS_JSON, import_affs tool - set main affiliations file, default \"github_users.json\"\n\tExcludeRepos        map[string]bool              // From GHA2DB_EXCLUDE_REPOS, gha2db tool, default \"\" - comma separated list of repos to exclude, example: \"theupdateframework/notary,theupdateframework/other\"\n\tInputDBs            []string                     // From GHA2DB_INPUT_DBS, merge_dbs tool - list of input databases to merge, order matters - first one will insert on a clean DB, next will do insert ignore (to avoid constraints failure due to common data)\n\tOutputDB            string                       // From GHA2DB_OUTPUT_DB, merge_dbs tool - output database to merge into\n\tTmOffset            int                          // From GHA2DB_TMOFFSET, gha2db_sync tool - uses time offset to decide when to calculate various metrics, default offset is 0 which means UTC, good offset for USA is -6, and for Poland is 1 or 2\n\tDefaultHostname     string                       // \"devstats.cncf.io\"\n\tRecentRange         string                       // From GHA2DB_RECENT_RANGE, ghapi2db tool, default '2 hours'. This is a recent period to check open issues/PR to fix their labels and milestones.\n\tRecentReposRange    string                       // From GHA2DB_RECENT_REPOS_RANGE, ghapi2db tool, default '1 day'. This is a recent period to check modified repositories.\n\tMinGHAPIPoints      int                          // From GHA2DB_MIN_GHAPI_POINTS, ghapi2db tool, minimum GitHub API points, before waiting for reset.\n\tMaxGHAPIWaitSeconds int                          // From GHA2DB_MAX_GHAPI_WAIT, ghapi2db tool, maximum wait time for GitHub API points reset (in seconds).\n\tMaxGHAPIRetry       int                          // From GHA2DB_MAX_GHAPI_RETRY, ghapi2db tool, maximum wait retries\n\tGHAPIErrorIsFatal   bool                         // From GHA2DB_GHAPI_ERROR_FATAL, ghapi2db tool, make any GH API error fatal, default false\n\tSkipGHAPI           bool                         // From GHA2DB_GHAPISKIP, ghapi2db tool, if set then tool is skipping GH API calls (all: events (artificial events to make sure we are in sync with GH) and commits (enriches obfuscated GHA commits data)\n\tSkipAPIEvents       bool                         // From GHA2DB_GHAPISKIPEVENTS, ghapi2db tool, if set then tool is skipping GH API events sync\n\tSkipAPICommits      bool                         // From GHA2DB_GHAPISKIPCOMMITS, ghapi2db tool, if set then tool is skipping GH API commits enrichment\n\tSkipGetRepos        bool                         // From GHA2DB_GETREPOSSKIP, get_repos tool, if set then tool does nothing\n\tCSVFile             string                       // From GHA2DB_CSVOUT, runq tool, if set, saves result in this file\n\tComputeAll          bool                         // From GHA2DB_COMPUTE_ALL, all tools, if set then no period decisions are taken based on time, but all possible periods are recalculated\n\tActorsFilter        bool                         // From GHA2DB_ACTORS_FILTER gha2db tool, if enabled then actor filterning will be added, default false\n\tActorsAllow         *regexp.Regexp               // From GHA2DB_ACTORS_ALLOW, gha2db tool, process JSON if actor matches this regexp, default \"\" which means skip this check\n\tActorsForbid        *regexp.Regexp               // From GHA2DB_ACTORS_FORBID, gha2db tool, process JSON if actor doesn't match this regexp, default \"\" which means skip this check\n\tSkipMetrics         map[string]bool              // From GHA2DB_SKIP_METRICS, gha2db_sync tool, default \"\" - comma separated list of metrics to skip, as given by \"sql: name\" in the \"metrics.yaml\" file. Those metrics will be skipped.\n\tOnlyMetrics         map[string]bool              // From GHA2DB_ONLY_METRICS, gha2db_sync tool, default \"\" - comma separated list of metrics to process, as given by \"sql: name\" in the \"metrics.yaml\" file. Only those metrics will be calculated.\n\tAllowBrokenJSON     bool                         // From GHA2DB_ALLOW_BROKEN_JSON, gha2db tool, default false. If set then gha2db skips broken jsons and saves them as jsons/error_YYYY-MM-DD-h-n-m.json (n is the JSON number (1-m) of m JSONS array)\n\tJSONsDir            string                       // From GHA2DB_JSONS_DIR, website_data tool, default \"./jsons/\"\n\tWebsiteData         bool                         // From GHA2DB_WEBSITEDATA, devstats tool, run website_data just after sync is complete, default false.\n\tSkipUpdateEvents    bool                         // From GHA2DB_SKIP_UPDATE_EVENTS, ghapi2db tool, drop and recreate artificial events if their state differs, default false\n\tComputePeriods      map[string]map[bool]struct{} // From GHA2DB_FORCE_PERIODS, gha2db_sync tool, force recompute only given periods, \"y10:t,m:f,...\", default \"\"\n\tAutoFetchCommits    bool                         // From GHA2DB_NO_AUTOFETCHCOMMITS, ghapi2db, disable fetching from last enriched commit data, it will fetch from 'RecentRange instead, AutoFetchCommits is enabled by default\n\tSkipTags            bool                         // From GHA2DB_SKIP_TAGS, gha2db_sync tool, skip calling tags tool, default false\n\tSkipAnnotations     bool                         // From GHA2DB_SKIP_ANNOTATIONS, gha2db_sync tool, skip calling annotations tool, default false\n\tSkipColumns         bool                         // From GHA2DB_SKIP_COLUMNS, gha2db_sync tool, skip calling columns tool, default false\n\tRunColumns          bool                         // From GHA2DB_RUN_COLUMNS, gha2db_sync tool, force calling columns tool, default false\n\tSkipVars            bool                         // From GHA2DB_SKIP_VARS, gha2db_sync tool, skip calling vars tool, default false\n\tExcludeVars         map[string]bool              // From GHA2DB_EXCLUDE_VARS, vars tool, default \"\" - comma separated list of variable names to exclude, example: \"hostname,projects_health_partial_html\"\n\tOnlyVars            map[string]bool              // From GHA2DB_ONLY_VARS, vars tool, default \"\" - comma separated list of variable names to write (and skip all others): \"hostname,projects_health_partial_html\", not used if empty\n\tElasticURL          string                       // From GHA2DB_ES_URL, calc_metric, tags, annotations tools - ElasticSearch URL (if used), default http://127.0.0.1:9200\n\tUseES               bool                         // From GHA2DB_USE_ES, calc_metric, tags, annotations tools - enable ElasticSearch, default false\n\tUseESOnly           bool                         // From GHA2DB_USE_ES_ONLY, calc_metric, annotations tools - enable ElasticSearch and do not write PSQL TSDB, default false\n\tUseESRaw            bool                         // From GHA2DB_USE_ES_RAW, gha2es, gha2db_sync tools - enable generating RAW ElasticSearch data (directly from gha_tables instead of aggregated data from TSDB)\n\tResetESRaw          bool                         // From GHA2DB_RESET_ES_RAW, gha2db_sync tools - generate RAW ES index from project start date\n\tSkipSharedDB        bool                         // From GHA2DB_SKIP_SHAREDDB, annotations tool, default false, will skip writing to shared_db (from projects.yaml) if set\n\tSkipPIDFile         bool                         // From GHA2DB_SKIP_PIDFILE, devstats tool, skip creating, checking and removing PID file\n\tSkipCompanyAcq      bool                         // From GHA2DB_SKIP_COMPANY_ACQ, import_affs tool, skip processing company acquisitions from companies.yaml file\n\tCheckProvisionFlag  bool                         // From GHA2DB_CHECK_PROVISION_FLAG, devstats tool - check if there is a 'provision' metric saved in 'gha_computed' table - if not, abort\n\tCheckRunningFlag    bool                         // From GHA2DB_CHECK_RUNNING_FLAG, devstats tool - check if there is a 'devstats_running' metric saved in 'gha_computed' table - if yes, abort\n\tSetRunningFlag      bool                         // From GHA2DB_SET_RUNNING_FLAG, devstats tool - set 'devstats_running' flag on 'gha_computed' table while devstats cronjob is running\n\tESBulkSize          int                          // From GHA2DB_ES_BULK_SIZE, calc_metric and gha2es tools, default 10000\n\tHTTPTimeout         int                          // From GHA2DB_HTTP_TIMEOUT, gha2db - data.gharchive.org timeout value in minutes, default 2\n\tPidFileRoot         string                       // From GHA2DB_PID_FILE_ROOT, devstats tool, use '/tmp/PidFileRoot.pid' as PID file, default 'devstats' -\u003e '/tmp/devstats.pid'\n\tSharedDB            string                       // Currently annotations tool read this from projects.yaml:shared_db and if set, outputs annotations data to the sharded DB in addition to the current DB\n\tProjectMainRepo     string                       // Used by annotations tool to store project's main repo name\n\tTestMode            bool                         // True when running tests\n}\n```\nCtx - environment context packed in structure\n\n```go\nfunc (ctx *Ctx) Init()\n```\nInit - get context from environment variables\n\n```go\nfunc (ctx *Ctx) Print()\n```\nPrint context contents\n\n```go\ntype Dummy struct{}\n```\nDummy - structure with no data pointer to this struct is used to test if such field was present in JSON or not\n\n```go\ntype ES struct {\n\t// contains filtered or unexported fields\n}\n```\nES - ElasticSearch connection client, context and default mapping\n\n```go\nfunc ESConn(ctx *Ctx, prefix string) *ES\n```\nESConn Connects to ElasticSearch\n\n```go\nfunc (es *ES) AddBulksItems(ctx *Ctx, b *ESBulks, doc map[string]interface{}, keys []string)\n```\nAddBulksItems adds items to the Bulk Request\n\n```go\nfunc (es *ES) AddBulksItemsI(ctx *Ctx, b *ESBulks, doc interface{}, docHash string)\n```\nAddBulksItemsI adds items to the Bulk Request\n\n```go\nfunc (es *ES) Bulks() (*elastic.BulkService, *elastic.BulkService)\n```\nBulks returns Delete and Add requests\n\n```go\nfunc (es *ES) CreateIndex(ctx *Ctx, raw bool)\n```\nCreateIndex creates index\n\n```go\nfunc (es *ES) DeleteByQuery(ctx *Ctx, propNames []string, propValues []interface{})\n```\nDeleteByQuery deletes data from given index \u0026 type by simple bool query\n\n```go\nfunc (es *ES) DeleteByWildcardQuery(ctx *Ctx, propName, propQuery string)\n```\nDeleteByWildcardQuery deletes data from given index \u0026 type by using wildcard query\n\n```go\nfunc (es *ES) ESEscapeFieldName(fieldName string) string\n```\nESEscapeFieldName escape characters non allowed in ES field names\n\n```go\nfunc (es *ES) ESIndexName(ctx *Ctx) string\n```\nESIndexName returns ES index name \"d\\_{{project}}\" --\u003e \"d\\_kubernetes\"\n\n```go\nfunc (es *ES) ExecuteBulkAdd(ctx *Ctx, bulkAdd *elastic.BulkService)\n```\nExecuteBulkAdd executes scheduled commands (delete and then inserts)\n\n```go\nfunc (es *ES) ExecuteBulkDel(ctx *Ctx, bulkDel *elastic.BulkService)\n```\nExecuteBulkDel executes scheduled commands (delete and then inserts)\n\n```go\nfunc (es *ES) ExecuteBulks(ctx *Ctx, b *ESBulks)\n```\nExecuteBulks executes scheduled commands (delete and then inserts)\n\n```go\nfunc (es *ES) GetElasticClient() *elastic.Client\n```\nGetElasticClient - returns embedded ES client\n\n```go\nfunc (es *ES) IndexExists(ctx *Ctx) bool\n```\nIndexExists checks if index exists\n\n```go\nfunc (es *ES) WriteESPoints(ctx *Ctx, pts *TSPoints, mergeS string, outputs [3]bool)\n```\nWriteESPoints write batch of points to postgresql outputs\\[0] - output using variable column name (1 doc) \\[used by annotations, tags and vars] outputs\\[1] - output using data\\[] array containing {name,ivalue,svalue,svalue2,svalue3,dtvalue} (1 doc), any of those keys is optional \\[not used currently] outputs\\[2] - output using N separate docs, each containing {name,ivalue,svalue,svalue2,svalue3,dtvalue} (N docs) (but trying to keep both int and string value in the same record) \\[used by metrics/time-series]\n\n```go\ntype ESBulks struct {\n\t// contains filtered or unexported fields\n}\n```\nESBulks keeps array of bulk services to add/delete each delete/add but can hold 10 items\n\n```go\nfunc (b *ESBulks) CurrentAdd() *elastic.BulkService\n```\nCurrentAdd returns current bulk add object\n\n```go\nfunc (b *ESBulks) CurrentDel() *elastic.BulkService\n```\nCurrentDel returns current bulk delete object\n\n```go\nfunc (b *ESBulks) Init(ec *elastic.Client, ctx *Ctx)\n```\nInit creates structure to hanle bulk inserts/deletes\n\n```go\nfunc (b *ESBulks) Next(ec *elastic.Client)\n```\nNext will increase objects count and possibly switch to another bulk objects\n\n```go\nfunc (b *ESBulks) String() string\n```\nString - output bulks config\n\n```go\ntype ESDataObject struct {\n\tName    string    `json:\"name\"`\n\tIValue  float64   `json:\"ivalue\"`\n\tSValue  string    `json:\"svalue\"`\n\tSValue2 string    `json:\"svalue2\"`\n\tSValue3 string    `json:\"svalue3\"`\n\tDtValue time.Time `json:\"dtvalue\"`\n}\n```\nESDataObject internal JSON data for stored documents\n\n```go\ntype Event struct {\n\tID        string    `json:\"id\"`\n\tType      string    `json:\"type\"`\n\tPublic    bool      `json:\"public\"`\n\tCreatedAt time.Time `json:\"created_at\"`\n\tActor     Actor     `json:\"actor\"`\n\tRepo      Repo      `json:\"repo\"`\n\tOrg       *Org      `json:\"org\"`\n\tPayload   Payload   `json:\"payload\"`\n}\n```\nEvent - full GHA (GitHub Archive) event structure\n\n```go\ntype EventOld struct {\n\tID         string      `json:\"-\"`\n\tType       string      `json:\"type\"`\n\tPublic     bool        `json:\"public\"`\n\tCreatedAt  time.Time   `json:\"created_at\"`\n\tActor      string      `json:\"actor\"`\n\tRepository ForkeeOld   `json:\"repository\"`\n\tPayload    *PayloadOld `json:\"payload\"`\n}\n```\nEventOld - full GHA (GitHub Archive) event structure, before 2015\n\n```go\ntype Forkee struct {\n\tID              int        `json:\"id\"`\n\tName            string     `json:\"name\"`\n\tFullName        string     `json:\"full_name\"`\n\tOwner           Actor      `json:\"owner\"`\n\tDescription     *string    `json:\"description\"`\n\tPublic          *bool      `json:\"public\"`\n\tFork            bool       `json:\"fork\"`\n\tCreatedAt       time.Time  `json:\"created_at\"`\n\tUpdatedAt       time.Time  `json:\"updated_at\"`\n\tPushedAt        *time.Time `json:\"pushed_at\"`\n\tHomepage        *string    `json:\"homepage\"`\n\tSize            int        `json:\"size\"`\n\tStargazersCount int        `json:\"stargazers_count\"`\n\tHasIssues       bool       `json:\"has_issues\"`\n\tHasProjects     *bool      `json:\"has_projects\"`\n\tHasDownloads    bool       `json:\"has_downloads\"`\n\tHasWiki         bool       `json:\"has_wiki\"`\n\tHasPages        *bool      `json:\"has_pages\"`\n\tForks           int        `json:\"forks\"`\n\tOpenIssues      int        `json:\"open_issues\"`\n\tWatchers        int        `json:\"watchers\"`\n\tDefaultBranch   string     `json:\"default_branch\"`\n}\n```\nForkee - GHA Forkee structure\n\n```go\ntype ForkeeOld struct {\n\tID            int        `json:\"id\"`\n\tCreatedAt     time.Time  `json:\"created_at\"`\n\tDescription   *string    `json:\"description\"`\n\tFork          bool       `json:\"fork\"`\n\tForks         int        `json:\"forks\"`\n\tHasDownloads  bool       `json:\"has_downloads\"`\n\tHasIssues     bool       `json:\"has_issues\"`\n\tHasWiki       bool       `json:\"has_wiki\"`\n\tHomepage      *string    `json:\"homepage\"`\n\tLanguage      *string    `json:\"language\"`\n\tDefaultBranch string     `json:\"master_branch\"`\n\tName          string     `json:\"name\"`\n\tOpenIssues    int        `json:\"open_issues\"`\n\tOrganization  *string    `json:\"organization\"`\n\tOwner         string     `json:\"owner\"`\n\tPrivate       *bool      `json:\"private\"`\n\tPushedAt      *time.Time `json:\"pushed_at\"`\n\tSize          int        `json:\"size\"`\n\tStargazers    int        `json:\"stargazers\"`\n\tWatchers      int        `json:\"watchers\"`\n}\n```\nForkeeOld - GHA Forkee structure (from before 2015) Handle missing 4 last properties (including two non-nulls!)\n\n```go\ntype Int64Ary []int64\n```\nInt64Ary - sortable Int64 array\n\n```go\nfunc (a Int64Ary) Len() int\n```\n\n```go\nfunc (a Int64Ary) Less(i, j int) bool\n```\n\n```go\nfunc (a Int64Ary) Swap(i, j int)\n```\n\n```go\ntype Issue struct {\n\tID          int        `json:\"id\"`\n\tNumber      int        `json:\"number\"`\n\tComments    int        `json:\"comments\"`\n\tTitle       string     `json:\"title\"`\n\tState       string     `json:\"state\"`\n\tLocked      bool       `json:\"locked\"`\n\tBody        *string    `json:\"body\"`\n\tUser        Actor      `json:\"user\"`\n\tAssignee    *Actor     `json:\"assignee\"`\n\tLabels      []Label    `json:\"labels\"`\n\tAssignees   []Actor    `json:\"assignees\"`\n\tMilestone   *Milestone `json:\"milestone\"`\n\tCreatedAt   time.Time  `json:\"created_at\"`\n\tUpdatedAt   time.Time  `json:\"updated_at\"`\n\tClosedAt    *time.Time `json:\"closed_at\"`\n\tPullRequest *Dummy     `json:\"pull_request\"`\n}\n```\nIssue - GHA Issue structure\n\n```go\ntype IssueConfig struct {\n\tRepo         string\n\tNumber       int\n\tIssueID      int64\n\tPr           bool\n\tMilestoneID  *int64\n\tLabels       string\n\tLabelsMap    map[int64]string\n\tGhIssue      *github.Issue\n\tCreatedAt    time.Time\n\tEventID      int64\n\tEventType    string\n\tGhEvent      *github.IssueEvent\n\tAssigneeID   *int64\n\tAssignees    string\n\tAssigneesMap map[int64]string\n}\n```\nIssueConfig - holds issue data\n\n```go\nfunc (ic IssueConfig) String() string\n```\n\n```go\ntype IssueConfigAry []IssueConfig\n```\nIssueConfigAry - allows sorting IssueConfig array by IssueID annd then event creation date\n\n```go\nfunc (ic IssueConfigAry) Len() int\n```\n\n```go\nfunc (ic IssueConfigAry) Less(i, j int) bool\n```\n\n```go\nfunc (ic IssueConfigAry) Swap(i, j int)\n```\n\n```go\ntype Label struct {\n\tID      *int   `json:\"id\"`\n\tName    string `json:\"name\"`\n\tColor   string `json:\"color\"`\n\tDefault *bool  `json:\"default\"`\n}\n```\nLabel - GHA Label structure\n\n```go\ntype Milestone struct {\n\tID           int        `json:\"id\"`\n\tName         string     `json:\"name\"`\n\tNumber       int        `json:\"number\"`\n\tTitle        string     `json:\"title\"`\n\tDescription  *string    `json:\"description\"`\n\tCreator      *Actor     `json:\"creator\"`\n\tOpenIssues   int        `json:\"open_issues\"`\n\tClosedIssues int        `json:\"closed_issues\"`\n\tState        string     `json:\"state\"`\n\tCreatedAt    time.Time  `json:\"created_at\"`\n\tUpdatedAt    time.Time  `json:\"updated_at\"`\n\tClosedAt     *time.Time `json:\"closed_at\"`\n\tDueOn        *time.Time `json:\"due_on\"`\n}\n```\nMilestone - GHA Milestone structure\n\n```go\ntype Org struct {\n\tID    int    `json:\"id\"`\n\tLogin string `json:\"login\"`\n}\n```\nOrg - GHA Org structure\n\n```go\ntype Page struct {\n\tSHA    string `json:\"sha\"`\n\tAction string `json:\"action\"`\n\tTitle  string `json:\"title\"`\n}\n```\nPage - GHA Page structure\n\n```go\ntype Payload struct {\n\tPushID       *int         `json:\"push_id\"`\n\tSize         *int         `json:\"size\"`\n\tRef          *string      `json:\"ref\"`\n\tHead         *string      `json:\"head\"`\n\tBefore       *string      `json:\"before\"`\n\tAction       *string      `json:\"action\"`\n\tRefType      *string      `json:\"ref_type\"`\n\tMasterBranch *string      `json:\"master_branch\"`\n\tDescription  *string      `json:\"description\"`\n\tNumber       *int         `json:\"number\"`\n\tForkee       *Forkee      `json:\"forkee\"`\n\tRelease      *Release     `json:\"release\"`\n\tMember       *Actor       `json:\"member\"`\n\tIssue        *Issue       `json:\"issue\"`\n\tComment      *Comment     `json:\"comment\"`\n\tCommits      *[]Commit    `json:\"commits\"`\n\tPages        *[]Page      `json:\"pages\"`\n\tPullRequest  *PullRequest `json:\"pull_request\"`\n}\n```\nPayload - GHA Payload structure\n\n```go\ntype PayloadOld struct {\n\tIssue        *int           `json:\"issue\"`\n\tIssueID      *int           `json:\"issue_id\"`\n\tComment      *Comment       `json:\"comment\"`\n\tCommentID    *int           `json:\"comment_id\"`\n\tDescription  *string        `json:\"description\"`\n\tMasterBranch *string        `json:\"master_branch\"`\n\tRef          *string        `json:\"ref\"`\n\tAction       *string        `json:\"action\"`\n\tRefType      *string        `json:\"ref_type\"`\n\tHead         *string        `json:\"head\"`\n\tSize         *int           `json:\"size\"`\n\tNumber       *int           `json:\"number\"`\n\tPullRequest  *PullRequest   `json:\"pull_request\"`\n\tMember       *Actor         `json:\"member\"`\n\tRelease      *Release       `json:\"release\"`\n\tPages        *[]Page        `json:\"pages\"`\n\tCommit       *string        `json:\"commit\"`\n\tSHAs         *[]interface{} `json:\"shas\"`\n\tRepository   *Forkee        `json:\"repository\"`\n\tTeam         *Team          `json:\"team\"`\n}\n```\nPayloadOld - GHA Payload structure (from before 2015)\n\n```go\ntype Project struct {\n\tCommandLine      []string          `yaml:\"command_line\"`\n\tStartDate        *time.Time        `yaml:\"start_date\"`\n\tPDB              string            `yaml:\"psql_db\"`\n\tDisabled         bool              `yaml:\"disabled\"`\n\tMainRepo         string            `yaml:\"main_repo\"`\n\tAnnotationRegexp string            `yaml:\"annotation_regexp\"`\n\tOrder            int               `yaml:\"order\"`\n\tJoinDate         *time.Time        `yaml:\"join_date\"`\n\tFilesSkipPattern string            `yaml:\"files_skip_pattern\"`\n\tEnv              map[string]string `yaml:\"env\"`\n\tFullName         string            `yaml:\"name\"`\n\tStatus           string            `yaml:\"status\"`\n\tSharedDB         string            `yaml:\"shared_db\"`\n}\n```\nProject contain mapping from project name to its command line used to sync it\n\n```go\nfunc GetProjectsList(ctx *Ctx, projects *AllProjects) (names []string, projs []Project)\n```\nGetProjectsList return list of projects to process It sorts them according to projects.yaml order Handles disabled/enabled projects Handles ONLY=\"project1 project2 ... projectN\" env\n\n```go\ntype PullRequest struct {\n\tID                  int        `json:\"id\"`\n\tBase                Branch     `json:\"base\"`\n\tHead                Branch     `json:\"head\"`\n\tUser                Actor      `json:\"user\"`\n\tNumber              int        `json:\"number\"`\n\tState               string     `json:\"state\"`\n\tLocked              *bool      `json:\"locked\"`\n\tTitle               string     `json:\"title\"`\n\tBody                *string    `json:\"body\"`\n\tCreatedAt           time.Time  `json:\"created_at\"`\n\tUpdatedAt           time.Time  `json:\"updated_at\"`\n\tClosedAt            *time.Time `json:\"closed_at\"`\n\tMergedAt            *time.Time `json:\"merged_at\"`\n\tMergeCommitSHA      *string    `json:\"merge_commit_sha\"`\n\tAssignee            *Actor     `json:\"assignee\"`\n\tAssignees           *[]Actor   `json:\"assignees\"`\n\tRequestedReviewers  *[]Actor   `json:\"requested_reviewers\"`\n\tMilestone           *Milestone `json:\"milestone\"`\n\tMerged              *bool      `json:\"merged\"`\n\tMergeable           *bool      `json:\"mergeable\"`\n\tMergedBy            *Actor     `json:\"merged_by\"`\n\tMergeableState      *string    `json:\"mergeable_state\"`\n\tRebaseable          *bool      `json:\"rebaseable\"`\n\tComments            *int       `json:\"comments\"`\n\tReviewComments      *int       `json:\"review_comments\"`\n\tMaintainerCanModify *bool      `json:\"maintainer_can_modify\"`\n\tCommits             *int       `json:\"commits\"`\n\tAdditions           *int       `json:\"additions\"`\n\tDeletions           *int       `json:\"deletions\"`\n\tChangedFiles        *int       `json:\"changed_files\"`\n}\n```\nPullRequest - GHA Pull Request structure\n\n```go\ntype Release struct {\n\tID              int        `json:\"id\"`\n\tTagName         string     `json:\"tag_name\"`\n\tTargetCommitish string     `json:\"target_commitish\"`\n\tName            *string    `json:\"name\"`\n\tDraft           bool       `json:\"draft\"`\n\tAuthor          Actor      `json:\"author\"`\n\tPrerelease      bool       `json:\"prerelease\"`\n\tCreatedAt       time.Time  `json:\"created_at\"`\n\tPublishedAt     *time.Time `json:\"published_at\"`\n\tBody            *string    `json:\"body\"`\n\tAssets          []Asset    `json:\"assets\"`\n}\n```\nRelease - GHA Release structure\n\n```go\ntype Repo struct {\n\tID   int    `json:\"id\"`\n\tName string `json:\"name\"`\n}\n```\nRepo - GHA Repo structure\n\n```go\ntype SkipDatesList struct {\n\tDates []time.Time `yaml:\"skip_dates\"`\n}\n```\nSkipDatesList holds a list of GHA hours to skip\n\n```go\ntype TSPoint struct {\n\t// contains filtered or unexported fields\n}\n```\nTSPoint keeps single time series point\n\n```go\nfunc NewTSPoint(ctx *Ctx, name, period string, tags map[string]string, fields map[string]interface{}, t time.Time, exact bool) TSPoint\n```\nNewTSPoint returns new point as specified by args\n\n```go\nfunc (p *TSPoint) Str() string\n```\nStr - string pretty print\n\n```go\ntype TSPoints []TSPoint\n```\nTSPoints keeps batch of TSPoint values to write\n\n```go\nfunc (ps *TSPoints) Str() string\n```\nStr - string pretty print\n\n```go\ntype Tag struct {\n\tName       string               `yaml:\"name\"`\n\tSQLFile    string               `yaml:\"sql\"`\n\tSeriesName string               `yaml:\"series_name\"`\n\tNameTag    string               `yaml:\"name_tag\"`\n\tValueTag   string               `yaml:\"value_tag\"`\n\tOtherTags  map[string][2]string `yaml:\"other_tags\"`\n\tLimit      int                  `yaml:\"limit\"`\n\tDisabled   bool                 `yaml:\"disabled\"`\n}\n```\nTag contain each TSDB tag data\n\n```go\ntype Tags struct {\n\tTags []Tag `yaml:\"tags\"`\n}\n```\nTags contain list of TSDB tags\n\n```go\ntype Team struct {\n\tID         int    `json:\"id\"`\n\tName       string `json:\"name\"`\n\tSlug       string `json:\"slug\"`\n\tPermission string `json:\"permission\"`\n}\n```\nTeam - GHA Team structure (only used before 2015)\n\n","path":"github.com/cncf/devstatscode","name":"devstatscode","synopsis":"","isRedistributable":true}
