cockroachdb

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func New

func New(host, network, sslRootCert, sslCert, sslKey, encryptionKey string) (*cockroachdb, error)

New opens a connection to the CockroachDB user database and returns a new cockroachdb context. sslRootCert, sslCert, sslKey, and encryptionKey are file paths.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type CMSCodeStats

type CMSCodeStats struct {
	ID               string `gorm:"primary_key"` // UserID + GithubName + Month + Year
	GitHubName       string `gorm:"not null"`    // GithubName
	Repository       string `gorm:"not null"`    // Repository
	Month            int    `gorm:"not null"`    // Month of code stats
	Year             int    `gorm:"not null"`    // Year of code stats
	PRs              string `gorm:"not null"`    // String of all PR URLs separated by commas
	Reviews          string `gorm:"not null"`    // String of all Reviewed PR URLS separated by commas
	Commits          string `gorm:"not null"`    // String of all commit URL separated by commas
	MergedAdditions  int64  `gorm:"not null"`    // Total merged code additions
	MergedDeletions  int64  `gorm:"not null"`    // Total merged code deletions
	UpdatedAdditions int64  `gorm:"not null"`    // Total updated code additions
	UpdatedDeletions int64  `gorm:"not null"`    // Total updated code deletions
	ReviewAdditions  int64  `gorm:"not null"`    // Total reviewed code additions
	ReviewDeletions  int64  `gorm:"not null"`    // Total reviewed code deletions
	CommitAdditions  int64  `gorm:"not null"`    // Total commit additions
	CommitDeletions  int64  `gorm:"not null"`    // Total commit deletions
}

CMSCodeStats struct contains information per month/year per repo for a given users' code statistics for merged pull requests and completed reviews over that time period.

func (CMSCodeStats) TableName

func (CMSCodeStats) TableName() string

TableName returns the table name of the CMSUsers table.

type CMSUser

type CMSUser struct {
	ID                 uuid.UUID `gorm:"primary_key"`            // UUID (User foreign key)
	User               User      `gorm:"not null;foreignkey:ID"` // politeiawww user
	Domain             int       `gorm:"not null"`               // Contractor domain
	GitHubName         string    `gorm:"not null"`               // Github Name/ID
	MatrixName         string    `gorm:"not null"`               // Matrix Name/ID
	ContractorType     int       `gorm:"not null"`               // Type of Contractor
	ContractorName     string    `gorm:"not null"`               // IRL Contractor Name or identity
	ContractorLocation string    `gorm:"not null"`               // General IRL Contractor Location
	ContractorContact  string    `gorm:"not null"`               // Point of contact outside of matrix
	SupervisorUserID   string    `gorm:"not null"`               // This is can either be 1 SupervisorUserID or a comma separated string of many supervisor user ids
	ProposalsOwned     string    `gorm:"not null"`               // This can either be 1 Proposal or a comma separated string of many.

	// Set by gorm
	CreatedAt time.Time // Time of record creation
	UpdatedAt time.Time // Time of last record update
}

CMSUser represents a CMS user. A CMS user includes the politeiawww User object as well as CMS specific user fields. A CMS user must correspond to a politeiawww User.

This is a CMS plugin model.

XXX We need to update SupervisorUserID to SupervisorUserIDs next time we update or do any migration on the userdb.

func (CMSUser) TableName

func (CMSUser) TableName() string

TableName returns the table name of the CMSUsers table.

type EmailHistory

type EmailHistory struct {
	UserID uuid.UUID `gorm:"primary_key"` // User UUID
	Blob   []byte    `gorm:"not null"`    // Encrypted email history
}

func (EmailHistory) TableName

func (EmailHistory) TableName() string

type Identity

type Identity struct {
	PublicKey   string    `gorm:"primary_key;size:64"` // ed25519 public key
	UserID      uuid.UUID `gorm:"not null"`            // User UUID (User foreign key)
	Activated   int64     `gorm:"not null"`            // UNIX timestamp of activation
	Deactivated int64     `gorm:"not null"`            // UNIX timestamp of deactivation
}

Identity represents a user identity.

func (Identity) TableName

func (Identity) TableName() string

TableName returns the table name of the Identity table.

type KeyValue

type KeyValue struct {
	Key   string `gorm:"primary_key"`
	Value []byte `gorm:"not null"`
}

KeyValue store is a generic key-value store.

func (KeyValue) TableName

func (KeyValue) TableName() string

TableName returns the table name of the KeyValue table.

type Session

type Session struct {
	Key       string    `gorm:"primary_key"` // SHA256 hash of the session ID
	UserID    uuid.UUID `gorm:"not null"`    // User UUID
	CreatedAt int64     `gorm:"not null"`    // Created at UNIX timestamp
	Blob      []byte    `gorm:"not null"`    // Encrypted user session
}

Session represents a user session.

Key is a SHA256 hash of the decoded session ID. The session Store handles encoding/decoding the ID.

Blob represents an ecrypted user.Session. The fields that have been broken out of the encrypted blob are the fields that need to be queryable.

func (Session) TableName

func (Session) TableName() string

TableName returns the table name of the Session table.

type User

type User struct {
	ID         uuid.UUID  `gorm:"primary_key"`       // UUID
	Username   string     `gorm:"not null;unique"`   // Unique username
	Identities []Identity `gorm:"foreignkey:UserID"` // User identity history
	Blob       []byte     `gorm:"not null"`          // Encrypted blob of user data

	// Set by gorm
	CreatedAt time.Time // Time of record creation
	UpdatedAt time.Time // Time of last record update
}

User represents a politeiawww user. Blog is an encrypted blob of the full user object.

func (User) TableName

func (User) TableName() string

TableName returns the table name of the User table.

Jump to

Keyboard shortcuts

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