models

package
v1.24.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeSourceModelName

func DecodeSourceModelName(req *restful.Request) (string, string)

func GetUsername

func GetUsername(req *restful.Request) string

func ParseCommonListOptions

func ParseCommonListOptions(r *restful.Request) repository.CommonListOptions

nolint: gomnd

Types

type CommentResponse

type CommentResponse struct {
	repository.Comment
	Replies []repository.Comment `json:"replies"`
}

type ModelResponse

type ModelResponse struct {
	repository.Model
	Rating   repository.Rating `json:"rating"`
	Versions []string          `json:"versions"` // not used
}

type ModelsAPI

type ModelsAPI struct {
	ModelRepository   *repository.ModelsRepository
	CommentRepository *repository.CommentsRepository
	SourcesRepository *repository.SourcesRepository
	SyncService       *SyncService
	// contains filtered or unexported fields
}

func NewModelsAPI

func NewModelsAPI(ctx context.Context, db *mongo.Database, syncopt *SyncOptions) (*ModelsAPI, error)

func (*ModelsAPI) AddSourceAdmin

func (o *ModelsAPI) AddSourceAdmin(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminCheckSource

func (m ModelsAPI) AdminCheckSource(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminCreateSource

func (m ModelsAPI) AdminCreateSource(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) AdminDeleteModel

func (m *ModelsAPI) AdminDeleteModel(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminDeleteSource

func (m ModelsAPI) AdminDeleteSource(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminGetSource

func (m ModelsAPI) AdminGetSource(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminListModel

func (m ModelsAPI) AdminListModel(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) AdminListSelector

func (m *ModelsAPI) AdminListSelector(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminListSources

func (m ModelsAPI) AdminListSources(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminUpdateModel

func (m ModelsAPI) AdminUpdateModel(req *restful.Request, resp *restful.Response)

func (ModelsAPI) AdminUpdateSource

func (m ModelsAPI) AdminUpdateSource(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) CreateComment

func (m *ModelsAPI) CreateComment(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) DeleteComment

func (m *ModelsAPI) DeleteComment(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) DeleteModel

func (m *ModelsAPI) DeleteModel(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) DeleteSourceAdmin

func (o *ModelsAPI) DeleteSourceAdmin(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) GetModel

func (m *ModelsAPI) GetModel(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) GetRating

func (m *ModelsAPI) GetRating(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) GetSource

func (m *ModelsAPI) GetSource(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) GetVersion

func (m *ModelsAPI) GetVersion(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) InitSchemas

func (m *ModelsAPI) InitSchemas(ctx context.Context) error

func (*ModelsAPI) ListComments

func (m *ModelsAPI) ListComments(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) ListModels

func (m *ModelsAPI) ListModels(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) ListSelectors

func (m *ModelsAPI) ListSelectors(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) ListSourceAdmin

func (o *ModelsAPI) ListSourceAdmin(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) ListSources

func (m *ModelsAPI) ListSources(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) ListVersions

func (m *ModelsAPI) ListVersions(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) RegisterRoute

func (m *ModelsAPI) RegisterRoute(rg *route.Group)

func (*ModelsAPI) StartSync

func (m *ModelsAPI) StartSync(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) StopSync

func (m *ModelsAPI) StopSync(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) SyncModel

func (m *ModelsAPI) SyncModel(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) SyncStatus

func (m *ModelsAPI) SyncStatus(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) UpdateComment

func (m *ModelsAPI) UpdateComment(req *restful.Request, resp *restful.Response)

func (*ModelsAPI) UpsertModel added in v1.23.12

func (m *ModelsAPI) UpsertModel(req *restful.Request, resp *restful.Response)

type ModelxSync added in v1.23.8

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

func (*ModelxSync) Stop added in v1.23.8

func (*ModelxSync) Sync added in v1.23.8

func (*ModelxSync) SyncOne added in v1.23.8

func (m *ModelxSync) SyncOne(ctx context.Context, source *repository.SourceWithAddtional, repo string) (any, error)

func (*ModelxSync) SyncStatus added in v1.23.8

func (m *ModelxSync) SyncStatus(ctx context.Context, source *repository.SourceWithAddtional) (*SyncStatus, error)

type SimpleModel

type SimpleModel struct {
	// nolint: tagliatelle
	ID        string   `json:"id,omitempty" bson:"_id,omitempty"`
	Name      string   `json:"name"`
	Tags      []string `json:"tags"`
	Intro     string   `json:"intro"`
	Recomment int      `json:"recomment"` // number of recomment votes
	Disabled  bool     `json:"disabled"`
}

type SourceWithSyncStatus

type SourceWithSyncStatus struct {
	repository.SourceWithAddtional `json:",inline"`
	SyncStatus                     SyncStatus `json:"syncStatus"`
}

type SyncOptions

type SyncOptions struct {
	Addr string `json:"addr" description:"address of the sync service"`
}

func NewDefaultSyncOptions

func NewDefaultSyncOptions() *SyncOptions

type SyncService

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

func NewSyncService

func NewSyncService(syncopt *SyncOptions, sources *repository.SourcesRepository, models *repository.ModelsRepository) *SyncService

func (*SyncService) Stop

func (*SyncService) Sync

func (*SyncService) SyncOne

func (s *SyncService) SyncOne(ctx context.Context, source *repository.SourceWithAddtional, repo string) (any, error)

func (*SyncService) SyncStatus

func (s *SyncService) SyncStatus(ctx context.Context, source *repository.SourceWithAddtional) (*SyncStatus, error)

type SyncServiceSyncStatus

type SyncServiceSyncStatus struct {
	Started  int64 // unix timestamp
	End      int64 // unix timestamp
	State    string
	Progress string
}

type SyncStatus

type SyncStatus struct {
	Status     SyncStatusPhase `json:"status"`
	Progress   string          `json:"progress"` // eg. 5/34
	StartedAt  *time.Time      `json:"startedAt"`
	FinishedAt *time.Time      `json:"finishedAt"`
	Message    string          `json:"message"`
}

func SyncStatusFrom

func SyncStatusFrom(status *SyncServiceSyncStatus) *SyncStatus

type SyncStatusPhase added in v1.23.8

type SyncStatusPhase string
const (
	SyncStatusRunning SyncStatusPhase = "PROGRESS"
	SyncStatusStopped SyncStatusPhase = "STOP"
	SyncStatusSuccess SyncStatusPhase = "SUCCESS"
	SyncStatusFailed  SyncStatusPhase = "FAILURE"
)

Jump to

Keyboard shortcuts

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