db

package
v0.0.0-...-8db0839 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertParticipant

func InsertParticipant(user *User, recruitment *Recruitment, alternate bool) error

Types

type Channel

type Channel struct {
	gorm.Model
	DiscordChannelId         int64
	DiscordGuildId           int64
	Recruitment              bool
	Timezone                 string
	Language                 string
	ReserveLimitTime         uint32
	ExpireDuration           uint32
	ExpireDurationForReserve uint32
	TwitterConfigId          uint32
}

func FetchAllChannels

func FetchAllChannels() ([]*Channel, error)

func FindChannel

func FindChannel(discordChannelId int64) (*Channel, error)

func FindOrCreateChannel

func FindOrCreateChannel(discordChannelId, discordGuildId int64) (*Channel, error)

func (*Channel) DiscordIdStr

func (c *Channel) DiscordIdStr() string

func (*Channel) IsEnabledRecruitment

func (c *Channel) IsEnabledRecruitment() bool

func (*Channel) LoadLocation

func (c *Channel) LoadLocation() *time.Location

func (*Channel) UpdateExpireDuration

func (c *Channel) UpdateExpireDuration(expireDuration uint32) error

func (*Channel) UpdateExpireDurationForReserve

func (c *Channel) UpdateExpireDurationForReserve(expireDurationForReserve uint32) error

func (*Channel) UpdateLanguage

func (c *Channel) UpdateLanguage(language string) error

func (*Channel) UpdateRecruitment

func (c *Channel) UpdateRecruitment(isRecruitment bool) error

func (*Channel) UpdateReserveLimitTime

func (c *Channel) UpdateReserveLimitTime(reserveLimitTime uint32) error

func (*Channel) UpdateTimezone

func (c *Channel) UpdateTimezone(timezone string) error

type Nickname

type Nickname struct {
	gorm.Model
	DiscordUserId  int64
	DiscordGuildId int64
	Name           string
}

func FindNickname

func FindNickname(discordUserId, discordGuildId int64) (*Nickname, error)

func UpdateNickname

func UpdateNickname(discordUserId, discordGuildId int64, name string) (*Nickname, error)

type Participant

type Participant struct {
	gorm.Model
	DiscordUserId int64
	RecruitmentId uint32
	Alternate     bool
	User          User `gorm:"foreignkey:DiscordUserId;references:discord_user_id"`
}

func (*Participant) Delete

func (p *Participant) Delete() error

type Recruitment

type Recruitment struct {
	gorm.Model
	DiscordChannelId int64
	Label            uint32
	Title            string
	EncryptedTitle   []byte
	Capacity         uint32
	Active           bool
	Notified         bool
	TweetId          int64
	ReserveAt        *time.Time
	ExpireAt         *time.Time
	Participants     []Participant `gorm:"foreignkey:RecruitmentId"`
}

func FetchActiveRecruitmentWithLabel

func FetchActiveRecruitmentWithLabel(channel *Channel, label int) (*Recruitment, error)

指定ラベルの募集を取得する ユーザー名、ニックネームは取得しない

func FetchActiveRecruitments

func FetchActiveRecruitments(channel *Channel) ([]*Recruitment, error)

指定チャンネルの全募集を取得する ユーザー名、ニックネームも取得する

func InsertRecruitment

func InsertRecruitment(user *User, channel *Channel, title string, capacity uint32, reserveAt *time.Time) (*Recruitment, string, error)

func ResurrectClosedRecruitment

func ResurrectClosedRecruitment(channel *Channel) (*Recruitment, error)

func (*Recruitment) AuthorName

func (r *Recruitment) AuthorName() string

func (*Recruitment) CloseRecruitment

func (r *Recruitment) CloseRecruitment() error

func (*Recruitment) ExpireAtTime

func (r *Recruitment) ExpireAtTime(timezone *time.Location) string

func (*Recruitment) GetTitle

func (r *Recruitment) GetTitle() string

func (*Recruitment) IsParticipantsFull

func (r *Recruitment) IsParticipantsFull() bool

func (*Recruitment) IsPastExpireAt

func (r *Recruitment) IsPastExpireAt() bool

func (*Recruitment) IsPastReserveAt

func (r *Recruitment) IsPastReserveAt() bool

予定時間が過ぎている、もしくは予定がなければtrue 予定時間が存在してまだ過ぎていないならfalse

func (*Recruitment) JoinParticipant

func (r *Recruitment) JoinParticipant(user *User, channel *Channel) (bool, error)

func (*Recruitment) JoinParticipantAlternate

func (r *Recruitment) JoinParticipantAlternate(user *User, channel *Channel) (bool, error)

func (*Recruitment) LeaveParticipant

func (r *Recruitment) LeaveParticipant(user *User, channel *Channel) (bool, error)

func (*Recruitment) MemberNames

func (r *Recruitment) MemberNames(alternate bool) []string

func (*Recruitment) NotifyRecruitment

func (r *Recruitment) NotifyRecruitment() error

func (*Recruitment) ParticipantCount

func (r *Recruitment) ParticipantCount() int

func (*Recruitment) ProcessOnTime

func (r *Recruitment) ProcessOnTime(now time.Time) (bool, bool, error)

func (*Recruitment) Reload

func (r *Recruitment) Reload(channel *Channel)

func (*Recruitment) ReserveAtTime

func (r *Recruitment) ReserveAtTime(timezone *time.Location) string

func (*Recruitment) UpdateTweetId

func (r *Recruitment) UpdateTweetId(id int64) error

func (*Recruitment) VacantSize

func (r *Recruitment) VacantSize() int

type TwitterConfig

type TwitterConfig struct {
	gorm.Model
	ConsumerKey       string
	ConsumerSecret    string
	AccessToken       string
	AccessTokenSecret string
	Title             string
}

func FindTwitterConfig

func FindTwitterConfig(id uint32) (*TwitterConfig, error)

type User

type User struct {
	gorm.Model
	DiscordUserId int64
	Name          string
	Nickname      Nickname `gorm:"foreignkey:DiscordUserId;references:discord_user_id"`
}

func FindOrCreateUser

func FindOrCreateUser(discordUserId int64, name string) (*User, error)

func FindUser

func FindUser(discordUserId int64) (*User, error)

func (*User) DisplayName

func (u *User) DisplayName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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