attribute

package
v0.0.0-...-68ec1c9 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugPrint = false
)

Variables

This section is empty.

Functions

func ToPrettyJSON

func ToPrettyJSON(o interface{}) string

Types

type Attribute

type Attribute struct {
	ID                int
	Type              string
	IsMultipleAllowed bool
	IsRequired        bool
	IsDisabled        bool
	Title             string
	DisplayOrder      int
	IsSearchable      bool
	ListingType       string
	DisplayPage       int
	OptionIDs         []int
}

type AttributeCondition

type AttributeCondition struct {
	AttributeID int `json:"attribute_id"`
	OptionID    int `json:"option_id"`
}

type Category

type Category struct {
	// E.g. map[id:1165 name:テント/タープ order:50 parent_id:1164 path:[8 1164]]
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Order    int    `json:"order"`
	ParentID int    `json:"parent_id"`
	Path     []int  `json:"path"`
}

type CategoryRule

type CategoryRule struct {
	CategoryID                int
	ShowIfOptionIDSelected    map[int][]*LimitedOptions // key = option ID (from precondition)
	ShowOptionIDAlways        map[int]bool              // key = option ID
	AttributeIDs              []int
	AlwaysVisibleAttributeIDs []int
}

func (*CategoryRule) AddLimitedOption

func (r *CategoryRule) AddLimitedOption(selectedOptionID int, o *Option)

type DB

type DB struct {
	IDs           map[string]int        `json:"ids"`
	IDCounter     int                   `json:"id_counter"`
	Attributes    map[int]*Attribute    `json:"attributes"`
	Options       map[int]*Option       `json:"options"`
	CategoryRules map[int]*CategoryRule `json:"category_rules"` // key = category_id
	ReverseIDs    map[int]string        `json:"reverse_ids"`
	CategoryTree  map[int]*Category     `json:"category_tree"` // key = category_id
	// contains filtered or unexported fields
}

func NewDB

func NewDB() *DB

func (*DB) AddAttribute

func (db *DB) AddAttribute(rec, headers []string) error

func (*DB) AddCategoryAttribute

func (db *DB) AddCategoryAttribute(rec, headers []string) error

func (*DB) AddDynamicOption

func (db *DB) AddDynamicOption(rec, headers []string) error

func (*DB) AddOption

func (db *DB) AddOption(rec, headers []string) error

func (*DB) Attribute

func (db *DB) Attribute(id int) *Attribute

func (*DB) AttributeOptionPairToString

func (db *DB) AttributeOptionPairToString(pair string) string

func (*DB) CategoryRule

func (db *DB) CategoryRule(categoryID int) *CategoryRule

func (*DB) ConvertID

func (db *DB) ConvertID(uuid string) (id int)

func (*DB) ConvertItemAttributeRelationships

func (db *DB) ConvertItemAttributeRelationships(fromGzippedCSVFile, toCSVFile string)

Takes a CSV file (gzipped) containing a ItemID->AttributeID->AttributeValue relationships and converts them to use this DB's IDs (integer primary keys).

func (*DB) Dump

func (db *DB) Dump(o DumpOpts)

func (*DB) DumpCategoryRule

func (db *DB) DumpCategoryRule(cr *CategoryRule, max int)

func (*DB) ForceAppendSuffixToAllConvertedKeys

func (db *DB) ForceAppendSuffixToAllConvertedKeys(suffix string)

func (*DB) FullCategoryName

func (db *DB) FullCategoryName(categoryID int) string

func (*DB) ImportPostgresDatabase

func (db *DB) ImportPostgresDatabase(a ImportPostgresDatabaseArgs) error

Dir contains gzipped CSV of key tables from the Item Attributes database exported from Postgres (each table exported as a separate CSV file).

func (*DB) LoadCategoriesJSON

func (db *DB) LoadCategoriesJSON(file string) error

func (*DB) Option

func (db *DB) Option(id int) *Option

func (*DB) PostProcessImportedData

func (db *DB) PostProcessImportedData() error

func (*DB) PreSort

func (db *DB) PreSort()

type DumpOpts

type DumpOpts struct {
	OnlyCategoryID  int
	MaxLinesToPrint int
}

type FindVisibleAttributesResponse

type FindVisibleAttributesResponse struct {
	Pages     int
	PageSize  int
	VAs       []*VisibleAttribute
	Corrected *SearchConditions
}

func FindVisibleAttributes

func FindVisibleAttributes(sc *SearchConditions, db *DB) (res *FindVisibleAttributesResponse, err error)

type ImportPostgresDatabaseArgs

type ImportPostgresDatabaseArgs struct {
	Dir string
}

type LimitedOptions

type LimitedOptions struct {
	AttributeID int
	OptionIDs   []int
}

type Option

type Option struct {
	ID           int
	AttributeID  int
	Title        string
	IsDisabled   bool
	DisplayOrder int
	Color        string
	Subtitle     string
}

type OptionFilter

type OptionFilter struct {
	AttributeID int
	Prefix      string
}

type SearchConditions

type SearchConditions struct {
	CategoryIDs []int                 `json:"category_id"`
	Attributes  []*AttributeCondition `json:"attributes"`
	PageSize    int                   `json:"page_size"`
	Offset      int                   `json:"offset"`
	Filters     []*OptionFilter       `json:"filters"`
}

type VisibleAttribute

type VisibleAttribute struct {
	ID    int              `json:"id"`
	Title string           `json:"title"`
	Os    []*VisibleOption `json:"options"`
}

type VisibleOption

type VisibleOption struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
}

Jump to

Keyboard shortcuts

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