models

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: CC0-1.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCantSwitchToYourself = errors.New("models: you can't switch to yourself")
)

Functions

This section is empty.

Types

type Blogpost

type Blogpost struct {
	gorm.Model            // adds CreatedAt, UpdatedAt, DeletedAt
	ID          string    `gorm:"uniqueIndex"` // unique identifier for the blogpost
	URL         string    `gorm:"uniqueIndex"` // URL of the blogpost
	Title       string    // title of the blogpost
	BodyHTML    string    // HTML body of the blogpost
	Image       string    // URL of the image for the blogpost
	PublishedAt time.Time // when the blogpost was published
}

Blogpost is a single blogpost from a JSON Feed.

This is tracked in the database so that the Announcer service can avoid double-posting.

type DAO

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

func New

func New(dbLoc, backupDBLoc string) (*DAO, error)

func (*DAO) Backup added in v1.11.0

func (d *DAO) Backup()

func (*DAO) CreateEvent

func (d *DAO) CreateEvent(ctx context.Context, event *Event) (*Event, error)

func (*DAO) DB

func (d *DAO) DB() *gorm.DB

func (*DAO) GetEvent

func (d *DAO) GetEvent(ctx context.Context, id int) (*Event, error)

func (*DAO) GetSwitch

func (d *DAO) GetSwitch(ctx context.Context, id string) (*Switch, error)

func (*DAO) HasBlogpost

func (d *DAO) HasBlogpost(ctx context.Context, postURL string) (bool, error)

func (*DAO) InsertBlogpost

func (d *DAO) InsertBlogpost(ctx context.Context, post *jsonfeed.Item) (*Blogpost, error)

func (*DAO) ListSwitches

func (d *DAO) ListSwitches(ctx context.Context, count, page int) ([]Switch, error)

func (*DAO) Members

func (d *DAO) Members(ctx context.Context) ([]Member, error)

func (*DAO) Ping

func (d *DAO) Ping(ctx context.Context) error

func (*DAO) RemoveEvent added in v1.11.0

func (d *DAO) RemoveEvent(ctx context.Context, id int) error

func (*DAO) SwitchFront

func (d *DAO) SwitchFront(ctx context.Context, memberName string) (*Switch, *Switch, error)

func (*DAO) UpcomingEvents

func (d *DAO) UpcomingEvents(ctx context.Context, count int) ([]Event, error)

func (*DAO) WhoIsFront

func (d *DAO) WhoIsFront(ctx context.Context) (*Switch, error)

type Event

type Event struct {
	gorm.Model
	ID          int `gorm:"primaryKey"`
	Name        string
	URL         string
	StartDate   time.Time
	EndDate     time.Time
	Location    string `gorm:"index"`
	Description string
	Syndicate   bool
}

Event represents an event that members of DevRel will be attending.

func (*Event) AsProto

func (e *Event) AsProto() *pb.Event

type Member

type Member struct {
	ID        int    // unique number to use as a primary key
	Name      string `gorm:"uniqueIndex"` // the name of the member
	AvatarURL string // public URL to the member's avatar
}

Member is a member of the Within system.

func (Member) AsProto

func (m Member) AsProto() *pb.Member

AsProto converts a Member to its protobuf representation.

type Switch

type Switch struct {
	gorm.Model            // adds CreatedAt, UpdatedAt, DeletedAt
	ID         string     `gorm:"uniqueIndex"` // unique identifier for the switch (ULID usually)
	EndedAt    *time.Time // when the switch ends, different from DeletedAt
	MemberID   int        // the member who is now in front
	Member     Member     `gorm:"foreignKey:MemberID"`
}

Switch is a record of the system switching front to a different member.

func (Switch) AsFrontChange

func (s Switch) AsFrontChange() *pb.FrontChange

AsFrontChange converts a Switch to a FrontChange protobuf.

func (*Switch) AsProto

func (s *Switch) AsProto() *pb.Switch

AsProto converts a Switch to its protobuf representation.

Jump to

Keyboard shortcuts

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