db

package
v0.0.0-...-bfcf95a Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SchemaSQL contains db/schema.sql via main.go
	SchemaSQL string

	Cmd = cobra.Command{
		Use:   "db",
		Short: "Database staff",
		Long: `All sub-commands require EDGAR_DB_URL environment variable set:

  EDGAR_DB_URL="postgres://username:password@localhost:5432/database_name"

Before using any of sub-commands, please create database:

  $ createuser -U postgres -e -P edgar
  $ createdb -U postgres -O edgar -E UTF8 --locale en_US.UTF-8 -T template0 edgar

and initialize it:

  $ edgar db init
`,
	}
)

Functions

func ContextLogger

func ContextLogger(ctx context.Context, def *slog.Logger) *slog.Logger

func ContextWithLogger

func ContextWithLogger(ctx context.Context, l *slog.Logger) context.Context

Types

type Repo

type Repo interface {
	AddCompany(ctx context.Context, cik uint32, name string) (bool, error)
	AddFact(ctx context.Context, tax, name string) (uint32, error)
	AddLabel(ctx context.Context, factId uint32, label, descr string,
		labelHash, descrHash uint64) error
	AddUnit(ctx context.Context, name string) (uint32, error)
	AddFactUnit(ctx context.Context, fact repo.FactUnit) error
	CopyFactUnits(ctx context.Context, length int,
		next func(i int) (repo.FactUnit, error)) error
	LastFiled(ctx context.Context) (map[uint32]time.Time, error)
	FactLabels(ctx context.Context) ([]repo.FactLabels, error)
	Units(ctx context.Context) (map[uint32]string, error)
	FiledCounts(ctx context.Context, cik uint32) (map[time.Time]uint32, error)
	ReplaceFactUnits(ctx context.Context, cik uint32, lastFiled time.Time,
		length int, next func(i int) (repo.FactUnit, error)) error
	AddLastUpdate(ctx context.Context, at time.Time) error
	LastUpdated(ctx context.Context) (lastUpdated time.Time, err error)
}

type Upload

type Upload struct {
	// contains filtered or unexported fields
}

func NewUpload

func NewUpload(edgar *client.Client, repo Repo) *Upload

func (*Upload) Update

func (self *Upload) Update() error

func (*Upload) Upload

func (self *Upload) Upload() error

func (*Upload) WithLogger

func (self *Upload) WithLogger(l *slog.Logger) *Upload

func (*Upload) WithProcsLimit

func (self *Upload) WithProcsLimit(n int) *Upload

Jump to

Keyboard shortcuts

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