flickrdb

package
v0.0.0-...-9d1cc32 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 23 Imported by: 4

Documentation

Index

Constants

View Source
const FlexDateFormatForDb = "2006-01-02"
View Source
const FlexDateFormatForJSON = "2006-01-02"
View Source
const FlexDateFormatForQuery = "2006-01-02"
View Source
const SchemaVersion = 1

Variables

View Source
var (
	PhotoInfoTable = &Table{Name: "photo_info", protoType: &PhotoInfoRow{}, freshness: 1 * time.Hour}
	TagInfoTable   = &Table{Name: "tag_info", protoType: &TagInfoRow{}}
	UrlInfoTable   = &Table{Name: "url_info", protoType: &UrlInfoRow{}}
	NoteInfoTable  = &Table{Name: "note_info", protoType: &NoteInfoRow{}}
)
View Source
var DB *sql.DB
View Source
var DomainTable = &Table{
	Name:      "domain",
	protoType: &DomainRow{},
	freshness: 24 * time.Hour,
}
View Source
var FavsTable = &Table{
	Name:      "favs",
	protoType: &FavsRow{},
	freshness: 1 * time.Hour,
}
View Source
var FreshView = &Table{
	Name:      "fresh",
	protoType: &FreshRow{},
}
View Source
var GroupTable = &Table{
	Name:      "groups",
	protoType: &GroupRow{},
}
View Source
var GroupsPerPhotoView = &Table{
	Name:      "groups_per_photo",
	protoType: &GroupsPerPhotoRow{},
}
View Source
var PhotoGroupTable = &Table{
	Name:      "photo_group",
	protoType: &PhotoGroupRow{},
	freshness: 1 * time.Hour,
}
View Source
var PhotoViewsTable = &Table{
	Name:      "photo_views",
	protoType: &PhotoViewsRow{},
	freshness: 1 * time.Hour,
}
View Source
var PhotosPerGroupView = &Table{
	Name:      "photos_per_group",
	protoType: &PhotosPerGroupRow{},
}
View Source
var PhotosTable = &Table{
	Name:      "photos",
	protoType: &PhotosRow{},
	freshness: 0,
}
View Source
var ReferrerTable = &Table{
	Name:      "referrer",
	protoType: &ReferrerRow{},
	freshness: 24 * time.Hour,
}
View Source
var StatsSummaryView = &Table{
	Name:      "stats_summary",
	protoType: &StatsSummaryRow{},
}
View Source
var TotalViewsTable = &Table{
	Name:      "total_views",
	protoType: &TotalViewsRow{},
}
View Source
var UserGroupTable = &Table{
	Name:      "user_group",
	protoType: &UserGroupRow{},
	freshness: 24 * time.Hour,
}
View Source
var UsersTable = &Table{
	Name:      "users",
	protoType: &UsersRow{},
	freshness: 24 * time.Hour,
}

Functions

func ClearFreshness

func ClearFreshness()

func DbCheck

func DbCheck() (err error)

func DbClear

func DbClear() (err error)

func DbConfigGet

func DbConfigGet(obj interface{}) (err error)

func DbConfigPut

func DbConfigPut(obj interface{}) (err error)

func DbInit

func DbInit() (err error)

func DbInitObjects

func DbInitObjects()

func DbTidy

func DbTidy()

func DoAuth

func DoAuth(setKey, setSecret, authUser string) (justSetup bool, err error)

func Epoch

func Epoch() string

func GetUserInfo

func GetUserInfo() (nsid, name string)

func LoadConfig

func LoadConfig() (err error)

func MarshalConfig

func MarshalConfig() (b []byte, err error)

func Open

func Open(driver, connect string) (err error)

func SaveConfig

func SaveConfig() (err error)

func SetTesting

func SetTesting(t bool)

func SetVerbose

func SetVerbose(v bool)

func Stack

func Stack(e *error)

func UnmarshalConfig

func UnmarshalConfig(b []byte) (err error)

func Wrap

func Wrap(err error) (wrapped error)

Types

type ContentDate

type ContentDate struct {
	Value FlexDate `json:"_content"`
}

type ContentInt

type ContentInt struct {
	Value FlexInt `json:"_content"`
}

type ContentString

type ContentString struct {
	Value string `json:"_content"`
}

type ContentWoeId

type ContentWoeId struct {
	Value string  `json:"_content"`
	WoeId FlexInt `json:"woeid"`
}

type DomainRow

type DomainRow struct {
	PhotoId string   `json:"photo_id" db:"key,index" test:"optional" fill:"query:photo_id"`
	Date    FlexDate `json:"date" db:"key,index" test:"optional" fill:"query:date"`
	Name    string   `json:"name"`
	Views   FlexInt  `json:"views"`
}

type FavsRow

type FavsRow struct {
	PhotoId string `json:"photo_id" db:"key,index" fill:"Photo.Id" test:"optional"`
	NsId    string `json:"nsid" db:"key,index"`
}

type FlexDate

type FlexDate string

func FlexDateFromInt

func FlexDateFromInt(i int64) (f FlexDate)

func FlexDateFromString

func FlexDateFromString(s string) (f FlexDate, err error)

func FlexNow

func FlexNow() FlexDate

func NewFlexDate

func NewFlexDate(t time.Time) FlexDate

func (FlexDate) Add

func (d FlexDate) Add(t time.Duration) FlexDate

func (FlexDate) ForDb

func (d FlexDate) ForDb() (s string)

func (FlexDate) ForQuery

func (d FlexDate) ForQuery() (s string)

func (FlexDate) String

func (d FlexDate) String() string

func (FlexDate) Time

func (d FlexDate) Time() (t time.Time)

func (*FlexDate) UnmarshalJSON

func (d *FlexDate) UnmarshalJSON(b []byte) (err error)

type FlexFloat

type FlexFloat float64

func (FlexFloat) MarshalJSON

func (f FlexFloat) MarshalJSON() ([]byte, error)

func (*FlexFloat) UnmarshalJSON

func (f *FlexFloat) UnmarshalJSON(b []byte) (err error)

type FlexInt

type FlexInt int64

func (FlexInt) MarshalJSON

func (f FlexInt) MarshalJSON() ([]byte, error)

func (*FlexInt) UnmarshalJSON

func (f *FlexInt) UnmarshalJSON(b []byte) (err error)

type FlickrError

type FlickrError struct {
	Stat    string  `json:"stat"`
	Code    FlexInt `json:"code"`
	Message string  `json:"message"`
}

func (FlickrError) Error

func (e FlickrError) Error() string

func (FlickrError) String

func (e FlickrError) String() string

type FlickrQuery

type FlickrQuery map[string]string

func (*FlickrQuery) Execute

func (fq *FlickrQuery) Execute(method string, result interface{}) (err error)

type FreshRow

type FreshRow struct {
	Query     string `json:"query"`
	LastFetch string `json:"last_fetch"`
}

type GroupRow

type GroupRow struct {
	NsId            string        `json:"nsid" db:"key"`
	Id              string        `json:"id"`
	PathAlias       string        `json:"path_alias"`
	Name            ContentString `json:"name"`
	IconFarm        FlexInt       `json:"iconfarm"`
	IconServer      FlexInt       `json:"iconserver"`
	Description     ContentString `json:"description"`
	Rules           ContentString `json:"rules"`
	Members         ContentInt    `json:"members"`
	PoolCount       ContentInt    `json:"pool_count"`
	TopicCount      ContentInt    `json:"topic_count"`
	Privacy         ContentInt    `json:"privacy"`
	Lang            string        `json:"lang"`
	IsPoolModerated FlexInt       `json:"ispoolmoderated"`
	Roles           struct {
		Member    string `json:"member"`
		Moderator string `json:"moderator"`
		Admin     string `json:"admin"`
	} `json:"roles"`
	PhotoLimitOptOut FlexInt       `json:"photo_limit_opt_out"`
	IsMember         FlexInt       `json:"is_member" test:"optional"`
	IsModerator      FlexInt       `json:"is_moderator" test:"optional"`
	IsAdmin          FlexInt       `json:"is_admin" test:"optional"`
	IsFounder        FlexInt       `json:"is_founder" test:"optional"`
	UserGroupPrefs   []interface{} `json:"user_group_prefs"` // Content unknown
	Blast            struct {
		Value          string   `json:"_content"`
		DateBlastAdded FlexDate `json:"date_blast_added"`
		UserId         string   `json:"user_id"`
	} `json:"blast" test:"optional"`
	Throttle struct {
		Count     FlexInt `json:"count" test:"optional"`
		Mode      string  `json:"mode"`
		Remaining FlexInt `json:"remaining" test:"optional"`
	} `json:"throttle"`
	Restrictions struct {
		PhotosOk     FlexInt `json:"photos_ok"`
		VideosOk     FlexInt `json:"videos_ok"`
		ImagesOK     FlexInt `json:"images_ok"`
		ScreensOk    FlexInt `json:"screens_ok"`
		ArtOk        FlexInt `json:"art_ok"`
		SafeOk       FlexInt `json:"safe_ok"`
		ModerateOk   FlexInt `json:"moderate_ok"`
		RestrictedOk FlexInt `json:"restricted_ok"`
		HasGeo       FlexInt `json:"has_geo"`
	} `json:"restrictions"`
}

type GroupsPerPhotoRow

type GroupsPerPhotoRow struct {
	PhotoId    string  `json:"photo_id"`
	GroupCount FlexInt `json:"group_count"`
}

type NoteInfoRow

type NoteInfoRow struct {
	PhotoId    string  `json:"photo_id" db:"key,index" fill:"Photo.Id" test:"optional"`
	Id         string  `json:"id" db:"key"`
	Author     string  `json:"author"`
	AuthorName string  `json:"authorname"`
	X          FlexInt `json:"x"`
	Y          FlexInt `json:"y"`
	W          FlexInt `json:"w"`
	H          FlexInt `json:"h"`
	Note       string  `json:"_content"`
}

type PhotoGroupRow

type PhotoGroupRow struct {
	PhotoId   string `json:"photo_id" db:"key,index"`
	GroupNsId string `json:"group_nsid" db:"key,index"`
}

type PhotoInfoRow

type PhotoInfoRow struct {
	Id    string `json:"id" db:"key"`
	Owner struct {
		NsId       string  `json:"nsid" db:"index"`
		IconFarm   FlexInt `json:"iconfarm" db:"ignore"`
		IconServer FlexInt `json:"iconserver" db:"ignore"`
		Location   string  `json:"location" db:"ignore"`
		PathAlias  string  `json:"path_alias" db:"ignore"`
		RealName   string  `json:"realname" db:"ignore"`
		UserName   string  `json:"username" db:"ignore"`
	} `json:"owner"`
	DateUploaded   FlexDate      `json:"dateuploaded"`
	IsFavorite     FlexInt       `json:"isfavorite"`
	License        FlexInt       `json:"license"`
	SafetyLevel    FlexInt       `json:"safety_level"`
	Rotation       FlexInt       `json:"rotation"`
	OriginalSecret string        `json:"originalsecret" test:"optional"`
	OriginalFormat string        `json:"originalformat" test:"optional"`
	Description    ContentString `json:"description"`
	Visibility     struct {
		IsPublic FlexInt `json:"ispublic"`
		IsFriend FlexInt `json:"isfriend"`
		IsFamily FlexInt `json:"isfamily"`
	} `json:"visibility"`
	Dates struct {
		Posted           FlexDate `json:"posted"`
		Taken            string   `json:"taken"`
		TakenGranularity FlexInt  `json:"takengranularity"`
		TakenUnknown     FlexInt  `json:"takenunknown"`
		LastUpdate       FlexDate `json:"lastupdate"`
	} `json:"dates"`
	Permissions struct {
		PermComment FlexInt `json:"permcomment"`
		PermAddMeta FlexInt `json:"permaddmeta"`
	} `json:"permissions" test:"optional"`
	Views       FlexInt `json:"views"`
	Editability struct {
		CanComment FlexInt `json:"cancomment"`
		CanAddMeta FlexInt `json:"canaddmeta"`
	} `json:"editability"`
	PublicEditability struct {
		CanComment FlexInt `json:"cancomment"`
		CanAddMeta FlexInt `json:"canaddmeta"`
	} `json:"publiceditability"`
	Usage struct {
		CanDownload FlexInt `json:"candownload"`
		CanBlog     FlexInt `json:"canblog"`
		CanPrint    FlexInt `json:"canprint"`
		CanShare    FlexInt `json:"canshare"`
	} `json:"usage"`
	Comments ContentInt `json:"comments"`
	Notes    struct {
		Note []*NoteInfoRow `json:"note"`
	} `json:"notes"`
	People struct {
		HasPeople FlexInt `json:"haspeople"`
	} `json:"people"`
	Tags struct {
		Tag []*TagInfoRow `json:"tag"`
	} `json:"tags"`
	Urls struct {
		Url []*UrlInfoRow `json:"url"`
	} `json:"urls"`
	Media    string `json:"media"`
	GeoPerms struct {
		IsPublic  FlexInt `json:"ispublic"`
		IsContact FlexInt `json:"iscontact"`
		IsFriend  FlexInt `json:"isfriend"`
		IsFamily  FlexInt `json:"isfamily"`
	} `json:"geoperms" test:"optional"`
	Location struct {
		Latitude      FlexFloat    `json:"latitude"`
		Longitude     FlexFloat    `json:"longitude"`
		Accuracy      FlexInt      `json:"accuracy"`
		Context       FlexInt      `json:"context"`
		Locality      ContentWoeId `json:"locality"`
		County        ContentWoeId `json:"county"`
		Region        ContentWoeId `json:"region"`
		Country       ContentWoeId `json:"country"`
		Neighbourhood ContentWoeId `json:"neighbourhood"`
	} `json:"location" test:"optional"`

	Farm   FlexInt       `json:"farm" db:"ignore"`
	Secret string        `json:"secret" db:"ignore"`
	Server FlexInt       `json:"server" db:"ignore"`
	Title  ContentString `json:"title" db:"ignore"`
}

type PhotoViewsRow

type PhotoViewsRow struct {
	PhotoId   string   `json:"photo_id" db:"key" test:"optional"`
	Date      FlexDate `json:"date" db:"key" test:"optional"`
	Views     FlexInt  `json:"views"`
	Comments  FlexInt  `json:"comments"`
	Favorites FlexInt  `json:"favorites"`
}

type PhotosPerGroupRow

type PhotosPerGroupRow struct {
	GroupNsid  string  `json:"group_nsid"`
	PhotoCount FlexInt `json:"photo_count"`
}

type PhotosRow

type PhotosRow struct {
	Id       string  `json:"id" db:"key"`
	Owner    string  `json:"owner"`
	Secret   string  `json:"secret"`
	Server   string  `json:"server"`
	Farm     FlexInt `json:"farm"`
	Title    string  `json:"title"`
	IsPublic FlexInt `json:"ispublic"`
	IsFriend FlexInt `json:"isfriend"`
	IsFamily FlexInt `json:"isfamily"`
}

type ReferrerRow

type ReferrerRow struct {
	PhotoId    string   `json:"photo_id" db:"key,index" test:"optional" fill:"query:photo_id"`
	Domain     string   `json:"domain" db:"key,index" test:"optional" fill:"query:domain"`
	Date       FlexDate `json:"date" db:"key,index" test:"optional" fill:"query:date"`
	Url        string   `json:"url" db:"key,index"`
	Views      FlexInt  `json:"views"`
	SearchTerm string   `json:"searchterm" test:"optional" db:"index"`
}

type Rows

type Rows struct {
	*sql.Rows
	// contains filtered or unexported fields
}

func (*Rows) ScanObj

func (r *Rows) ScanObj(obj interface{}) (err error)

type StackError

type StackError struct {
	// contains filtered or unexported fields
}

func (*StackError) Error

func (s *StackError) Error() string

func (*StackError) Unwrap

func (s *StackError) Unwrap() error

type StatsSummaryRow

type StatsSummaryRow struct {
	PhotoId    string   `json:"photo_id"`
	FavCount   FlexInt  `json:"fav_count"`
	ViewCount  FlexInt  `json:"view_count"`
	PostedDate FlexDate `json:"posted_date"`
	PageUrl    string   `json:"page_url"`
	Title      string   `json:"title"`
	Farm       FlexInt  `json:"farm"`
	Server     string   `json:"server"`
	Secret     string   `json:"secret"`
}

type Table

type Table struct {
	Name string
	// contains filtered or unexported fields
}

func (*Table) Count

func (tbl *Table) Count(where string, objs ...interface{}) (count int64, err error)

func (*Table) InsertArray

func (tbl *Table) InsertArray(tx *sql.Tx, objs interface{}) (err error)

func (*Table) IsFresh

func (tbl *Table) IsFresh() bool

func (*Table) NewInserter

func (tbl *Table) NewInserter(tx *sql.Tx) (ins *TableInserter, err error)

func (*Table) Select

func (tbl *Table) Select(where string, objs ...interface{}) (r *Rows, err error)

func (*Table) UpdateFreshness

func (tbl *Table) UpdateFreshness(tx *sql.Tx) (err error)

type TableInserter

type TableInserter struct {
	*sql.Stmt
	// contains filtered or unexported fields
}

func (*TableInserter) Insert

func (ins *TableInserter) Insert(obj interface{}) (err error)

func (*TableInserter) InsertArray

func (ins *TableInserter) InsertArray(objs interface{}) (err error)

type TagInfoRow

type TagInfoRow struct {
	PhotoId    string  `json:"photo_id" db:"key,index" fill:"Photo.Id" test:"optional"`
	Id         string  `json:"id" db:"key"`
	Author     string  `json:"author"`
	AuthorName string  `json:"authorname"`
	Raw        string  `json:"raw"`
	Tag        string  `json:"_content" db:"index"`
	MachineTag FlexInt `json:"machine_tag"`
}

type TotalViewsRow

type TotalViewsRow struct {
	NsId        string   `json:"id" db:"key" test:"optional"`
	Date        FlexDate `json:"date" db:"key" test:"optional"`
	Total       viewsInt `json:"total"`
	Photos      viewsInt `json:"photos"`
	PhotoStream viewsInt `json:"photostream"`
	Sets        viewsInt `json:"sets"`
	Collections viewsInt `json:"collections"`
	Galleries   viewsInt `json:"galleries"`
}

type UrlInfoRow

type UrlInfoRow struct {
	PhotoId string `json:"photo_id" db:"key,index" fill:"Photo.Id" test:"optional"`
	Type    string `json:"type" db:"key"`
	Url     string `json:"_content"`
}

type UserGroupRow

type UserGroupRow struct {
	UserNsId  string `json:"user_nsid" db:"key,index"`
	GroupNsId string `json:"group_nsid" db:"key"`
}

type UsersRow

type UsersRow struct {
	NsId string `json:"nsid" db:"key"`
	Id   string `json:"id"`

	IsPro      FlexInt `json:"ispro"`
	CanBuyPro  FlexInt `json:"can_buy_pro"`
	IconServer string  `json:"iconserver"`
	IconFarm   FlexInt `json:"iconfarm"`
	PathAlias  string  `json:"path_alias"`
	HasStats   string  `json:"has_stats"`
	ProBadge   string  `json:"pro_badge" test:"optional"`
	Expire     string  `json:"expire" test:"optional"`

	UserName    ContentString `json:"username"`
	RealName    ContentString `json:"realname" test:"optional"`
	MboxSha1Sum ContentString `json:"mbox_sha1sum" test:"optional"`

	Location ContentString `json:"location" test:"optional"`
	TimeZone struct {
		Label  string `json:"label"`
		Offset string `json:"offset"`
		Id     string `json:"timezone_id"`
	} `json:"timezone" test:"optional"`

	Description ContentString `json:"description"`
	PhotosUrl   ContentString `json:"photosurl"`
	ProfileUrl  ContentString `json:"profileurl"`
	MobileUrl   ContentString `json:"mobileurl"`

	Photos struct {
		FirstDateTaken ContentDate `json:"firstdatetaken"`
		FirstDate      ContentDate `json:"firstdate"`
		Count          ContentInt  `json:"count"`
		Views          ContentInt  `json:"views" test:"optional"`
	} `json:"photos"`
	UploadCount                 FlexInt `json:"upload_count" test:"optional"`
	UploadLimit                 FlexInt `json:"upload_limit" test:"optional"`
	UploadLimitStatus           string  `json:"upload_limit_status" test:"optional"`
	IsCognitoUser               FlexInt `json:"is_cognito_user" test:"optional"`
	AllRightsReservedPhotoCount FlexInt `json:"all_rights_reserved_photos_count" test:"optional"`

	Ignored FlexInt `json:"ignored" test:"optional"`
	Gender  string  `json:"gender" test:"optional"`

	Contact    FlexInt `json:"contact" test:"optional"`
	Friend     FlexInt `json:"friend" test:"optional"`
	Family     FlexInt `json:"family" test:"optional"`
	RevContact FlexInt `json:"revcontact" test:"optional"`
	RevFriend  FlexInt `json:"revfriend" test:"optional"`
	RevFamily  FlexInt `json:"revfamily" test:"optional"`
}

Jump to

Keyboard shortcuts

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