metric

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 12 Imported by: 0

README

Go Report Card GoDoc GolangCI

xmodule/metric for Xamboo - GO

The metric package is used to keep metric tables, structures and functions to convert from one metric to another.

Version Changes Control

v0.0.1 - 2020-05-08

  • Compatible with xmodule context standard

v0.0.0 - 2020-03-05

  • Support for multithread context implemented

v0.0.0 - 2020-01-23

  • BuildCaches is now on parallel thread

v0.0.0 - 2019-12-18

  • First release of module

Manual:

I. Metrics

Intro


  1. Overview

Example:

import "github.com/webability-go/xmodules/metric"


  1. Reference

To use the package:

import "github.com/webability-go/xmodules/metric"

Documentation

Overview

Package user contains the list of administrative user for the system. All users have accesses, into a profile and even extended access based upon table records. It needs base xmodule.

Index

Constants

View Source
const (
	MODULEID         = "metric"
	VERSION          = "0.0.1"
	TRANSLATIONTHEME = "metric"
)
View Source
const (
	SI_GRAM  = 42
	SI_LITER = 49
	SI_METER = 205

	SI_KILO       = 45
	SI_CENTILITER = 14
	SI_MILILITER  = 55

	// solido
	SA_OUNCE = 56
	SA_POUND = 48

	// liquido
	SA_LOQUIDOUNCE = 207
	SA_GALLON      = 39

	// solido o liquido, aplicar densidad si necesario
	SC_CUP      = 86
	SC_SPOON    = 29
	SC_TEASPOON = 30

	UNIT_NOTVISIBLE = 102 // pieza sin escribir el nombre
	UNIT_VISIBLE    = 62  // pieza escribiendo el nombre
)

Variables

View Source
var ModuleMetric = assets.ModuleEntries{}

Functions

func ConvertMetrics

func ConvertMetrics(sitecontext *base.Datasource, quantity float64, density float64, state int, fromMetric *xdominion.XRecord, system int) (float64, *xdominion.XRecord)

system is 1 - "si", 2 - "sa" or 3 - "sc" (campo "tipo" de la tabla) 0 - as captured 1 - si = sistema internacional 2 - sa = sistema americano 3 - sc = sistema de cocina density is needed for weight-volume conversions (approx 0.7 to 2.5 generally) state is the type of metric we prefer for this ingredient: (basically for SI and SA), since SC is all volume 1 = solid 2 = liquid

func CreateStructureMetricByData

func CreateStructureMetricByData(sitecontext applications.Datasource, data xdominion.XRecordDef, lang language.Tag) base.Structure

func CreateStructureMetricByKey

func CreateStructureMetricByKey(sitecontext applications.Datasource, key int, lang language.Tag) base.Structure

func ParseQuantity

func ParseQuantity(cantidad string) float64

1. si SOLO tiene 0-9 y . : entonces es int/float: convierte directo 2. si tiene SOLO con anteriores / y ' ' puede ser una fraccion si tiene otra cosa: no podemos convertir (letras, guiones, espacios etc) Regresa 0 si la cantidad es 0 o vacia regresa -1 si la cantidad no pudo ser comprendida (por ejemplo, puras letras, o un float con un formato erroneo)

func Setup

func Setup(ds applications.Datasource, prefix string) ([]string, error)

InitModule is called during the init phase to link the module with the system adds tables and caches to ctx::database

func StartContext

func StartContext(ds applications.Datasource, ctx *context.Context) error

func Synchronize

func Synchronize(ds applications.Datasource, prefix string) ([]string, error)

Types

type StructureMetric

type StructureMetric struct {
	Key  int
	Lang language.Tag
	Data *xdominion.XRecord
}

func GetMetric

func GetMetric(sitecontext *base.Datasource, clave int, lang language.Tag) *StructureMetric

func (*StructureMetric) Clone

func (sm *StructureMetric) Clone() base.Structure

Clone the whole structure

func (*StructureMetric) ComplementData

func (sm *StructureMetric) ComplementData(sitecontext applications.Datasource)

ComplementData adds all the needed data from other objects /duplicable in the thread since the object will be destroyed at the end

func (*StructureMetric) GetData

func (sm *StructureMetric) GetData() *xdominion.XRecord

Returns the raw data

func (*StructureMetric) IsAuthorized

func (sm *StructureMetric) IsAuthorized(sitecontext applications.Datasource, site string, language string, device string) bool

IsAuthorized returns true if the structure can be used on this site/language/device

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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