DataManager

package
v0.0.0-...-31ad618 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Unlicense Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Sqlite3Timestamp  = "2006-01-02 15:04:05"
	Fsqlite3Timestamp = "2006-01-02T15:04:05Z"
)
View Source
const (
	RDupe reportType = iota
	RNonDupe
)
View Source
const (
	PFID sqlbinder.Field = iota
	PFCid
	PFThumbnails
	PFMime
	PFRemoved
	PFDeleted
	PFSize
	PFDimension
	PFScore
	PFTimestamp
	PFChecksums
	PFAlts
	PFAltGroup
	PFDescription
	PFTombstone
	PFMetaData
)
View Source
const (
	FID sqlbinder.Field = iota
	FTag
	FCount
	FNamespace
)

Variables

View Source
var DB *sql.DB
View Source
var Mimes []*Mime

Functions

func AliasTags

func AliasTags(fromStr, toStr string) loggingAction

func AlterManyPostTags

func AlterManyPostTags(pids []int, addStr, remStr string, delim rune) loggingAction

func AlterPostTags

func AlterPostTags(postID int, tagstr, tagdiff string) loggingAction

Add and remove tags from a post performing related parent/alias lookups and producing a log

func Archive

func Archive(id string) *archive

func AssignDuplicates

func AssignDuplicates(dupe Dupe, user user.User) error

func CalculateChecksums

func CalculateChecksums() error

func Close

func Close() error

func Counter

func Counter() int

func CreateChapter

func CreateChapter(comicID, order int, title string) loggingAction

func CreateComic

func CreateComic(title string, retid *int) loggingAction

func CreateComicPage

func CreateComicPage(chapterID, postID, page int) loggingAction

func DeleteChapter

func DeleteChapter(chapterID int, comicID *int) loggingAction

func DeleteComic

func DeleteComic(comicID int) loggingAction

func DeleteComicPage

func DeleteComicPage(pageID int) loggingAction

func DeleteComment

func DeleteComment(id int) error

func DnsMapTag

func DnsMapTag(creatorID int, tagstr string) error

func DnsNewBanner

func DnsNewBanner(file io.ReadSeeker, creatorID int, bannerType string) error

func DuplicateReportCleanup

func DuplicateReportCleanup() (int64, error)

Cleanup non apple-tree reports

func EditChapter

func EditChapter(chapterID, order int, title string) loggingAction

func EditComic

func EditComic(comicID int, title string) loggingAction

func EditComicPage

func EditComicPage(pageID, chapterID, postID, page int) loggingAction

func GenPhash

func GenPhash() error

func GenerateFileDimensions

func GenerateFileDimensions()

func GenerateFileSizes

func GenerateFileSizes() error

func GeneratePears

func GeneratePears() error

func GeneratePearsTx

func GeneratePearsTx(tx *sql.Tx) error

func GenerateThumbnail

func GenerateThumbnail(postID int) error

func GenerateThumbnails

func GenerateThumbnails(size int)

func GetTotalPosts

func GetTotalPosts() int

func HasVoted

func HasVoted(userID user.ID, postID int) (bool, error)

func InitDir

func InitDir()

func MigrateStore

func MigrateStore(start int)

func MimeIDsFromType

func MimeIDsFromType(mslice []string) []int

func ParentTags

func ParentTags(childStr, parentStr string) loggingAction

func PluckApple

func PluckApple(dupe Dupe) error

func PostAddMetaData

func PostAddMetaData(postID int, metaStr string) ([]loggingAction, error)

func PostChangeDescription

func PostChangeDescription(postID int, newDescr string) loggingAction

func PostRemoveMetaData

func PostRemoveMetaData(postID int, metaDataStrings []string) ([]loggingAction, error)

func ProcessDupReport

func ProcessDupReport(reportID int) error

func RecalculateAppletree

func RecalculateAppletree() error

Remove mismatched appletrees

func RegisterPostView

func RegisterPostView(postID int)

func ReportDuplicates

func ReportDuplicates(dupe Dupe, reporter user.User, note string, repT reportType) error

func Root

func Root() string

func SetAlts

func SetAlts(posts []int) loggingAction

func Setup

func Setup(iApi string)

func ShiftChapterPages

func ShiftChapterPages(chapterID, shiftBy, symbol, page int) loggingAction

func SplitAlts

func SplitAlts(posts []int) loggingAction

Split the altgroup into two separate groups one with the supplied post ids the other with the remaining alts

func UnaliasTags

func UnaliasTags(fromStr string) loggingAction

func UnparentTags

func UnparentTags(childStr, parentStr string) loggingAction

func UpdateTombstone

func UpdateTombstone(filep string) error

func UpdateUserFlags

func UpdateUserFlags(newFlag, oldFlag int) error

func UpgradePostCids

func UpgradePostCids()

func VerifyFileIntegrity

func VerifyFileIntegrity(start int) error

Types

type AppleTree

type AppleTree struct {
	Apple *Post
	Pears []*Post
}

func GetAppleTrees

func GetAppleTrees(tagStr string, baseonPear bool, limit, offset int) ([]AppleTree, error)

type Chapter

type Chapter struct {
	ID    int
	Title string
	Order int
	Pages []ComicPage
	Comic *Comic
}

func GetPostChapters

func GetPostChapters(postID int, postFields ...sqlbinder.Field) ([]*Chapter, error)

func (*Chapter) NPages

func (c *Chapter) NPages(n int) []ComicPage

func (*Chapter) PageCount

func (c *Chapter) PageCount() int

type Comic

type Comic struct {
	ID        int
	Title     string
	FrontPage *Post
	Chapters  []*Chapter
	PageCount int

	TagSummary []Tag
}

func GetComic

func GetComic(comicID int) (*Comic, error)

func (*Comic) ChapterIndex

func (comic *Comic) ChapterIndex(index int) *Chapter

type ComicPage

type ComicPage struct {
	ID   int
	Post *Post
	Page int
}

type Comics

type Comics struct {
	Comics []*Comic
	Total  int
}

func SearchComics

func SearchComics(title, tagStr string, limit, offset int) (c Comics, err error)

type Comment

type Comment struct {
	ID           int
	User         user.User
	Text         string
	CompiledText string
	Time         timestamp.Timestamp
}

func CommentByID

func CommentByID(id int) (Comment, error)

func (*Comment) Edit

func (cm *Comment) Edit(text string) error

func (*Comment) Save

func (cm *Comment) Save(userID int, text string) error

Save a new comment to the wall

func (Comment) Username

func (cm Comment) Username() string

type CommentCollector

type CommentCollector struct {
	Comments []Comment
}

CommentModel is used to retriev and save comments

func (*CommentCollector) Get

func (cm *CommentCollector) Get(q querier, count int, daemon string) error

Get the latest comments

type Config

type Config struct {
	//Database string
	ConnectionString string
	StdUserFlag      flag.Flag
	Store            string
	MFSRootDir       string
	ThumbnailFormat  string
	ThumbnailSizes   []uint
	ThumbnailQuality int
}
var CFG *Config

func (*Config) Default

func (c *Config) Default()

type Dimension

type Dimension struct {
	Width  int
	Height int
}

type DnsCreator

type DnsCreator struct {
	Id        int
	Name      string
	Score     int
	Tags      []DnsTag
	LocalTags []Tag
	Domains   map[string]DnsDomain
	Banners   map[string]string
}

func DnsGetCreatorFromTag

func DnsGetCreatorFromTag(tagId int) (DnsCreator, error)

func DnsSpotlight

func DnsSpotlight() (*DnsCreator, error)

func GetDnsCreator

func GetDnsCreator(id int) (c DnsCreator, err error)

func ListDnsCreators

func ListDnsCreators(limit, offset int) ([]DnsCreator, error)

type DnsDomain

type DnsDomain struct {
	Domain dns.Domain
	Urls   []dns.URL
}

type DnsTag

type DnsTag struct {
	Id          string
	Name        string
	Description string
	Score       int
}

type DupReport

type DupReport struct {
	ID         int
	ReportType reportType
	Reporter   user.User
	Note       string
	Approved   timestamp.Timestamp
	Timestamp  timestamp.Timestamp
	Dupe       Dupe
}

func FetchDupReport

func FetchDupReport(id int, q querier) (*DupReport, error)

func FetchDupReports

func FetchDupReports(limit, offset int, asc, approved, pluckedReports bool) ([]*DupReport, error)

func (*DupReport) QInferior

func (r *DupReport) QInferior(q querier) error

type Dupe

type Dupe struct {
	Post     *Post
	Inferior []*Post
}

type DupeConflict

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

func (DupeConflict) Error

func (d DupeConflict) Error() string

type DupeReportStats

type DupeReportStats struct {
	Average duration
	Total   int
}

func GetDupeReportDelay

func GetDupeReportDelay() (report DupeReportStats, err error)

type ErrorTag

type ErrorTag string

func (ErrorTag) Error

func (e ErrorTag) Error() string

type Log

type Log struct {
	ID        int
	User      user.User
	Timestamp timestamp.Timestamp

	// Post logs
	Posts postHistoryMap

	// Alts
	Alts []logAlts

	// Duplicates
	Duplicates logDuplicates

	// Alias
	Aliases logAliasMap

	// Parents
	Parents logParent

	// Multi tags
	MultiTags map[lAction][]logMultiTags

	// Comics
	Comic      logComic
	Chapters   []logChapter
	ComicPages []logComicPage
}

func SearchLogs

func SearchLogs(opts LogSearchOptions) ([]Log, int, error)

type LogCategory

type LogCategory int
const (
	LogNoCat LogCategory = iota
	LogCatPost
	LogCatComic
	LogCatChapter
	LogCatComicPage
)

type LogSearchOptions

type LogSearchOptions struct {
	Category LogCategory
	CatVal   int

	UserID int

	DateSince time.Time
	DateUntil time.Time

	Limit  int
	Offset int
}

type MetaData

type MetaData interface {
	String() string

	Namespace() namespace.Namespace
	Data() string
	// contains filtered or unexported methods
}

type Mime

type Mime struct {
	ID   int
	Name string
	Type string
}

func NewMime

func NewMime() *Mime

func (*Mime) Parse

func (m *Mime) Parse(str string) error

func (*Mime) QID

func (m *Mime) QID(q querier) int

func (*Mime) QName

func (m *Mime) QName(q querier) string

func (*Mime) QType

func (m *Mime) QType(q querier) string

func (*Mime) Save

func (m *Mime) Save(q querier) error

func (Mime) Str

func (m Mime) Str() string

func (Mime) String

func (m Mime) String() string

type Namespace

type Namespace = namespace.Namespace

type Pool

type Pool struct {
	pool.Pool

	Posts []PoolMapping
}

func PoolFromID

func PoolFromID(ctx context.Context, id pool.ID) (Pool, error)

Until posts refactor

func PoolsOfUser

func PoolsOfUser(ctx context.Context, id user.ID) ([]Pool, error)

func (*Pool) PostsLimit

func (p *Pool) PostsLimit(limit int) []PoolMapping

func (*Pool) QPosts

func (p *Pool) QPosts(q querier) error

type PoolMapping

type PoolMapping struct {
	Post     *Post
	Position int
}

type Post

type Post struct {
	ID  int
	Cid string

	Mime      *Mime
	Removed   bool
	Deleted   bool
	Size      int64
	Dimension Dimension
	Score     float64
	Timestamp timestamp.Timestamp

	Checksums checksums

	AltGroup int
	Alts     []*Post
	MetaData metaDataMap

	Tombstone Tombstone

	Description string
	// contains filtered or unexported fields
}

func CachedPost

func CachedPost(p *Post) *Post

func CreatePost

func CreatePost(file io.ReadSeeker, user user.User, ud UploadData) (*Post, error)

func GetPostFromCID

func GetPostFromCID(cid string) (*Post, error)

func GetPostFromHash

func GetPostFromHash(fnc, hash string) (*Post, error)

func ImageLookup

func ImageLookup(file io.ReadSeeker, distance int) ([]*Post, error)

func NewPost

func NewPost() *Post

func RecentUploads

func RecentUploads(userID user.ID) ([]Post, error)

func RecentVotes

func RecentVotes(userID user.ID) ([]Post, error)

func (*Post) BindField

func (p *Post) BindField(sel *sqlbinder.Selection, field sqlbinder.Field)

func (Post) ClosestThumbnail

func (p Post) ClosestThumbnail(size int) (ret string)

func (*Post) Comments

func (p *Post) Comments(q querier) ([]PostComment, error)

func (*Post) Delete

func (p *Post) Delete() error

No going back

func (*Post) Duplicates

func (p *Post) Duplicates(q querier) (Dupe, error)

func (*Post) FindSimilar

func (p *Post) FindSimilar(q querier, dist int, removed bool) ([]*Post, error)

func (*Post) NewComment

func (p *Post) NewComment() PostComment

func (*Post) QAlts

func (p *Post) QAlts(q querier, fields ...sqlbinder.Field) error

func (*Post) QMul

func (p *Post) QMul(q querier, fields ...sqlbinder.Field) error

func (*Post) QTagHistoryCount

func (p *Post) QTagHistoryCount(q querier) (int, error)

func (*Post) QThumbs

func (p *Post) QThumbs(q querier, fields ...sqlbinder.Field) error

func (*Post) Reinstate

func (p *Post) Reinstate(q querier) error

func (*Post) Remove

func (p *Post) Remove(q querier) error

func (*Post) SetID

func (p *Post) SetID(q querier, id int) error

func (*Post) SizePretty

func (p *Post) SizePretty() string

func (Post) Tags

func (p Post) Tags() ([]Tag, error)

func (Post) Thumbnails

func (p Post) Thumbnails() []Thumb

func (*Post) Vote

func (p *Post) Vote(q querier, u user.User) error

type PostCollector

type PostCollector struct {
	TotalPosts int
	// contains filtered or unexported fields
}

func CachedPostCollector

func CachedPostCollector(pc *PostCollector) *PostCollector

func NewPostCollector

func NewPostCollector() *PostCollector

func (*PostCollector) ArchiveSearch

func (pc *PostCollector) ArchiveSearch() (*archive, error)

func (*PostCollector) Get

func (pc *PostCollector) Get(opts SearchOptions) error

func (*PostCollector) Search2

func (pc *PostCollector) Search2(limit, offset int) (SearchResult, error)

func (*PostCollector) Tags

func (pc *PostCollector) Tags(maxTags int) []Tag

type PostComment

type PostComment struct {
	ID   int
	Post *Post
	User user.User
	Text string
	Time timestamp.Timestamp
}

func (*PostComment) Save

func (pc *PostComment) Save(q querier) error

Save a new comment on a post

type ProgressState

type ProgressState struct {
	Message string
	Percent float32
}

type Report

type Report struct {
	ID          int
	Post        *Post
	Reporter    user.User
	Reason      int
	Description string
}

func GetReports

func GetReports(q querier) ([]*Report, error)

func NewReport

func NewReport() Report

func (Report) Delete

func (r Report) Delete(q querier) error

func (Report) Submit

func (r Report) Submit() error

type SearchOptions

type SearchOptions struct {
	And    string
	Or     string
	Filter string
	Unless string

	MimeIDs    []int
	Altgroup   int
	AltCollect bool
	Tombstone  bool
	Order      string
}

type SearchResult

type SearchResult []resultSet

type Tag

type Tag struct {
	ID        int
	Tag       string
	Namespace Namespace
	Count     int
}

func TagFromID

func TagFromID(id int) (Tag, error)

func TagHints

func TagHints(str string) ([]Tag, error)

func (Tag) Aliasing

func (t Tag) Aliasing() (to *Tag, from []Tag, err error)

Get the aliasing of the tag returns aliased_to, aliased_from, error

func (Tag) EditString

func (t Tag) EditString() string

func (Tag) Escaped

func (t Tag) Escaped() string

func (Tag) Family

func (t Tag) Family() (children, parents, grandChildren, grandParents []Tag, err error)

Get the family tree of the tag returns children, parents, grandchildren, grandparents, error

func (Tag) Less

func (a Tag) Less(b Tag) bool

func (*Tag) Rebind

func (t *Tag) Rebind(sel *sqlbinder.Selection, field sqlbinder.Field)

func (Tag) String

func (t Tag) String() string

type TagsResult

type TagsResult struct {
	Tags  []Tag
	Count int
}

func SearchTags

func SearchTags(tagstr string, limit, offset int) (TagsResult, error)

type Thumb

type Thumb struct {
	Cid  string
	Size int
}

func (*Thumb) Rebind

func (t *Thumb) Rebind(sel *sqlbinder.Selection, field sqlbinder.Field)

type Tombstone

type Tombstone struct {
	Post    *Post
	E6id    int
	Md5     string
	Reason  string
	Removed timestamp.Timestamp
}

func GetTombstonedPosts

func GetTombstonedPosts(query string, limit, offset int) (int, []Tombstone, error)

type UploadData

type UploadData struct {
	FileSize    int64
	TagStr      string
	Mime        string
	MetaData    string
	Description string
}

type UserActions

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

func UserAction

func UserAction(user user.User) *UserActions

func (*UserActions) Add

func (a *UserActions) Add(l ...loggingAction)

func (UserActions) Exec

func (a UserActions) Exec() error

Jump to

Keyboard shortcuts

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