Documentation
¶
Index ¶
- Constants
- Variables
- func CSVString(str string) string
- func DBInsertApplications(conn *sql.DB, applications []Application) error
- func DBInsertBrands(conn *sql.DB, brands []Brand) error
- func DBInsertCredentials(conn *sql.DB, credentials []Credential) error
- func DBInsertTax(conn *sql.DB, taxes []Tax) error
- func DBInsertWeeklySales(conn *sql.DB, sales []WeeklySales) error
- func IsBrandErroneous(b *Brand) bool
- func IsEmptyMeasurement(str string) bool
- func IsErrorMeasurement(str string) bool
- func IsTraceMeasurement(str string) bool
- type Application
- type ApplicationDocument
- type Brand
- type Credential
- type Image
- type Measure
- func (m Measure) Amount() (result float64, trace bool, empty bool)
- func (m Measure) AsCSV() string
- func (m Measure) AsSQL() string
- func (m *Measure) FromString(str string) error
- func (m Measure) IsEmpty() bool
- func (m Measure) IsTrace() bool
- func (m Measure) IsValidPercent() bool
- func (m Measure) IsZero() bool
- func (m Measure) MarshalCSV() (string, error)
- func (m *Measure) MarshalJSON() ([]byte, error)
- func (m *Measure) UnmarshalCSV(value string) error
- func (m *Measure) UnmarshalJSON(b []byte) error
- func (m Measure) Value() (driver.Value, error)
- type Tax
- type WeeklySales
Constants ¶
const ( ApplicationJSONFilename = "us_ct_applications.json" ApplicationCSVFilename = "us_ct_applications.csv" ApplicationsURL = "https://data.ct.gov/resource/bqby-dyzr.json" )
const ( BrandJSONFilename = "us_ct_brands.json" BrandCSVFilename = "us_ct_brands.csv" // BrandsURL is the URL to fetch the CT cannabis brands data BrandsURL = "https://data.ct.gov/resource/egd5-wb6r.json" )
const ( CredentialJSONFilename = "us_ct_credentials.json" CredentialCSVFilename = "us_ct_credentials.csv" CredentialsURL = "https://data.ct.gov/resource/tjfe-s2x9.json" )
const ( WeeklySalesJSONFilename = "us_ct_weekly_sales.json" WeeklySalesCSVFilename = "us_ct_weekly_sales.csv" WeeklySalesURL = "https://data.ct.gov/resource/ucaf-96h6.json" )
const ( TaxJSONFilename = "us_ct_tax.json" TaxCSVFilename = "us_ct_tax.csv" TaxURL = "https://data.ct.gov/resource/jey2-vq68.json" )
Variables ¶
var ApplicationConfig = sources.SocrataConfig{ URL: ApplicationsURL, CacheFilename: ApplicationJSONFilename, }
ApplicationConfig returns the Socrata configuration for applications
var BrandConfig = sources.SocrataConfig{ URL: BrandsURL, CacheFilename: BrandJSONFilename, OrderBy: "registration_number", }
BrandConfig is the Socrata configuration for fetching brands
var CredentialConfig = sources.SocrataConfig{ URL: CredentialsURL, CacheFilename: CredentialJSONFilename, }
CredentialConfig returns the Socrata configuration for credentials
var DuckDBMigration string
var TaxConfig = sources.SocrataConfig{ URL: TaxURL, CacheFilename: TaxJSONFilename, OrderBy: "period_end_date", }
TaxConfig returns the Socrata configuration for tax data
var WeeklySalesConfig = sources.SocrataConfig{ URL: WeeklySalesURL, CacheFilename: WeeklySalesJSONFilename, OrderBy: "unnamed_column", }
WeeklySalesConfig returns the Socrata configuration for weekly sales
Functions ¶
func DBInsertApplications ¶
func DBInsertApplications(conn *sql.DB, applications []Application) error
DBInsertApplications inserts applications into DuckDB
func DBInsertCredentials ¶
func DBInsertCredentials(conn *sql.DB, credentials []Credential) error
DBInsertCredentials inserts credentials into DuckDB
func DBInsertTax ¶
DBInsertTax inserts tax records into DuckDB
func DBInsertWeeklySales ¶
func DBInsertWeeklySales(conn *sql.DB, sales []WeeklySales) error
DBInsertWeeklySales inserts weekly sales into DuckDB
func IsBrandErroneous ¶
IsBrandErroneous checks if the brand is erroneous
func IsEmptyMeasurement ¶
IsEmptyMeasurement returns true if the string is considered an empty measure Examples are: "" and "."
func IsErrorMeasurement ¶
IsErrorMeasurement returns true if the string is considered to be erroneous
func IsTraceMeasurement ¶
IsTraceMeasurement returns true if the string is considered a trace measure Examples are: "TRC" "<LOQ" and "<0.1"
Types ¶
type Application ¶
type Application struct {
ApplicationLicenseNumber string `json:"application_license_number"`
ApplicationCredentialStatus string `json:"application_credential_status"`
StatusReason string `json:"status_reason"`
SECReviewStatus string `json:"sec_review_status"`
InitialApplicationType string `json:"initial_application_type"`
HowSelected string `json:"how_selected"`
Name string `json:"name"`
Documents ApplicationDocument `json:"documents"`
}
Application represents a CT cannabis license application
func FetchApplications ¶
func FetchApplications(appToken string, maxCacheAge time.Duration) ([]Application, error)
FetchApplications fetches all CT cannabis application data from the CT API
func (Application) CSVHeaders ¶
func (a Application) CSVHeaders() string
CSVHeaders returns the CSV headers for the Application struct
func (Application) CSVValue ¶
func (a Application) CSVValue() string
CSVValue returns the CSV value for the Application struct
type ApplicationDocument ¶
type ApplicationDocument struct {
URL string `json:"url"`
}
ApplicationDocument represents a document attached to an application
type Brand ¶
type Brand struct {
BrandName string `csv:"BRAND-NAME" json:"brand_name"`
DosageForm string `csv:"DOSAGE-FORM" json:"dosage_form"`
BrandingEntity string `csv:"BRANDING-ENTITY" json:"branding_entity"`
ProductImage Image `csv:"PRODUCT-IMAGE" json:"product_image"`
LabelImage Image `csv:"LABEL-IMAGE" json:"label_image"`
LabAnalysis Image `csv:"LAB-ANALYSIS" json:"lab_analysis"`
ApprovalDate iso8601.Time `csv:"APPROVAL-DATE" json:"approval_date"`
RegistrationNumber string `csv:"REGISTRATION-NUMBER" json:"registration_number"`
TetrahydrocannabinolThc Measure `csv:"TETRAHYDROCANNABINOL-THC" json:"tetrahydrocannabinol_thc"`
TetrahydrocannabinolAcidThca Measure `csv:"TETRAHYDROCANNABINOL-ACID-THCA" json:"tetrahydrocannabinol_acid_thca"`
CannabidiolsCbd Measure `csv:"CANNABIDIOLS-CBD" json:"cannabidiols_cbd"`
CannabidiolAcidCbda Measure `csv:"CANNABIDIOL-ACID-CBDA" json:"cannabidiol_acid_cbda"`
APinene Measure `csv:"A-PINENE" json:"a_pinene"`
BMyrcene Measure `csv:"B-MYRCENE" json:"b_myrcene"`
BCaryophyllene Measure `csv:"B-CARYOPHYLLENE" json:"b_caryophyllene"`
BPinene Measure `csv:"B-PINENE" json:"b_pinene"`
Limonene Measure `csv:"LIMONENE" json:"limonene"`
Ocimene Measure `csv:"OCIMENE" json:"ocimene"`
LinaloolLin Measure `csv:"LINALOOL-LIN" json:"linalool_lin"`
HumuleneHum Measure `csv:"HUMULENE-HUM" json:"humulene_hum"`
Cbg Measure `csv:"CBG" json:"cbg"`
CbgA Measure `csv:"CBG-A" json:"cbg_a"`
CannabavarinCbdv Measure `csv:"CANNABAVARIN-CBDV" json:"cannabavarin_cbdv"`
CannabichromeneCbc Measure `csv:"CANNABICHROMENE-CBC" json:"cannabichromene_cbc"`
CannbinolCbn Measure `csv:"CANNBINO-CBN" json:"cannbinol_cbn"`
TetrahydrocannabivarinThcv Measure `csv:"TETRAHYDROCANNABIVARIN-THCV" json:"tetrahydrocannabivarin_thcv"`
ABisabolol Measure `csv:"A-BISABOLOL" json:"a_bisabolol"`
APhellandrene Measure `csv:"A-PHELLANDRENE" json:"a_phellandrene"`
ATerpinene Measure `csv:"A-TERPINENE" json:"a_terpinene"`
BEudesmol Measure `csv:"B-EUDESMOL" json:"b_eudesmol"`
BTerpinene Measure `csv:"B-TERPINENE" json:"b_terpinene"`
Fenchone Measure `csv:"FENCHONE" json:"fenchone"`
Pulegol Measure `csv:"PULEGOL" json:"pulegol"`
Borneol Measure `csv:"BORNEOL" json:"borneol"`
Isopulegol Measure `csv:"ISOPULEGOL" json:"isopulegol"`
Carene Measure `csv:"CARENE" json:"carene"`
Camphene Measure `csv:"CAMPHENE" json:"camphene"`
Camphor Measure `csv:"CAMPHOR" json:"camphor"`
CaryophylleneOxide Measure `csv:"CARYOPHYLLENE_OXIDE" json:"caryophyllene_oxide"`
Cedrol Measure `csv:"CEDROL" json:"cedrol"`
Eucalyptol Measure `csv:"EUCALYPTOL" json:"eucalyptol"`
Geraniol Measure `csv:"GERANIOL" json:"geraniol"`
Guaiol Measure `csv:"GUAIOL" json:"guaiol"`
GeranylAcetate Measure `csv:"GERANYL_ACETATE" json:"geranyl_acetate"`
Isoborneol Measure `csv:"ISOBORNEOL" json:"isoborneol"`
Menthol Measure `csv:"MENTHOL" json:"menthol"`
LFenchone Measure `csv:"L-FENCHONE" json:"l_fenchone"`
Nerol Measure `csv:"NEROL" json:"nerol"`
Sabinene Measure `csv:"SABINENE" json:"sabinene"`
Terpineol Measure `csv:"TERPINEOL" json:"terpineol"`
Terpinolene Measure `csv:"TERPINOLENE" json:"terpinolene"`
TransBFarnesene Measure `csv:"TRANS-B-FARNESENE" json:"trans_b_farnesene"`
Valencene Measure `csv:"VALENCENE" json:"valencene"`
ACedrene Measure `csv:"A-CEDRENE" json:"a_cedrene"`
AFarnesene Measure `csv:"A-FARNESENE" json:"a_farnesene"`
BFarnesene Measure `csv:"B-FARNESENE" json:"b_farnesene"`
CisNerolidol Measure `csv:"CIS-NEROLIDOL" json:"cis_nerolidol"`
Fenchol Measure `csv:"FENCHOL" json:"fenchol"`
TransNerolidol Measure `csv:"TRANS-NEROLIDOL" json:"trans_nerolidol"`
Market string `csv:"Market" json:"market"`
Chemotype string `csv:"Chemotype" json:"chemotype"`
ProcessingTechnique string `csv:"Processing Technique" json:"processing_technique"`
SolventsUsed string `csv:"Solvents Used" json:"solvents_used"`
NationalDrugCode string `csv:"National Drug Code" json:"national_drug_code"`
}
Brand represents a raw Cannabis Brand Record from CT
func CleanBrands ¶
CleanBrands filters out bad Brand samples using IsBrandErroneous().
func FetchBrands ¶
FetchBrands fetches all the CT cannabis brands data from the CT API
func (Brand) CSVHeaders ¶
CSVHeaders returns the CSV headers for the Brand struct
type Credential ¶
type Credential struct {
CredentialType string `json:"credentialtype"`
Status string `json:"status"`
Count string `json:"count"`
}
Credential represents a CT cannabis credential count record
func FetchCredentials ¶
func FetchCredentials(appToken string, maxCacheAge time.Duration) ([]Credential, error)
FetchCredentials fetches all CT cannabis credential data from the CT API
func (Credential) CSVHeaders ¶
func (c Credential) CSVHeaders() string
CSVHeaders returns the CSV headers for the Credential struct
func (Credential) CSVValue ¶
func (c Credential) CSVValue() string
CSVValue returns the CSV value for the Credential struct
func (Credential) CountInt ¶
func (c Credential) CountInt() int
CountInt returns the count as an integer
type Measure ¶
type Measure struct {
// contains filtered or unexported fields
}
Measure tracks a measurement, with special flags for no-measurement and trace measurement
func NewEmptyMeasure ¶
func NewEmptyMeasure() Measure
NewEmptyMeasure creates a new "empty" measure. This may also be created through nil-initialization Measure{}
func NewMeasure ¶
NewMeasure creates a new measure with the given amount. Any amount < 0, will be treated as a trace measurement. To create an "empty" Measure object, use nil-initialization Measure{} or NewEmptyMeasure
func NewTraceMeasure ¶
func NewTraceMeasure() Measure
NewTraceMeasure creates a new "trace amount" measure.
func (*Measure) FromString ¶
FromString modifies the given measure based on the passed string
func (Measure) IsValidPercent ¶
IsValidPercent returns true if the measure is a valid percentage (0-100)
func (Measure) MarshalCSV ¶
MarshalCSV marshals the measure to a CSV string
func (*Measure) MarshalJSON ¶
MarshalJSON converts the measure to JSON
func (*Measure) UnmarshalCSV ¶
UnmarshalCSV unmarshals the measure from a CSV string
func (*Measure) UnmarshalJSON ¶
UnmarshalJSON converts the measure from JSON
type Tax ¶
type Tax struct {
PeriodEndDate string `json:"period_end_date"` // ISO 8601 datetime
Month string `json:"month"`
Year string `json:"year"`
FiscalYear string `json:"fiscal_year"`
PlantMaterialTax string `json:"plant_material_tax"`
EdibleProductsTax string `json:"edible_products_tax"`
OtherCannabisTax string `json:"other_cannabis_tax"`
TotalTax string `json:"total_tax"`
}
Tax represents a CT cannabis monthly tax record
func (Tax) CSVHeaders ¶
CSVHeaders returns the CSV headers for the Tax struct
type WeeklySales ¶
type WeeklySales struct {
WeekEnding string `json:"unnamed_column"` // ISO 8601 datetime
AdultUse string `json:"adult_use"`
Medical string `json:"medical"`
Total string `json:"total"`
AdultUseProductsSold string `json:"adult_use_products_sold"`
MedicalProductsSold string `json:"medical_products_sold"`
TotalProductsSold string `json:"total_products_sold"`
AdultUseCannabisAveragePrice string `json:"adult_use_cannabis_average_product_price"`
MedicalMarijuanaAveragePrice string `json:"medical_marijuana_average_product_price"`
}
WeeklySales represents a CT cannabis weekly retail sales record
func FetchWeeklySales ¶
func FetchWeeklySales(appToken string, maxCacheAge time.Duration) ([]WeeklySales, error)
FetchWeeklySales fetches all CT cannabis weekly sales data from the CT API
func (WeeklySales) CSVHeaders ¶
func (s WeeklySales) CSVHeaders() string
CSVHeaders returns the CSV headers for the WeeklySales struct
func (WeeklySales) CSVValue ¶
func (s WeeklySales) CSVValue() string
CSVValue returns the CSV value for the WeeklySales struct