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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeInvoice

func DecodeInvoice(invoice *Invoice) (*database.Invoice, error)

DecodeInvoice decodes a cockroachdb Invoice instance into a generic database.Invoice.

func DecodeInvoiceLineItem

func DecodeInvoiceLineItem(lineItem *LineItem) *database.LineItem

DecodeInvoiceLineItem decodes a cockroachdb line item into a generic database.LineItem

func DecodeInvoices

func DecodeInvoices(invoices []Invoice) ([]database.Invoice, error)

DecodeInvoices decodes an array of cockroachdb Invoice instances into generic database.Invoices.

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, net, rootCert, cert, key string) (*cockroachdb, error)

New returns a new cockroachdb context that contains a connection to the specified database that was made using the politeiawww user and the passed in certificates.

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 DCC

type DCC struct {
	Token              string `gorm:"primary_key"`
	SponsorUserID      string `gorm:"not null"`
	NomineeUserID      string `gorm:"not null"`
	Type               int    `gorm:"not null"`
	Status             int    `gorm:"not null"`
	StatusChangeReason string `gorm:"not null"`
	TimeSubmitted      int64  `gorm:"not null"`
	TimeReviewed       int64  `gorm:"not null"`
	PublicKey          string `gorm:"not null"`
	UserSignature      string `gorm:"not null"`
	ServerSignature    string `gorm:"not null"`
	SponsorStatement   string `gorm:"not null"`
	Domain             int    `gorm:"not null"`
	ContractorType     int    `gorm:"not null"`

	SupportUserIDs    string `gorm:"not null"`
	OppositionUserIDs string `gorm:"not null"`
}

DCC contains all the information about a given DCC proposal.

func (DCC) TableName

func (DCC) TableName() string

TableName returns the table name of the DCC table.

type ExchangeRate

type ExchangeRate struct {
	Month        uint `gorm:"not null"`
	Year         uint `gorm:"not null"`
	ExchangeRate uint `gorm:"not null"`
}

ExchangeRate contains cached calculated rates for a given month/year

func (ExchangeRate) TableName

func (ExchangeRate) TableName() string

TableName returns the table name of the line items table.

type Invoice

type Invoice struct {
	Key                string    `gorm:"primary_key"` // Token + version
	Token              string    `gorm:"not null"`
	UserID             string    `gorm:"not null"`
	Username           string    `gorm:"-"` // Only populated when reading from the database
	Month              uint      `gorm:"not null"`
	Year               uint      `gorm:"not null"`
	ExchangeRate       uint      `gorm:"not null"`
	Timestamp          time.Time `gorm:"not null"`
	Status             uint      `gorm:"not null"`
	StatusChangeReason string    `gorm:"not null"`
	PublicKey          string    `gorm:"not null"`
	UserSignature      string    `gorm:"not null"`
	ServerSignature    string    `gorm:"not null"`
	Version            string    `gorm:"not null"`
	ContractorName     string    `gorm:"not null"`
	ContractorLocation string    `gorm:"not null"`
	ContractorRate     uint      `gorm:"not null"`
	ContractorContact  string    `gorm:"not null"`
	PaymentAddress     string    `gorm:"not null"`

	LineItems []LineItem      `gorm:"foreignkey:InvoiceKey"`
	Changes   []InvoiceChange `gorm:"foreignkey:InvoiceKey"`
	Payments  Payments        `gorm:"foreignkey:InvoiceKey"`
}

Invoice is the database model for the database.Invoice type

func EncodeInvoice

func EncodeInvoice(dbInvoice *database.Invoice) *Invoice

EncodeInvoice encodes a generic database.Invoice instance into a cockroachdb Invoice.

func (Invoice) TableName

func (Invoice) TableName() string

TableName returns the table name of the invoices table.

type InvoiceChange

type InvoiceChange struct {
	InvoiceKey     string    `gorm:"not null"` // The key of the invoice that it is attached
	InvoiceToken   string    `gorm:"not null"` // Censorship token of the invoice
	AdminPublicKey string    `gorm:"not null"` // The public of the admin that processed the status change.
	NewStatus      uint      `gorm:"not null"` // Updated status of the invoice.
	Reason         string    `gorm:"not null"` // Reason for status updated (required if rejected)
	Timestamp      time.Time `gorm:"not null"` // The timestamp of the status change.
}

InvoiceChange contains entries for any status update that occurs to a given invoice. This will give a full history of an invoices history.

func (InvoiceChange) TableName

func (InvoiceChange) TableName() string

TableName returns the table name of the line items table.

type LineItem

type LineItem struct {
	LineItemKey    string `gorm:"primary_key"` // Token of the Invoice + version + array index
	InvoiceKey     string `gorm:"not null"`    // The key of the invoice that it is attached
	InvoiceToken   string `gorm:"not null"`    // Censorship token of the invoice
	Type           uint   `gorm:"not null"`    // Type of line item
	Domain         string `gorm:"not null"`    // Domain of the work performed (dev, marketing etc)
	Subdomain      string `gorm:"not null"`    // Subdomain of the work performed (decrediton, event X etc)
	Description    string `gorm:"not null"`    // Description of work performed
	ProposalURL    string `gorm:"not null"`    // Link to politeia proposal that work is associated with
	Labor          uint   `gorm:"not null"`    // Number of minutes worked
	Expenses       uint   `gorm:"not null"`    // Total cost of line item (in USD cents)
	ContractorRate uint   `gorm:"not null"`    // Optional contractor rate for line item, typically used for Sub Contractors
	SubUserID      string `gorm:"not null"`    // SubContractor User ID if Subcontractor Line Item
}

LineItem is the database model for the database.LineItem type

func EncodeInvoiceLineItem

func EncodeInvoiceLineItem(dbLineItem *database.LineItem) LineItem

EncodeInvoiceLineItem encodes a database.LineItem into a cockroachdb line item.

func (LineItem) TableName

func (LineItem) TableName() string

TableName returns the table name of the line items table.

type MatchingLineItems

type MatchingLineItems struct {
	InvoiceToken   string
	UserID         string
	Month          uint
	Year           uint
	Type           uint
	Domain         string
	Subdomain      string
	Description    string
	ProposalURL    string
	Labor          uint
	Expenses       uint
	ContractorRate uint
	PublicKey      string
	ExchangeRate   uint
	SubRate        uint
	SubUser        string
}

MatchingLineItems is a type used for finding matched line items based on proposal ownership.

type Payments

type Payments struct {
	InvoiceKey      string `gorm:"primary_key"` // The key of the invoice that it is attached
	InvoiceToken    string `gorm:"not null"`
	Address         string `gorm:"not null"`
	TxIDs           string `gorm:"not null"`
	TimeStarted     int64  `gorm:"not null"`
	TimeLastUpdated int64  `gorm:"not null"`
	AmountNeeded    int64  `gorm:"not null"`
	AmountReceived  int64  `gorm:"not null"`
	Status          uint   `gorm:"not null"`
}

Payments contains all the information about a given invoice's payment

func (Payments) TableName

func (Payments) TableName() string

TableName returns the table name of the line items table.

type Version

type Version struct {
	ID        string `gorm:"primary_key"` // Primary key
	Version   string `gorm:"not null"`    // Version
	Timestamp int64  `gorm:"not null"`    // UNIX timestamp of record creation
}

Version describes the version of a record or plugin that the database is currently using.

func (Version) TableName

func (Version) TableName() string

TableName returns the table name of the invoices table.

Jump to

Keyboard shortcuts

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