model

package
v0.0.0-...-f83d065 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package model .

Index

Constants

View Source
const (
	RTRead   = "read"   // have read
	RTSkim   = "skim"   // have skimmed
	RTUnread = "unread" // unread: 1. from read to unread; 2. read it later
	RTSkip   = "skip"   // skipped and will not read
)

Read types

Variables

View Source
var (
	ErrDuplicatedQuery = errors.New("Duplicated record")
)

Model errors

Functions

func CreateArticle

func CreateArticle(db *gorm.DB, a *Article) error

CreateArticle .

func GetArticleStatistics

func GetArticleStatistics(db *gorm.DB, loc *time.Location, date time.Time) (
	[]ArticleStat, []ArticleRank, error,
)

GetArticleStatistics .

Types

type Article

type Article struct {
	gorm.Model

	ReadType    string `gorm:"read_type;size:16;not null" json:"Type,omitempty"`
	Title       string `gorm:"title;size:128;not null" json:"Title,omitempty" yaml:"title"`
	URL         string `gorm:"url;size:512;not null" json:"URL,omitempty"`
	Domain      string `gorm:"domain;index;size:256;not null" json:"Domain,omitempty"`
	Author      string `gorm:"author;index;size:128" json:"Author,omitempty"`
	Description string `gorm:"description;size:256" json:"Description,omitempty"`
	Device      string `gorm:"device;index;size:32" json:"Device,omitempty"`

	ReadAtText      string `gorm:"-" json:"CreatedAtText"`
	DescriptionText string `gorm:"-" json:"DescriptionText"`
}

Article definition of an article

func ExportArticles

func ExportArticles(db *gorm.DB, loc *time.Location, year, month int) ([]Article, error)

ExportArticles .

func ListArticles

func ListArticles(db *gorm.DB, loc *time.Location, year, month int) ([]Article, error)

ListArticles .

type ArticleExport

type ArticleExport struct {
	ID          uint      `yaml:"id"`
	ReadType    string    `yaml:"read_type"`
	Title       string    `yaml:"title"`
	URL         string    `yaml:"url"`
	Domain      string    `yaml:"domain"`
	Author      string    `yaml:"author,omitempty"`
	Description string    `yaml:"description,omitempty"`
	Device      string    `yaml:"device,omitempty"`
	CreatedAt   time.Time `yaml:"created_at"`
	UpdatedAt   time.Time `yaml:"updated_at"`
}

ArticleExport for export

type ArticleRank

type ArticleRank struct {
	Name   string
	Count  int64
	Result []ArticleRankResult
}

ArticleRank .

type ArticleRankResult

type ArticleRankResult struct {
	Domain    string
	Device    string
	ReadCount int64
}

ArticleRankResult .

type ArticleStat

type ArticleStat struct {
	Name string
	All  int64
	Read int64
	Skim int64
	Skip int64
}

ArticleStat .

type ArticleStatResult

type ArticleStatResult struct {
	ReadType  string
	ReadCount int64
}

ArticleStatResult .

type User

type User struct {
	Name     string
	Nickname string
	Picture  string
	Sub      string
}

User auth0 user info

Jump to

Keyboard shortcuts

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