model

package
v0.0.0-...-dd1a276 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func AddLeetCodeProblem

func AddLeetCodeProblem(problem *Problem)

func ClearTestDatabase

func ClearTestDatabase()

func ConnectionDatabase

func ConnectionDatabase()

正式環境的資料庫

func CountStudyGroupProblems

func CountStudyGroupProblems(SID uuid.UUID) int64

總共有幾題會報告

func CreateLeetCodeProblemsTable

func CreateLeetCodeProblemsTable()

func CreateNewReport

func CreateNewReport(UserID string, ProblemID int, SID uuid.UUID)

func DeleteReport

func DeleteReport(UserID string, ProblemID int, SID uuid.UUID)

func DeleteUserReports

func DeleteUserReports(UserID, GuildID string)

func GetTodayEnd

func GetTodayEnd() int64

獲得當日12點時間戳

func IsStudyGroupExist

func IsStudyGroupExist(GuildID string) bool

true => study group is exist

func SetDB

func SetDB(db *gorm.DB)

test database

func SetStudyGroupTime

func SetStudyGroupTime(GuildID string, t time.Time) (uuid.UUID, bool)

func UpdateSgAttendance

func UpdateSgAttendance(SID uuid.UUID) (int, int)

更新study group 人數狀態並且回傳舉辦時間

func VerifyProblem

func VerifyProblem(ProblemID int) bool

return true mean problem exist

func VerifyReport

func VerifyReport(UserID string, ProblemID int, SID uuid.UUID) bool

不存在指定的report return true

func VerifyStudyGroup

func VerifyStudyGroup(GuildID string) uuid.UUID

if studygroup update, remeber also update new studygroup turn && old studygroup next turn value.

Types

type LeetCode

type LeetCode struct {
	UserName  string `json:"user_name"`
	NumSolved int    `json:"num_solved"`
	NumTotal  int    `json:"num_total"`
	AcEasy    int    `json:"ac_easy"`
	AcMedium  int    `json:"ac_medium"`
	AcHard    int    `json:"ac_hard"`

	StatStatusPairs []struct {
		Stat struct {
			QuestionID          int         `json:"question_id"`
			QuestionArticleLive interface{} `json:"question__article__live"` //
			QuestionArticleSlug interface{} `json:"question__article__slug"` //
			QuestionTitle       string      `json:"question__title"`
			QuestionTitleSlug   string      `json:"question__title_slug"`
			QuestionHide        bool        `json:"question__hide"`
			TotalAcs            int         `json:"total_acs"`
			TotalSubmitted      int         `json:"total_submitted"`
			FrontendQuestionID  int         `json:"frontend_question_id"`
			IsNewQuestion       bool        `json:"is_new_question"`
		} `json:"stat"`

		Status interface{} `json:"status"` //

		Difficulty struct {
			Level int `json:"level"`
		} `json:"difficulty"`

		PaidOnly  bool `json:"paid_only"`
		IsFavor   bool `json:"is_favor"`
		Frequency int  `json:"frequency"`
		Progress  int  `json:"progress"`
	} `json:"stat_status_pairs"`
}

leetcode api data struct

type Problem

type Problem struct {
	ProblemID    int    `gorm:"primaryKey"`
	ProblemTitle string `gorm:"not null"`
	ProblemURL   string
	Difficulty   int
	PaidOnly     bool
	Submit       int
	Accept       int
}

func SearchWithProblemID

func SearchWithProblemID(ID int) (*Problem, error)

func SearchWithProblemIDTest

func SearchWithProblemIDTest(ID int) (*Problem, error)

func SearchWithProblemTitle

func SearchWithProblemTitle(title string) (*Problem, error)

type Report

type Report struct {
	UserID    string    `gorm:"not null;"`
	ProblemID int       `gorm:"not null;"`
	SID       uuid.UUID `gorm:"type: char(36); not null;"`
}

type ReportsResult

type ReportsResult struct {
	ProblemID  int
	Title      string
	Difficulty int
}

func GetStudyGroupReports

func GetStudyGroupReports(SID uuid.UUID) []ReportsResult

func GetUserReports

func GetUserReports(SID uuid.UUID, UserID string) []ReportsResult

use user_id and s_id search user's reports

type StudyGroup

type StudyGroup struct {
	SID        uuid.UUID `gorm:"type: char(36); primaryKey; not null; unique;"`
	Turn       uint16
	GuildID    string
	Attendance uint16
	NextTurn   bool
	StartTime  Time `gorm:"not null;"`
}

func GetStudyGroup

func GetStudyGroup(SID uuid.UUID) *StudyGroup

func GetStudyGroupWithGID

func GetStudyGroupWithGID(GuildID string) (*StudyGroup, error)

type Time

type Time time.Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json marshal interface.

func (*Time) Scan

func (t *Time) Scan(v interface{}) error

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json unmarshal interface.

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value ...

Jump to

Keyboard shortcuts

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