mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-25 05:38:42 +08:00
feat: github webhook 任务创建失败日志
This commit is contained in:
1 parent
9557732d9f
commit
32df5254ec
33 files changed
+6073
-67
No files matched your search
@@ -30,6 +30,7 @@ type GithubWebhookHandler struct {
|
||||
logger *slog.Logger
|
||||
redis *redis.Client
|
||||
gitbotUsecase domain.GitBotUsecase
|
||||
pubhost domain.PublicHostUsecase
|
||||
gitTaskUsecase domain.GitTaskUsecase
|
||||
}
|
||||
|
||||
@@ -41,6 +42,7 @@ func NewGithubWebhookHandler(i *do.Injector) (*GithubWebhookHandler, error) {
|
||||
redis: do.MustInvoke[*redis.Client](i),
|
||||
gitbotUsecase: do.MustInvoke[domain.GitBotUsecase](i),
|
||||
gitTaskUsecase: do.MustInvoke[domain.GitTaskUsecase](i),
|
||||
pubhost: do.MustInvoke[domain.PublicHostUsecase](i),
|
||||
}
|
||||
|
||||
w := do.MustInvoke[*web.Web](i)
|
||||
@@ -76,6 +78,7 @@ func (h *GithubWebhookHandler) Webhook(c *web.Context) error {
|
||||
}
|
||||
|
||||
event := c.Request().Header.Get("X-Github-Event")
|
||||
h.logger.With("bot", bot.ID, "body", string(body), "event", event).DebugContext(c.Request().Context(), "github webhook")
|
||||
if event == "pull_request" {
|
||||
h.handlePullRequest(ctx, bot, body)
|
||||
}
|
||||
@@ -132,21 +135,34 @@ func (h *GithubWebhookHandler) handlePullRequest(ctx context.Context, bot *domai
|
||||
return
|
||||
}
|
||||
|
||||
host, err := h.pubhost.PickHost(ctx)
|
||||
if err != nil {
|
||||
h.logger.With("error", err).ErrorContext(ctx, "failed to pick host")
|
||||
return
|
||||
}
|
||||
|
||||
branch := pr.Head.Ref
|
||||
repo := pr.Head.Repo
|
||||
h.gitTaskUsecase.Create(ctx, domain.CreateGitTaskReq{
|
||||
HostID: bot.Host.ID,
|
||||
if _, err := h.gitTaskUsecase.Create(ctx, domain.CreateGitTaskReq{
|
||||
HostID: host.ID,
|
||||
ImageID: uuid.MustParse(h.cfg.Task.ImageID),
|
||||
Prompt: pr.HTMLURL,
|
||||
Git: taskflow.Git{Token: bot.Token},
|
||||
Subject: domain.Subject{
|
||||
ID: fmt.Sprintf("%d", pr.ID), Type: "PullRequest",
|
||||
Title: pr.Title, URL: pr.HTMLURL, Number: pr.Number,
|
||||
ID: fmt.Sprintf("%d", pr.ID),
|
||||
Type: "PullRequest",
|
||||
Title: pr.Title,
|
||||
URL: pr.HTMLURL,
|
||||
Number: pr.Number,
|
||||
},
|
||||
Repo: domain.Repo{
|
||||
ID: fmt.Sprintf("%d", repo.ID), Name: repo.Name,
|
||||
FullName: repo.FullName, URL: repo.HTMLURL,
|
||||
Desc: repo.Description, IsPrivate: repo.Private, Branch: &branch,
|
||||
ID: fmt.Sprintf("%d", repo.ID),
|
||||
Name: repo.Name,
|
||||
FullName: repo.FullName,
|
||||
URL: repo.HTMLURL,
|
||||
Desc: repo.Description,
|
||||
IsPrivate: repo.Private,
|
||||
Branch: &branch,
|
||||
},
|
||||
Platform: consts.GitPlatformGithub,
|
||||
User: domain.User{Name: pr.User.Login, AvatarURL: pr.User.AvatarURL, Email: pr.User.Email},
|
||||
@@ -154,7 +170,9 @@ func (h *GithubWebhookHandler) handlePullRequest(ctx context.Context, bot *domai
|
||||
Time: time.Now(),
|
||||
Env: map[string]string{"GITHUB_TOKEN": bot.Token},
|
||||
Bot: bot,
|
||||
})
|
||||
}); err != nil {
|
||||
h.logger.With("error", err).ErrorContext(ctx, "failed to create git task")
|
||||
}
|
||||
}
|
||||
|
||||
// --- 公共工具函数 ---
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/chaitin/MonkeyCode/backend/consts"
|
||||
"github.com/chaitin/MonkeyCode/backend/db"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/host"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/image"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/model"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/user"
|
||||
"github.com/chaitin/MonkeyCode/backend/domain"
|
||||
@@ -60,7 +59,7 @@ func (g *GitTaskRepo) upsertUser(ctx context.Context, tx *db.Tx, u *domain.User)
|
||||
}
|
||||
|
||||
// Create implements domain.GitTaskRepoInterface.
|
||||
func (g *GitTaskRepo) Create(ctx context.Context, req domain.CreateGitTaskReq, fn func(user *db.User, t *db.Task, m *db.Model, i *db.Image) (*taskflow.VirtualMachine, error)) (*db.Task, error) {
|
||||
func (g *GitTaskRepo) Create(ctx context.Context, req domain.CreateGitTaskReq, fn func(user *db.User, t *db.Task, m *db.Model) (*taskflow.VirtualMachine, error)) (*db.Task, error) {
|
||||
var res *db.Task
|
||||
err := entx.WithTx2(ctx, g.db, func(tx *db.Tx) error {
|
||||
h, err := tx.Host.Query().Where(host.ID(req.HostID)).First(ctx)
|
||||
@@ -68,19 +67,17 @@ func (g *GitTaskRepo) Create(ctx context.Context, req domain.CreateGitTaskReq, f
|
||||
return fmt.Errorf("host not found: %w", err)
|
||||
}
|
||||
|
||||
// 查找 review 模型
|
||||
ms, err := tx.Model.Query().
|
||||
Where(model.Remark("review")).
|
||||
Where(model.HasUserWith(user.Role(consts.UserRoleAdmin))).
|
||||
All(ctx)
|
||||
if err != nil || len(ms) == 0 {
|
||||
return fmt.Errorf("review model not found")
|
||||
}
|
||||
m := ms[0]
|
||||
|
||||
img, err := tx.Image.Query().Where(image.ID(req.ImageID)).First(ctx)
|
||||
mid, err := uuid.Parse(g.cfg.ReviewAgent.ModelID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("image not found: %w", err)
|
||||
return fmt.Errorf("failed to parse model id: %w", err)
|
||||
}
|
||||
|
||||
// 查找 review 模型
|
||||
m, err := tx.Model.Query().
|
||||
Where(model.ID(mid)).
|
||||
First(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("review model not found")
|
||||
}
|
||||
|
||||
u, err := g.upsertUser(ctx, tx, &req.User)
|
||||
@@ -101,26 +98,26 @@ func (g *GitTaskRepo) Create(ctx context.Context, req domain.CreateGitTaskReq, f
|
||||
SetContent(req.Prompt).
|
||||
SetUserID(u.ID).
|
||||
SetStatus(consts.TaskStatusPending).
|
||||
SetLogStore(consts.LogStoreClickHouse).
|
||||
Save(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 创建 ProjectTask 关联
|
||||
pt, err := tx.ProjectTask.Create().
|
||||
SetImageID(img.ID).
|
||||
SetModelID(m.ID).
|
||||
// 创建 GitTask 关联
|
||||
if err := tx.GitTask.Create().
|
||||
SetTaskID(tk.ID).
|
||||
SetRepoURL(req.Repo.URL).
|
||||
SetBranch(branch).
|
||||
SetCliName(consts.CliNameClaude).
|
||||
Save(ctx)
|
||||
if err != nil {
|
||||
SetGithubInstallationID(req.GithubInstallationID).
|
||||
SetSubjectID(req.Subject.ID).
|
||||
SetSubjectNumber(req.Subject.Number).
|
||||
SetSubjectTitle(req.Subject.Title).
|
||||
SetSubjectType(req.Subject.Type).
|
||||
SetSubjectURL(req.Subject.URL).
|
||||
Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
_ = pt
|
||||
|
||||
vm, err := fn(u, tk, m, img)
|
||||
vm, err := fn(u, tk, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (g *GitTaskUsecase) Create(ctx context.Context, req domain.CreateGitTaskReq
|
||||
req.Env = make(map[string]string)
|
||||
}
|
||||
|
||||
tk, err := g.repo.Create(ctx, req, func(u *db.User, t *db.Task, m *db.Model, img *db.Image) (*taskflow.VirtualMachine, error) {
|
||||
tk, err := g.repo.Create(ctx, req, func(u *db.User, t *db.Task, m *db.Model) (*taskflow.VirtualMachine, error) {
|
||||
branch := "master"
|
||||
if req.Repo.Branch != nil {
|
||||
branch = *req.Repo.Branch
|
||||
@@ -72,7 +72,7 @@ func (g *GitTaskUsecase) Create(ctx context.Context, req domain.CreateGitTaskReq
|
||||
Branch: branch,
|
||||
Token: req.Git.Token,
|
||||
},
|
||||
ImageURL: img.Name,
|
||||
ImageURL: g.cfg.ReviewAgent.Image,
|
||||
TaskID: t.ID,
|
||||
LLM: taskflow.LLMProviderReq{
|
||||
Provider: taskflow.LlmProviderOpenAI,
|
||||
|
||||
@@ -74,6 +74,13 @@ type Config struct {
|
||||
|
||||
// 语音识别配置(阿里云 NLS)
|
||||
NLS NLS `mapstructure:"nls"`
|
||||
|
||||
ReviewAgent ReviewAgent `mapstructure:"review_agent"`
|
||||
}
|
||||
|
||||
type ReviewAgent struct {
|
||||
ModelID string `mapstructure:"model_id"`
|
||||
Image string `mapstructure:"image"`
|
||||
}
|
||||
|
||||
// NLS 阿里云语音识别配置
|
||||
|
||||
+195
-20
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/host"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/image"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/mcptool"
|
||||
@@ -74,6 +75,8 @@ type Client struct {
|
||||
GitBotUser *GitBotUserClient
|
||||
// GitIdentity is the client for interacting with the GitIdentity builders.
|
||||
GitIdentity *GitIdentityClient
|
||||
// GitTask is the client for interacting with the GitTask builders.
|
||||
GitTask *GitTaskClient
|
||||
// Host is the client for interacting with the Host builders.
|
||||
Host *HostClient
|
||||
// Image is the client for interacting with the Image builders.
|
||||
@@ -158,6 +161,7 @@ func (c *Client) init() {
|
||||
c.GitBotTask = NewGitBotTaskClient(c.config)
|
||||
c.GitBotUser = NewGitBotUserClient(c.config)
|
||||
c.GitIdentity = NewGitIdentityClient(c.config)
|
||||
c.GitTask = NewGitTaskClient(c.config)
|
||||
c.Host = NewHostClient(c.config)
|
||||
c.Image = NewImageClient(c.config)
|
||||
c.MCPTool = NewMCPToolClient(c.config)
|
||||
@@ -289,6 +293,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
GitBotTask: NewGitBotTaskClient(cfg),
|
||||
GitBotUser: NewGitBotUserClient(cfg),
|
||||
GitIdentity: NewGitIdentityClient(cfg),
|
||||
GitTask: NewGitTaskClient(cfg),
|
||||
Host: NewHostClient(cfg),
|
||||
Image: NewImageClient(cfg),
|
||||
MCPTool: NewMCPToolClient(cfg),
|
||||
@@ -347,6 +352,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
GitBotTask: NewGitBotTaskClient(cfg),
|
||||
GitBotUser: NewGitBotUserClient(cfg),
|
||||
GitIdentity: NewGitIdentityClient(cfg),
|
||||
GitTask: NewGitTaskClient(cfg),
|
||||
Host: NewHostClient(cfg),
|
||||
Image: NewImageClient(cfg),
|
||||
MCPTool: NewMCPToolClient(cfg),
|
||||
@@ -410,14 +416,15 @@ func (c *Client) Close() error {
|
||||
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
for _, n := range []interface{ Use(...Hook) }{
|
||||
c.Audit, c.GitBot, c.GitBotTask, c.GitBotUser, c.GitIdentity, c.Host, c.Image,
|
||||
c.MCPTool, c.MCPUpstream, c.MCPUserToolSetting, c.Model, c.ModelApiKey,
|
||||
c.ModelPricing, c.NotifyChannel, c.NotifySendLog, c.NotifySubscription,
|
||||
c.Project, c.ProjectCollaborator, c.ProjectGitBot, c.ProjectIssue,
|
||||
c.ProjectIssueComment, c.ProjectTask, c.Task, c.TaskModelSwitch,
|
||||
c.TaskUsageStat, c.TaskVirtualMachine, c.Team, c.TeamGroup, c.TeamGroupHost,
|
||||
c.TeamGroupImage, c.TeamGroupMember, c.TeamGroupModel, c.TeamHost, c.TeamImage,
|
||||
c.TeamMember, c.TeamModel, c.User, c.UserIdentity, c.VirtualMachine,
|
||||
c.Audit, c.GitBot, c.GitBotTask, c.GitBotUser, c.GitIdentity, c.GitTask, c.Host,
|
||||
c.Image, c.MCPTool, c.MCPUpstream, c.MCPUserToolSetting, c.Model,
|
||||
c.ModelApiKey, c.ModelPricing, c.NotifyChannel, c.NotifySendLog,
|
||||
c.NotifySubscription, c.Project, c.ProjectCollaborator, c.ProjectGitBot,
|
||||
c.ProjectIssue, c.ProjectIssueComment, c.ProjectTask, c.Task,
|
||||
c.TaskModelSwitch, c.TaskUsageStat, c.TaskVirtualMachine, c.Team, c.TeamGroup,
|
||||
c.TeamGroupHost, c.TeamGroupImage, c.TeamGroupMember, c.TeamGroupModel,
|
||||
c.TeamHost, c.TeamImage, c.TeamMember, c.TeamModel, c.User, c.UserIdentity,
|
||||
c.VirtualMachine,
|
||||
} {
|
||||
n.Use(hooks...)
|
||||
}
|
||||
@@ -427,14 +434,15 @@ func (c *Client) Use(hooks ...Hook) {
|
||||
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||
c.Audit, c.GitBot, c.GitBotTask, c.GitBotUser, c.GitIdentity, c.Host, c.Image,
|
||||
c.MCPTool, c.MCPUpstream, c.MCPUserToolSetting, c.Model, c.ModelApiKey,
|
||||
c.ModelPricing, c.NotifyChannel, c.NotifySendLog, c.NotifySubscription,
|
||||
c.Project, c.ProjectCollaborator, c.ProjectGitBot, c.ProjectIssue,
|
||||
c.ProjectIssueComment, c.ProjectTask, c.Task, c.TaskModelSwitch,
|
||||
c.TaskUsageStat, c.TaskVirtualMachine, c.Team, c.TeamGroup, c.TeamGroupHost,
|
||||
c.TeamGroupImage, c.TeamGroupMember, c.TeamGroupModel, c.TeamHost, c.TeamImage,
|
||||
c.TeamMember, c.TeamModel, c.User, c.UserIdentity, c.VirtualMachine,
|
||||
c.Audit, c.GitBot, c.GitBotTask, c.GitBotUser, c.GitIdentity, c.GitTask, c.Host,
|
||||
c.Image, c.MCPTool, c.MCPUpstream, c.MCPUserToolSetting, c.Model,
|
||||
c.ModelApiKey, c.ModelPricing, c.NotifyChannel, c.NotifySendLog,
|
||||
c.NotifySubscription, c.Project, c.ProjectCollaborator, c.ProjectGitBot,
|
||||
c.ProjectIssue, c.ProjectIssueComment, c.ProjectTask, c.Task,
|
||||
c.TaskModelSwitch, c.TaskUsageStat, c.TaskVirtualMachine, c.Team, c.TeamGroup,
|
||||
c.TeamGroupHost, c.TeamGroupImage, c.TeamGroupMember, c.TeamGroupModel,
|
||||
c.TeamHost, c.TeamImage, c.TeamMember, c.TeamModel, c.User, c.UserIdentity,
|
||||
c.VirtualMachine,
|
||||
} {
|
||||
n.Intercept(interceptors...)
|
||||
}
|
||||
@@ -453,6 +461,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.GitBotUser.mutate(ctx, m)
|
||||
case *GitIdentityMutation:
|
||||
return c.GitIdentity.mutate(ctx, m)
|
||||
case *GitTaskMutation:
|
||||
return c.GitTask.mutate(ctx, m)
|
||||
case *HostMutation:
|
||||
return c.Host.mutate(ctx, m)
|
||||
case *ImageMutation:
|
||||
@@ -1435,6 +1445,155 @@ func (c *GitIdentityClient) mutate(ctx context.Context, m *GitIdentityMutation)
|
||||
}
|
||||
}
|
||||
|
||||
// GitTaskClient is a client for the GitTask schema.
|
||||
type GitTaskClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewGitTaskClient returns a client for the GitTask from the given config.
|
||||
func NewGitTaskClient(c config) *GitTaskClient {
|
||||
return &GitTaskClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `gittask.Hooks(f(g(h())))`.
|
||||
func (c *GitTaskClient) Use(hooks ...Hook) {
|
||||
c.hooks.GitTask = append(c.hooks.GitTask, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `gittask.Intercept(f(g(h())))`.
|
||||
func (c *GitTaskClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.GitTask = append(c.inters.GitTask, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a GitTask entity.
|
||||
func (c *GitTaskClient) Create() *GitTaskCreate {
|
||||
mutation := newGitTaskMutation(c.config, OpCreate)
|
||||
return &GitTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of GitTask entities.
|
||||
func (c *GitTaskClient) CreateBulk(builders ...*GitTaskCreate) *GitTaskCreateBulk {
|
||||
return &GitTaskCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *GitTaskClient) MapCreateBulk(slice any, setFunc func(*GitTaskCreate, int)) *GitTaskCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &GitTaskCreateBulk{err: fmt.Errorf("calling to GitTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*GitTaskCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &GitTaskCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for GitTask.
|
||||
func (c *GitTaskClient) Update() *GitTaskUpdate {
|
||||
mutation := newGitTaskMutation(c.config, OpUpdate)
|
||||
return &GitTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *GitTaskClient) UpdateOne(_m *GitTask) *GitTaskUpdateOne {
|
||||
mutation := newGitTaskMutation(c.config, OpUpdateOne, withGitTask(_m))
|
||||
return &GitTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *GitTaskClient) UpdateOneID(id uuid.UUID) *GitTaskUpdateOne {
|
||||
mutation := newGitTaskMutation(c.config, OpUpdateOne, withGitTaskID(id))
|
||||
return &GitTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for GitTask.
|
||||
func (c *GitTaskClient) Delete() *GitTaskDelete {
|
||||
mutation := newGitTaskMutation(c.config, OpDelete)
|
||||
return &GitTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *GitTaskClient) DeleteOne(_m *GitTask) *GitTaskDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *GitTaskClient) DeleteOneID(id uuid.UUID) *GitTaskDeleteOne {
|
||||
builder := c.Delete().Where(gittask.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &GitTaskDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for GitTask.
|
||||
func (c *GitTaskClient) Query() *GitTaskQuery {
|
||||
return &GitTaskQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeGitTask},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a GitTask entity by its id.
|
||||
func (c *GitTaskClient) Get(ctx context.Context, id uuid.UUID) (*GitTask, error) {
|
||||
return c.Query().Where(gittask.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *GitTaskClient) GetX(ctx context.Context, id uuid.UUID) *GitTask {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryTask queries the task edge of a GitTask.
|
||||
func (c *GitTaskClient) QueryTask(_m *GitTask) *TaskQuery {
|
||||
query := (&TaskClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(gittask.Table, gittask.FieldID, id),
|
||||
sqlgraph.To(task.Table, task.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, gittask.TaskTable, gittask.TaskColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *GitTaskClient) Hooks() []Hook {
|
||||
return c.hooks.GitTask
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *GitTaskClient) Interceptors() []Interceptor {
|
||||
return c.inters.GitTask
|
||||
}
|
||||
|
||||
func (c *GitTaskClient) mutate(ctx context.Context, m *GitTaskMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&GitTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&GitTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&GitTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&GitTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("db: unknown GitTask mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// HostClient is a client for the Host schema.
|
||||
type HostClient struct {
|
||||
config
|
||||
@@ -4756,6 +4915,22 @@ func (c *TaskClient) QueryProjectTasks(_m *Task) *ProjectTaskQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryGitTasks queries the git_tasks edge of a Task.
|
||||
func (c *TaskClient) QueryGitTasks(_m *Task) *GitTaskQuery {
|
||||
query := (&GitTaskClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(task.Table, task.FieldID, id),
|
||||
sqlgraph.To(gittask.Table, gittask.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, task.GitTasksTable, task.GitTasksColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUser queries the user edge of a Task.
|
||||
func (c *TaskClient) QueryUser(_m *Task) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
@@ -8060,8 +8235,8 @@ func (c *VirtualMachineClient) mutate(ctx context.Context, m *VirtualMachineMuta
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, Host, Image, MCPTool,
|
||||
MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, ModelPricing,
|
||||
Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, GitTask, Host, Image,
|
||||
MCPTool, MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, ModelPricing,
|
||||
NotifyChannel, NotifySendLog, NotifySubscription, Project, ProjectCollaborator,
|
||||
ProjectGitBot, ProjectIssue, ProjectIssueComment, ProjectTask, Task,
|
||||
TaskModelSwitch, TaskUsageStat, TaskVirtualMachine, Team, TeamGroup,
|
||||
@@ -8069,8 +8244,8 @@ type (
|
||||
TeamImage, TeamMember, TeamModel, User, UserIdentity, VirtualMachine []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, Host, Image, MCPTool,
|
||||
MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, ModelPricing,
|
||||
Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, GitTask, Host, Image,
|
||||
MCPTool, MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, ModelPricing,
|
||||
NotifyChannel, NotifySendLog, NotifySubscription, Project, ProjectCollaborator,
|
||||
ProjectGitBot, ProjectIssue, ProjectIssueComment, ProjectTask, Task,
|
||||
TaskModelSwitch, TaskUsageStat, TaskVirtualMachine, Team, TeamGroup,
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/host"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/image"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/mcptool"
|
||||
@@ -116,6 +117,7 @@ func checkColumn(t, c string) error {
|
||||
gitbottask.Table: gitbottask.ValidColumn,
|
||||
gitbotuser.Table: gitbotuser.ValidColumn,
|
||||
gitidentity.Table: gitidentity.ValidColumn,
|
||||
gittask.Table: gittask.ValidColumn,
|
||||
host.Table: host.ValidColumn,
|
||||
image.Table: image.ValidColumn,
|
||||
mcptool.Table: mcptool.ValidColumn,
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/task"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// GitTask is the model entity for the GitTask schema.
|
||||
type GitTask struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// TaskID holds the value of the "task_id" field.
|
||||
TaskID uuid.UUID `json:"task_id,omitempty"`
|
||||
// RepoID holds the value of the "repo_id" field.
|
||||
RepoID uuid.UUID `json:"repo_id,omitempty"`
|
||||
// SubjectType holds the value of the "subject_type" field.
|
||||
SubjectType string `json:"subject_type,omitempty"`
|
||||
// SubjectID holds the value of the "subject_id" field.
|
||||
SubjectID string `json:"subject_id,omitempty"`
|
||||
// SubjectNumber holds the value of the "subject_number" field.
|
||||
SubjectNumber int `json:"subject_number,omitempty"`
|
||||
// SubjectURL holds the value of the "subject_url" field.
|
||||
SubjectURL string `json:"subject_url,omitempty"`
|
||||
// SubjectTitle holds the value of the "subject_title" field.
|
||||
SubjectTitle string `json:"subject_title,omitempty"`
|
||||
// PromptID holds the value of the "prompt_id" field.
|
||||
PromptID string `json:"prompt_id,omitempty"`
|
||||
// ShowURL holds the value of the "show_url" field.
|
||||
ShowURL string `json:"show_url,omitempty"`
|
||||
// GithubInstallationID holds the value of the "github_installation_id" field.
|
||||
GithubInstallationID int64 `json:"github_installation_id,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the GitTaskQuery when eager-loading is set.
|
||||
Edges GitTaskEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// GitTaskEdges holds the relations/edges for other nodes in the graph.
|
||||
type GitTaskEdges struct {
|
||||
// Task holds the value of the task edge.
|
||||
Task *Task `json:"task,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// TaskOrErr returns the Task value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e GitTaskEdges) TaskOrErr() (*Task, error) {
|
||||
if e.Task != nil {
|
||||
return e.Task, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: task.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "task"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*GitTask) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case gittask.FieldSubjectNumber, gittask.FieldGithubInstallationID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case gittask.FieldSubjectType, gittask.FieldSubjectID, gittask.FieldSubjectURL, gittask.FieldSubjectTitle, gittask.FieldPromptID, gittask.FieldShowURL:
|
||||
values[i] = new(sql.NullString)
|
||||
case gittask.FieldCreatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case gittask.FieldID, gittask.FieldTaskID, gittask.FieldRepoID:
|
||||
values[i] = new(uuid.UUID)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the GitTask fields.
|
||||
func (_m *GitTask) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case gittask.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case gittask.FieldTaskID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field task_id", values[i])
|
||||
} else if value != nil {
|
||||
_m.TaskID = *value
|
||||
}
|
||||
case gittask.FieldRepoID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field repo_id", values[i])
|
||||
} else if value != nil {
|
||||
_m.RepoID = *value
|
||||
}
|
||||
case gittask.FieldSubjectType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field subject_type", values[i])
|
||||
} else if value.Valid {
|
||||
_m.SubjectType = value.String
|
||||
}
|
||||
case gittask.FieldSubjectID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field subject_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.SubjectID = value.String
|
||||
}
|
||||
case gittask.FieldSubjectNumber:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field subject_number", values[i])
|
||||
} else if value.Valid {
|
||||
_m.SubjectNumber = int(value.Int64)
|
||||
}
|
||||
case gittask.FieldSubjectURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field subject_url", values[i])
|
||||
} else if value.Valid {
|
||||
_m.SubjectURL = value.String
|
||||
}
|
||||
case gittask.FieldSubjectTitle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field subject_title", values[i])
|
||||
} else if value.Valid {
|
||||
_m.SubjectTitle = value.String
|
||||
}
|
||||
case gittask.FieldPromptID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field prompt_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.PromptID = value.String
|
||||
}
|
||||
case gittask.FieldShowURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field show_url", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ShowURL = value.String
|
||||
}
|
||||
case gittask.FieldGithubInstallationID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field github_installation_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.GithubInstallationID = value.Int64
|
||||
}
|
||||
case gittask.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the GitTask.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *GitTask) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryTask queries the "task" edge of the GitTask entity.
|
||||
func (_m *GitTask) QueryTask() *TaskQuery {
|
||||
return NewGitTaskClient(_m.config).QueryTask(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this GitTask.
|
||||
// Note that you need to call GitTask.Unwrap() before calling this method if this GitTask
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *GitTask) Update() *GitTaskUpdateOne {
|
||||
return NewGitTaskClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the GitTask entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *GitTask) Unwrap() *GitTask {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("db: GitTask is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *GitTask) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("GitTask(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("task_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.TaskID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("repo_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.RepoID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("subject_type=")
|
||||
builder.WriteString(_m.SubjectType)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("subject_id=")
|
||||
builder.WriteString(_m.SubjectID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("subject_number=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.SubjectNumber))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("subject_url=")
|
||||
builder.WriteString(_m.SubjectURL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("subject_title=")
|
||||
builder.WriteString(_m.SubjectTitle)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("prompt_id=")
|
||||
builder.WriteString(_m.PromptID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("show_url=")
|
||||
builder.WriteString(_m.ShowURL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("github_installation_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.GithubInstallationID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// GitTasks is a parsable slice of GitTask.
|
||||
type GitTasks []*GitTask
|
||||
@@ -0,0 +1,160 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package gittask
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the gittask type in the database.
|
||||
Label = "git_task"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldTaskID holds the string denoting the task_id field in the database.
|
||||
FieldTaskID = "task_id"
|
||||
// FieldRepoID holds the string denoting the repo_id field in the database.
|
||||
FieldRepoID = "repo_id"
|
||||
// FieldSubjectType holds the string denoting the subject_type field in the database.
|
||||
FieldSubjectType = "subject_type"
|
||||
// FieldSubjectID holds the string denoting the subject_id field in the database.
|
||||
FieldSubjectID = "subject_id"
|
||||
// FieldSubjectNumber holds the string denoting the subject_number field in the database.
|
||||
FieldSubjectNumber = "subject_number"
|
||||
// FieldSubjectURL holds the string denoting the subject_url field in the database.
|
||||
FieldSubjectURL = "subject_url"
|
||||
// FieldSubjectTitle holds the string denoting the subject_title field in the database.
|
||||
FieldSubjectTitle = "subject_title"
|
||||
// FieldPromptID holds the string denoting the prompt_id field in the database.
|
||||
FieldPromptID = "prompt_id"
|
||||
// FieldShowURL holds the string denoting the show_url field in the database.
|
||||
FieldShowURL = "show_url"
|
||||
// FieldGithubInstallationID holds the string denoting the github_installation_id field in the database.
|
||||
FieldGithubInstallationID = "github_installation_id"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// EdgeTask holds the string denoting the task edge name in mutations.
|
||||
EdgeTask = "task"
|
||||
// Table holds the table name of the gittask in the database.
|
||||
Table = "git_tasks"
|
||||
// TaskTable is the table that holds the task relation/edge.
|
||||
TaskTable = "git_tasks"
|
||||
// TaskInverseTable is the table name for the Task entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "task" package.
|
||||
TaskInverseTable = "tasks"
|
||||
// TaskColumn is the table column denoting the task relation/edge.
|
||||
TaskColumn = "task_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for gittask fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldTaskID,
|
||||
FieldRepoID,
|
||||
FieldSubjectType,
|
||||
FieldSubjectID,
|
||||
FieldSubjectNumber,
|
||||
FieldSubjectURL,
|
||||
FieldSubjectTitle,
|
||||
FieldPromptID,
|
||||
FieldShowURL,
|
||||
FieldGithubInstallationID,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// SubjectTypeValidator is a validator for the "subject_type" field. It is called by the builders before save.
|
||||
SubjectTypeValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the GitTask queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTaskID orders the results by the task_id field.
|
||||
func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTaskID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRepoID orders the results by the repo_id field.
|
||||
func ByRepoID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRepoID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySubjectType orders the results by the subject_type field.
|
||||
func BySubjectType(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSubjectType, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySubjectID orders the results by the subject_id field.
|
||||
func BySubjectID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSubjectID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySubjectNumber orders the results by the subject_number field.
|
||||
func BySubjectNumber(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSubjectNumber, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySubjectURL orders the results by the subject_url field.
|
||||
func BySubjectURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSubjectURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySubjectTitle orders the results by the subject_title field.
|
||||
func BySubjectTitle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSubjectTitle, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPromptID orders the results by the prompt_id field.
|
||||
func ByPromptID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPromptID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByShowURL orders the results by the show_url field.
|
||||
func ByShowURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldShowURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGithubInstallationID orders the results by the github_installation_id field.
|
||||
func ByGithubInstallationID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldGithubInstallationID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTaskField orders the results by task field.
|
||||
func ByTaskField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newTaskStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newTaskStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(TaskInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, TaskTable, TaskColumn),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,800 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package gittask
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// TaskID applies equality check predicate on the "task_id" field. It's identical to TaskIDEQ.
|
||||
func TaskID(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldTaskID, v))
|
||||
}
|
||||
|
||||
// RepoID applies equality check predicate on the "repo_id" field. It's identical to RepoIDEQ.
|
||||
func RepoID(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldRepoID, v))
|
||||
}
|
||||
|
||||
// SubjectType applies equality check predicate on the "subject_type" field. It's identical to SubjectTypeEQ.
|
||||
func SubjectType(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectID applies equality check predicate on the "subject_id" field. It's identical to SubjectIDEQ.
|
||||
func SubjectID(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectNumber applies equality check predicate on the "subject_number" field. It's identical to SubjectNumberEQ.
|
||||
func SubjectNumber(v int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectNumber, v))
|
||||
}
|
||||
|
||||
// SubjectURL applies equality check predicate on the "subject_url" field. It's identical to SubjectURLEQ.
|
||||
func SubjectURL(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectTitle applies equality check predicate on the "subject_title" field. It's identical to SubjectTitleEQ.
|
||||
func SubjectTitle(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// PromptID applies equality check predicate on the "prompt_id" field. It's identical to PromptIDEQ.
|
||||
func PromptID(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// ShowURL applies equality check predicate on the "show_url" field. It's identical to ShowURLEQ.
|
||||
func ShowURL(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// GithubInstallationID applies equality check predicate on the "github_installation_id" field. It's identical to GithubInstallationIDEQ.
|
||||
func GithubInstallationID(v int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldGithubInstallationID, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// TaskIDEQ applies the EQ predicate on the "task_id" field.
|
||||
func TaskIDEQ(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldTaskID, v))
|
||||
}
|
||||
|
||||
// TaskIDNEQ applies the NEQ predicate on the "task_id" field.
|
||||
func TaskIDNEQ(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldTaskID, v))
|
||||
}
|
||||
|
||||
// TaskIDIn applies the In predicate on the "task_id" field.
|
||||
func TaskIDIn(vs ...uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldTaskID, vs...))
|
||||
}
|
||||
|
||||
// TaskIDNotIn applies the NotIn predicate on the "task_id" field.
|
||||
func TaskIDNotIn(vs ...uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldTaskID, vs...))
|
||||
}
|
||||
|
||||
// RepoIDEQ applies the EQ predicate on the "repo_id" field.
|
||||
func RepoIDEQ(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldRepoID, v))
|
||||
}
|
||||
|
||||
// RepoIDNEQ applies the NEQ predicate on the "repo_id" field.
|
||||
func RepoIDNEQ(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldRepoID, v))
|
||||
}
|
||||
|
||||
// RepoIDIn applies the In predicate on the "repo_id" field.
|
||||
func RepoIDIn(vs ...uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldRepoID, vs...))
|
||||
}
|
||||
|
||||
// RepoIDNotIn applies the NotIn predicate on the "repo_id" field.
|
||||
func RepoIDNotIn(vs ...uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldRepoID, vs...))
|
||||
}
|
||||
|
||||
// RepoIDGT applies the GT predicate on the "repo_id" field.
|
||||
func RepoIDGT(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldRepoID, v))
|
||||
}
|
||||
|
||||
// RepoIDGTE applies the GTE predicate on the "repo_id" field.
|
||||
func RepoIDGTE(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldRepoID, v))
|
||||
}
|
||||
|
||||
// RepoIDLT applies the LT predicate on the "repo_id" field.
|
||||
func RepoIDLT(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldRepoID, v))
|
||||
}
|
||||
|
||||
// RepoIDLTE applies the LTE predicate on the "repo_id" field.
|
||||
func RepoIDLTE(v uuid.UUID) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldRepoID, v))
|
||||
}
|
||||
|
||||
// RepoIDIsNil applies the IsNil predicate on the "repo_id" field.
|
||||
func RepoIDIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldRepoID))
|
||||
}
|
||||
|
||||
// RepoIDNotNil applies the NotNil predicate on the "repo_id" field.
|
||||
func RepoIDNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldRepoID))
|
||||
}
|
||||
|
||||
// SubjectTypeEQ applies the EQ predicate on the "subject_type" field.
|
||||
func SubjectTypeEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeNEQ applies the NEQ predicate on the "subject_type" field.
|
||||
func SubjectTypeNEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeIn applies the In predicate on the "subject_type" field.
|
||||
func SubjectTypeIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldSubjectType, vs...))
|
||||
}
|
||||
|
||||
// SubjectTypeNotIn applies the NotIn predicate on the "subject_type" field.
|
||||
func SubjectTypeNotIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldSubjectType, vs...))
|
||||
}
|
||||
|
||||
// SubjectTypeGT applies the GT predicate on the "subject_type" field.
|
||||
func SubjectTypeGT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeGTE applies the GTE predicate on the "subject_type" field.
|
||||
func SubjectTypeGTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeLT applies the LT predicate on the "subject_type" field.
|
||||
func SubjectTypeLT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeLTE applies the LTE predicate on the "subject_type" field.
|
||||
func SubjectTypeLTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeContains applies the Contains predicate on the "subject_type" field.
|
||||
func SubjectTypeContains(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContains(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeHasPrefix applies the HasPrefix predicate on the "subject_type" field.
|
||||
func SubjectTypeHasPrefix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasPrefix(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeHasSuffix applies the HasSuffix predicate on the "subject_type" field.
|
||||
func SubjectTypeHasSuffix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasSuffix(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeEqualFold applies the EqualFold predicate on the "subject_type" field.
|
||||
func SubjectTypeEqualFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEqualFold(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectTypeContainsFold applies the ContainsFold predicate on the "subject_type" field.
|
||||
func SubjectTypeContainsFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContainsFold(FieldSubjectType, v))
|
||||
}
|
||||
|
||||
// SubjectIDEQ applies the EQ predicate on the "subject_id" field.
|
||||
func SubjectIDEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDNEQ applies the NEQ predicate on the "subject_id" field.
|
||||
func SubjectIDNEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDIn applies the In predicate on the "subject_id" field.
|
||||
func SubjectIDIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldSubjectID, vs...))
|
||||
}
|
||||
|
||||
// SubjectIDNotIn applies the NotIn predicate on the "subject_id" field.
|
||||
func SubjectIDNotIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldSubjectID, vs...))
|
||||
}
|
||||
|
||||
// SubjectIDGT applies the GT predicate on the "subject_id" field.
|
||||
func SubjectIDGT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDGTE applies the GTE predicate on the "subject_id" field.
|
||||
func SubjectIDGTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDLT applies the LT predicate on the "subject_id" field.
|
||||
func SubjectIDLT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDLTE applies the LTE predicate on the "subject_id" field.
|
||||
func SubjectIDLTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDContains applies the Contains predicate on the "subject_id" field.
|
||||
func SubjectIDContains(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContains(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDHasPrefix applies the HasPrefix predicate on the "subject_id" field.
|
||||
func SubjectIDHasPrefix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasPrefix(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDHasSuffix applies the HasSuffix predicate on the "subject_id" field.
|
||||
func SubjectIDHasSuffix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasSuffix(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDIsNil applies the IsNil predicate on the "subject_id" field.
|
||||
func SubjectIDIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldSubjectID))
|
||||
}
|
||||
|
||||
// SubjectIDNotNil applies the NotNil predicate on the "subject_id" field.
|
||||
func SubjectIDNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldSubjectID))
|
||||
}
|
||||
|
||||
// SubjectIDEqualFold applies the EqualFold predicate on the "subject_id" field.
|
||||
func SubjectIDEqualFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEqualFold(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectIDContainsFold applies the ContainsFold predicate on the "subject_id" field.
|
||||
func SubjectIDContainsFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContainsFold(FieldSubjectID, v))
|
||||
}
|
||||
|
||||
// SubjectNumberEQ applies the EQ predicate on the "subject_number" field.
|
||||
func SubjectNumberEQ(v int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectNumber, v))
|
||||
}
|
||||
|
||||
// SubjectNumberNEQ applies the NEQ predicate on the "subject_number" field.
|
||||
func SubjectNumberNEQ(v int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldSubjectNumber, v))
|
||||
}
|
||||
|
||||
// SubjectNumberIn applies the In predicate on the "subject_number" field.
|
||||
func SubjectNumberIn(vs ...int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldSubjectNumber, vs...))
|
||||
}
|
||||
|
||||
// SubjectNumberNotIn applies the NotIn predicate on the "subject_number" field.
|
||||
func SubjectNumberNotIn(vs ...int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldSubjectNumber, vs...))
|
||||
}
|
||||
|
||||
// SubjectNumberGT applies the GT predicate on the "subject_number" field.
|
||||
func SubjectNumberGT(v int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldSubjectNumber, v))
|
||||
}
|
||||
|
||||
// SubjectNumberGTE applies the GTE predicate on the "subject_number" field.
|
||||
func SubjectNumberGTE(v int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldSubjectNumber, v))
|
||||
}
|
||||
|
||||
// SubjectNumberLT applies the LT predicate on the "subject_number" field.
|
||||
func SubjectNumberLT(v int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldSubjectNumber, v))
|
||||
}
|
||||
|
||||
// SubjectNumberLTE applies the LTE predicate on the "subject_number" field.
|
||||
func SubjectNumberLTE(v int) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldSubjectNumber, v))
|
||||
}
|
||||
|
||||
// SubjectNumberIsNil applies the IsNil predicate on the "subject_number" field.
|
||||
func SubjectNumberIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldSubjectNumber))
|
||||
}
|
||||
|
||||
// SubjectNumberNotNil applies the NotNil predicate on the "subject_number" field.
|
||||
func SubjectNumberNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldSubjectNumber))
|
||||
}
|
||||
|
||||
// SubjectURLEQ applies the EQ predicate on the "subject_url" field.
|
||||
func SubjectURLEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLNEQ applies the NEQ predicate on the "subject_url" field.
|
||||
func SubjectURLNEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLIn applies the In predicate on the "subject_url" field.
|
||||
func SubjectURLIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldSubjectURL, vs...))
|
||||
}
|
||||
|
||||
// SubjectURLNotIn applies the NotIn predicate on the "subject_url" field.
|
||||
func SubjectURLNotIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldSubjectURL, vs...))
|
||||
}
|
||||
|
||||
// SubjectURLGT applies the GT predicate on the "subject_url" field.
|
||||
func SubjectURLGT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLGTE applies the GTE predicate on the "subject_url" field.
|
||||
func SubjectURLGTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLLT applies the LT predicate on the "subject_url" field.
|
||||
func SubjectURLLT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLLTE applies the LTE predicate on the "subject_url" field.
|
||||
func SubjectURLLTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLContains applies the Contains predicate on the "subject_url" field.
|
||||
func SubjectURLContains(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContains(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLHasPrefix applies the HasPrefix predicate on the "subject_url" field.
|
||||
func SubjectURLHasPrefix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasPrefix(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLHasSuffix applies the HasSuffix predicate on the "subject_url" field.
|
||||
func SubjectURLHasSuffix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasSuffix(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLIsNil applies the IsNil predicate on the "subject_url" field.
|
||||
func SubjectURLIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldSubjectURL))
|
||||
}
|
||||
|
||||
// SubjectURLNotNil applies the NotNil predicate on the "subject_url" field.
|
||||
func SubjectURLNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldSubjectURL))
|
||||
}
|
||||
|
||||
// SubjectURLEqualFold applies the EqualFold predicate on the "subject_url" field.
|
||||
func SubjectURLEqualFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEqualFold(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectURLContainsFold applies the ContainsFold predicate on the "subject_url" field.
|
||||
func SubjectURLContainsFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContainsFold(FieldSubjectURL, v))
|
||||
}
|
||||
|
||||
// SubjectTitleEQ applies the EQ predicate on the "subject_title" field.
|
||||
func SubjectTitleEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleNEQ applies the NEQ predicate on the "subject_title" field.
|
||||
func SubjectTitleNEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleIn applies the In predicate on the "subject_title" field.
|
||||
func SubjectTitleIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldSubjectTitle, vs...))
|
||||
}
|
||||
|
||||
// SubjectTitleNotIn applies the NotIn predicate on the "subject_title" field.
|
||||
func SubjectTitleNotIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldSubjectTitle, vs...))
|
||||
}
|
||||
|
||||
// SubjectTitleGT applies the GT predicate on the "subject_title" field.
|
||||
func SubjectTitleGT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleGTE applies the GTE predicate on the "subject_title" field.
|
||||
func SubjectTitleGTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleLT applies the LT predicate on the "subject_title" field.
|
||||
func SubjectTitleLT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleLTE applies the LTE predicate on the "subject_title" field.
|
||||
func SubjectTitleLTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleContains applies the Contains predicate on the "subject_title" field.
|
||||
func SubjectTitleContains(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContains(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleHasPrefix applies the HasPrefix predicate on the "subject_title" field.
|
||||
func SubjectTitleHasPrefix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasPrefix(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleHasSuffix applies the HasSuffix predicate on the "subject_title" field.
|
||||
func SubjectTitleHasSuffix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasSuffix(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleIsNil applies the IsNil predicate on the "subject_title" field.
|
||||
func SubjectTitleIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldSubjectTitle))
|
||||
}
|
||||
|
||||
// SubjectTitleNotNil applies the NotNil predicate on the "subject_title" field.
|
||||
func SubjectTitleNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldSubjectTitle))
|
||||
}
|
||||
|
||||
// SubjectTitleEqualFold applies the EqualFold predicate on the "subject_title" field.
|
||||
func SubjectTitleEqualFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEqualFold(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// SubjectTitleContainsFold applies the ContainsFold predicate on the "subject_title" field.
|
||||
func SubjectTitleContainsFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContainsFold(FieldSubjectTitle, v))
|
||||
}
|
||||
|
||||
// PromptIDEQ applies the EQ predicate on the "prompt_id" field.
|
||||
func PromptIDEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDNEQ applies the NEQ predicate on the "prompt_id" field.
|
||||
func PromptIDNEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDIn applies the In predicate on the "prompt_id" field.
|
||||
func PromptIDIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldPromptID, vs...))
|
||||
}
|
||||
|
||||
// PromptIDNotIn applies the NotIn predicate on the "prompt_id" field.
|
||||
func PromptIDNotIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldPromptID, vs...))
|
||||
}
|
||||
|
||||
// PromptIDGT applies the GT predicate on the "prompt_id" field.
|
||||
func PromptIDGT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDGTE applies the GTE predicate on the "prompt_id" field.
|
||||
func PromptIDGTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDLT applies the LT predicate on the "prompt_id" field.
|
||||
func PromptIDLT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDLTE applies the LTE predicate on the "prompt_id" field.
|
||||
func PromptIDLTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDContains applies the Contains predicate on the "prompt_id" field.
|
||||
func PromptIDContains(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContains(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDHasPrefix applies the HasPrefix predicate on the "prompt_id" field.
|
||||
func PromptIDHasPrefix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasPrefix(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDHasSuffix applies the HasSuffix predicate on the "prompt_id" field.
|
||||
func PromptIDHasSuffix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasSuffix(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDIsNil applies the IsNil predicate on the "prompt_id" field.
|
||||
func PromptIDIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldPromptID))
|
||||
}
|
||||
|
||||
// PromptIDNotNil applies the NotNil predicate on the "prompt_id" field.
|
||||
func PromptIDNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldPromptID))
|
||||
}
|
||||
|
||||
// PromptIDEqualFold applies the EqualFold predicate on the "prompt_id" field.
|
||||
func PromptIDEqualFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEqualFold(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// PromptIDContainsFold applies the ContainsFold predicate on the "prompt_id" field.
|
||||
func PromptIDContainsFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContainsFold(FieldPromptID, v))
|
||||
}
|
||||
|
||||
// ShowURLEQ applies the EQ predicate on the "show_url" field.
|
||||
func ShowURLEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLNEQ applies the NEQ predicate on the "show_url" field.
|
||||
func ShowURLNEQ(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLIn applies the In predicate on the "show_url" field.
|
||||
func ShowURLIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldShowURL, vs...))
|
||||
}
|
||||
|
||||
// ShowURLNotIn applies the NotIn predicate on the "show_url" field.
|
||||
func ShowURLNotIn(vs ...string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldShowURL, vs...))
|
||||
}
|
||||
|
||||
// ShowURLGT applies the GT predicate on the "show_url" field.
|
||||
func ShowURLGT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLGTE applies the GTE predicate on the "show_url" field.
|
||||
func ShowURLGTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLLT applies the LT predicate on the "show_url" field.
|
||||
func ShowURLLT(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLLTE applies the LTE predicate on the "show_url" field.
|
||||
func ShowURLLTE(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLContains applies the Contains predicate on the "show_url" field.
|
||||
func ShowURLContains(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContains(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLHasPrefix applies the HasPrefix predicate on the "show_url" field.
|
||||
func ShowURLHasPrefix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasPrefix(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLHasSuffix applies the HasSuffix predicate on the "show_url" field.
|
||||
func ShowURLHasSuffix(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldHasSuffix(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLIsNil applies the IsNil predicate on the "show_url" field.
|
||||
func ShowURLIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldShowURL))
|
||||
}
|
||||
|
||||
// ShowURLNotNil applies the NotNil predicate on the "show_url" field.
|
||||
func ShowURLNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldShowURL))
|
||||
}
|
||||
|
||||
// ShowURLEqualFold applies the EqualFold predicate on the "show_url" field.
|
||||
func ShowURLEqualFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEqualFold(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// ShowURLContainsFold applies the ContainsFold predicate on the "show_url" field.
|
||||
func ShowURLContainsFold(v string) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldContainsFold(FieldShowURL, v))
|
||||
}
|
||||
|
||||
// GithubInstallationIDEQ applies the EQ predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDEQ(v int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldGithubInstallationID, v))
|
||||
}
|
||||
|
||||
// GithubInstallationIDNEQ applies the NEQ predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDNEQ(v int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldGithubInstallationID, v))
|
||||
}
|
||||
|
||||
// GithubInstallationIDIn applies the In predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDIn(vs ...int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldGithubInstallationID, vs...))
|
||||
}
|
||||
|
||||
// GithubInstallationIDNotIn applies the NotIn predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDNotIn(vs ...int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldGithubInstallationID, vs...))
|
||||
}
|
||||
|
||||
// GithubInstallationIDGT applies the GT predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDGT(v int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldGithubInstallationID, v))
|
||||
}
|
||||
|
||||
// GithubInstallationIDGTE applies the GTE predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDGTE(v int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldGithubInstallationID, v))
|
||||
}
|
||||
|
||||
// GithubInstallationIDLT applies the LT predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDLT(v int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldGithubInstallationID, v))
|
||||
}
|
||||
|
||||
// GithubInstallationIDLTE applies the LTE predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDLTE(v int64) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldGithubInstallationID, v))
|
||||
}
|
||||
|
||||
// GithubInstallationIDIsNil applies the IsNil predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDIsNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIsNull(FieldGithubInstallationID))
|
||||
}
|
||||
|
||||
// GithubInstallationIDNotNil applies the NotNil predicate on the "github_installation_id" field.
|
||||
func GithubInstallationIDNotNil() predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotNull(FieldGithubInstallationID))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.GitTask {
|
||||
return predicate.GitTask(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// HasTask applies the HasEdge predicate on the "task" edge.
|
||||
func HasTask() predicate.GitTask {
|
||||
return predicate.GitTask(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, TaskTable, TaskColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasTaskWith applies the HasEdge predicate on the "task" edge with a given conditions (other predicates).
|
||||
func HasTaskWith(preds ...predicate.Task) predicate.GitTask {
|
||||
return predicate.GitTask(func(s *sql.Selector) {
|
||||
step := newTaskStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.GitTask) predicate.GitTask {
|
||||
return predicate.GitTask(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.GitTask) predicate.GitTask {
|
||||
return predicate.GitTask(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.GitTask) predicate.GitTask {
|
||||
return predicate.GitTask(sql.NotPredicates(p))
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
||||
)
|
||||
|
||||
// GitTaskDelete is the builder for deleting a GitTask entity.
|
||||
type GitTaskDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *GitTaskMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GitTaskDelete builder.
|
||||
func (_d *GitTaskDelete) Where(ps ...predicate.GitTask) *GitTaskDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *GitTaskDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *GitTaskDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *GitTaskDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(gittask.Table, sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// GitTaskDeleteOne is the builder for deleting a single GitTask entity.
|
||||
type GitTaskDeleteOne struct {
|
||||
_d *GitTaskDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GitTaskDelete builder.
|
||||
func (_d *GitTaskDeleteOne) Where(ps ...predicate.GitTask) *GitTaskDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *GitTaskDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{gittask.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *GitTaskDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,657 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/task"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// GitTaskQuery is the builder for querying GitTask entities.
|
||||
type GitTaskQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []gittask.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.GitTask
|
||||
withTask *TaskQuery
|
||||
modifiers []func(*sql.Selector)
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the GitTaskQuery builder.
|
||||
func (_q *GitTaskQuery) Where(ps ...predicate.GitTask) *GitTaskQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *GitTaskQuery) Limit(limit int) *GitTaskQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *GitTaskQuery) Offset(offset int) *GitTaskQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *GitTaskQuery) Unique(unique bool) *GitTaskQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *GitTaskQuery) Order(o ...gittask.OrderOption) *GitTaskQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryTask chains the current query on the "task" edge.
|
||||
func (_q *GitTaskQuery) QueryTask() *TaskQuery {
|
||||
query := (&TaskClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(gittask.Table, gittask.FieldID, selector),
|
||||
sqlgraph.To(task.Table, task.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, gittask.TaskTable, gittask.TaskColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first GitTask entity from the query.
|
||||
// Returns a *NotFoundError when no GitTask was found.
|
||||
func (_q *GitTaskQuery) First(ctx context.Context) (*GitTask, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{gittask.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) FirstX(ctx context.Context) *GitTask {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first GitTask ID from the query.
|
||||
// Returns a *NotFoundError when no GitTask ID was found.
|
||||
func (_q *GitTaskQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{gittask.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single GitTask entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one GitTask entity is found.
|
||||
// Returns a *NotFoundError when no GitTask entities are found.
|
||||
func (_q *GitTaskQuery) Only(ctx context.Context) (*GitTask, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{gittask.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{gittask.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) OnlyX(ctx context.Context) *GitTask {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only GitTask ID in the query.
|
||||
// Returns a *NotSingularError when more than one GitTask ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *GitTaskQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{gittask.Label}
|
||||
default:
|
||||
err = &NotSingularError{gittask.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of GitTasks.
|
||||
func (_q *GitTaskQuery) All(ctx context.Context) ([]*GitTask, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*GitTask, *GitTaskQuery]()
|
||||
return withInterceptors[[]*GitTask](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) AllX(ctx context.Context) []*GitTask {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of GitTask IDs.
|
||||
func (_q *GitTaskQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(gittask.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *GitTaskQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*GitTaskQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *GitTaskQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("db: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *GitTaskQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the GitTaskQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *GitTaskQuery) Clone() *GitTaskQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &GitTaskQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]gittask.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.GitTask{}, _q.predicates...),
|
||||
withTask: _q.withTask.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithTask tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "task" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *GitTaskQuery) WithTask(opts ...func(*TaskQuery)) *GitTaskQuery {
|
||||
query := (&TaskClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withTask = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// TaskID uuid.UUID `json:"task_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.GitTask.Query().
|
||||
// GroupBy(gittask.FieldTaskID).
|
||||
// Aggregate(db.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *GitTaskQuery) GroupBy(field string, fields ...string) *GitTaskGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &GitTaskGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = gittask.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// TaskID uuid.UUID `json:"task_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.GitTask.Query().
|
||||
// Select(gittask.FieldTaskID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *GitTaskQuery) Select(fields ...string) *GitTaskSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &GitTaskSelect{GitTaskQuery: _q}
|
||||
sbuild.label = gittask.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a GitTaskSelect configured with the given aggregations.
|
||||
func (_q *GitTaskQuery) Aggregate(fns ...AggregateFunc) *GitTaskSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *GitTaskQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !gittask.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *GitTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*GitTask, error) {
|
||||
var (
|
||||
nodes = []*GitTask{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
_q.withTask != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*GitTask).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &GitTask{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withTask; query != nil {
|
||||
if err := _q.loadTask(ctx, query, nodes, nil,
|
||||
func(n *GitTask, e *Task) { n.Edges.Task = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *GitTaskQuery) loadTask(ctx context.Context, query *TaskQuery, nodes []*GitTask, init func(*GitTask), assign func(*GitTask, *Task)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*GitTask)
|
||||
for i := range nodes {
|
||||
fk := nodes[i].TaskID
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(task.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "task_id" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *GitTaskQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *GitTaskQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(gittask.Table, gittask.Columns, sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, gittask.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != gittask.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if _q.withTask != nil {
|
||||
_spec.Node.AddColumnOnce(gittask.FieldTaskID)
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *GitTaskQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(gittask.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = gittask.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
|
||||
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
|
||||
// either committed or rolled-back.
|
||||
func (_q *GitTaskQuery) ForUpdate(opts ...sql.LockOption) *GitTaskQuery {
|
||||
if _q.driver.Dialect() == dialect.Postgres {
|
||||
_q.Unique(false)
|
||||
}
|
||||
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
|
||||
s.ForUpdate(opts...)
|
||||
})
|
||||
return _q
|
||||
}
|
||||
|
||||
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
|
||||
// on any rows that are read. Other sessions can read the rows, but cannot modify them
|
||||
// until your transaction commits.
|
||||
func (_q *GitTaskQuery) ForShare(opts ...sql.LockOption) *GitTaskQuery {
|
||||
if _q.driver.Dialect() == dialect.Postgres {
|
||||
_q.Unique(false)
|
||||
}
|
||||
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
|
||||
s.ForShare(opts...)
|
||||
})
|
||||
return _q
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (_q *GitTaskQuery) Modify(modifiers ...func(s *sql.Selector)) *GitTaskSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// GitTaskGroupBy is the group-by builder for GitTask entities.
|
||||
type GitTaskGroupBy struct {
|
||||
selector
|
||||
build *GitTaskQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *GitTaskGroupBy) Aggregate(fns ...AggregateFunc) *GitTaskGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *GitTaskGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*GitTaskQuery, *GitTaskGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *GitTaskGroupBy) sqlScan(ctx context.Context, root *GitTaskQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// GitTaskSelect is the builder for selecting fields of GitTask entities.
|
||||
type GitTaskSelect struct {
|
||||
*GitTaskQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *GitTaskSelect) Aggregate(fns ...AggregateFunc) *GitTaskSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *GitTaskSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*GitTaskQuery, *GitTaskSelect](ctx, _s.GitTaskQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *GitTaskSelect) sqlScan(ctx context.Context, root *GitTaskQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (_s *GitTaskSelect) Modify(modifiers ...func(s *sql.Selector)) *GitTaskSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
@@ -0,0 +1,858 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/task"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// GitTaskUpdate is the builder for updating GitTask entities.
|
||||
type GitTaskUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *GitTaskMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GitTaskUpdate builder.
|
||||
func (_u *GitTaskUpdate) Where(ps ...predicate.GitTask) *GitTaskUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTaskID sets the "task_id" field.
|
||||
func (_u *GitTaskUpdate) SetTaskID(v uuid.UUID) *GitTaskUpdate {
|
||||
_u.mutation.SetTaskID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableTaskID(v *uuid.UUID) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetTaskID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRepoID sets the "repo_id" field.
|
||||
func (_u *GitTaskUpdate) SetRepoID(v uuid.UUID) *GitTaskUpdate {
|
||||
_u.mutation.SetRepoID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRepoID sets the "repo_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableRepoID(v *uuid.UUID) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetRepoID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRepoID clears the value of the "repo_id" field.
|
||||
func (_u *GitTaskUpdate) ClearRepoID() *GitTaskUpdate {
|
||||
_u.mutation.ClearRepoID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectType sets the "subject_type" field.
|
||||
func (_u *GitTaskUpdate) SetSubjectType(v string) *GitTaskUpdate {
|
||||
_u.mutation.SetSubjectType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectType sets the "subject_type" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableSubjectType(v *string) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetSubjectType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectID sets the "subject_id" field.
|
||||
func (_u *GitTaskUpdate) SetSubjectID(v string) *GitTaskUpdate {
|
||||
_u.mutation.SetSubjectID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectID sets the "subject_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableSubjectID(v *string) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetSubjectID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectID clears the value of the "subject_id" field.
|
||||
func (_u *GitTaskUpdate) ClearSubjectID() *GitTaskUpdate {
|
||||
_u.mutation.ClearSubjectID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectNumber sets the "subject_number" field.
|
||||
func (_u *GitTaskUpdate) SetSubjectNumber(v int) *GitTaskUpdate {
|
||||
_u.mutation.ResetSubjectNumber()
|
||||
_u.mutation.SetSubjectNumber(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectNumber sets the "subject_number" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableSubjectNumber(v *int) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetSubjectNumber(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSubjectNumber adds value to the "subject_number" field.
|
||||
func (_u *GitTaskUpdate) AddSubjectNumber(v int) *GitTaskUpdate {
|
||||
_u.mutation.AddSubjectNumber(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectNumber clears the value of the "subject_number" field.
|
||||
func (_u *GitTaskUpdate) ClearSubjectNumber() *GitTaskUpdate {
|
||||
_u.mutation.ClearSubjectNumber()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectURL sets the "subject_url" field.
|
||||
func (_u *GitTaskUpdate) SetSubjectURL(v string) *GitTaskUpdate {
|
||||
_u.mutation.SetSubjectURL(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectURL sets the "subject_url" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableSubjectURL(v *string) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetSubjectURL(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectURL clears the value of the "subject_url" field.
|
||||
func (_u *GitTaskUpdate) ClearSubjectURL() *GitTaskUpdate {
|
||||
_u.mutation.ClearSubjectURL()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectTitle sets the "subject_title" field.
|
||||
func (_u *GitTaskUpdate) SetSubjectTitle(v string) *GitTaskUpdate {
|
||||
_u.mutation.SetSubjectTitle(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectTitle sets the "subject_title" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableSubjectTitle(v *string) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetSubjectTitle(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectTitle clears the value of the "subject_title" field.
|
||||
func (_u *GitTaskUpdate) ClearSubjectTitle() *GitTaskUpdate {
|
||||
_u.mutation.ClearSubjectTitle()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPromptID sets the "prompt_id" field.
|
||||
func (_u *GitTaskUpdate) SetPromptID(v string) *GitTaskUpdate {
|
||||
_u.mutation.SetPromptID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePromptID sets the "prompt_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillablePromptID(v *string) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetPromptID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearPromptID clears the value of the "prompt_id" field.
|
||||
func (_u *GitTaskUpdate) ClearPromptID() *GitTaskUpdate {
|
||||
_u.mutation.ClearPromptID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetShowURL sets the "show_url" field.
|
||||
func (_u *GitTaskUpdate) SetShowURL(v string) *GitTaskUpdate {
|
||||
_u.mutation.SetShowURL(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableShowURL sets the "show_url" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableShowURL(v *string) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetShowURL(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearShowURL clears the value of the "show_url" field.
|
||||
func (_u *GitTaskUpdate) ClearShowURL() *GitTaskUpdate {
|
||||
_u.mutation.ClearShowURL()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGithubInstallationID sets the "github_installation_id" field.
|
||||
func (_u *GitTaskUpdate) SetGithubInstallationID(v int64) *GitTaskUpdate {
|
||||
_u.mutation.ResetGithubInstallationID()
|
||||
_u.mutation.SetGithubInstallationID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGithubInstallationID sets the "github_installation_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableGithubInstallationID(v *int64) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetGithubInstallationID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddGithubInstallationID adds value to the "github_installation_id" field.
|
||||
func (_u *GitTaskUpdate) AddGithubInstallationID(v int64) *GitTaskUpdate {
|
||||
_u.mutation.AddGithubInstallationID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearGithubInstallationID clears the value of the "github_installation_id" field.
|
||||
func (_u *GitTaskUpdate) ClearGithubInstallationID() *GitTaskUpdate {
|
||||
_u.mutation.ClearGithubInstallationID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *GitTaskUpdate) SetCreatedAt(v time.Time) *GitTaskUpdate {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdate) SetNillableCreatedAt(v *time.Time) *GitTaskUpdate {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTask sets the "task" edge to the Task entity.
|
||||
func (_u *GitTaskUpdate) SetTask(v *Task) *GitTaskUpdate {
|
||||
return _u.SetTaskID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the GitTaskMutation object of the builder.
|
||||
func (_u *GitTaskUpdate) Mutation() *GitTaskMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearTask clears the "task" edge to the Task entity.
|
||||
func (_u *GitTaskUpdate) ClearTask() *GitTaskUpdate {
|
||||
_u.mutation.ClearTask()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *GitTaskUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *GitTaskUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *GitTaskUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *GitTaskUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *GitTaskUpdate) check() error {
|
||||
if v, ok := _u.mutation.SubjectType(); ok {
|
||||
if err := gittask.SubjectTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "subject_type", err: fmt.Errorf(`db: validator failed for field "GitTask.subject_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.TaskCleared() && len(_u.mutation.TaskIDs()) > 0 {
|
||||
return errors.New(`db: clearing a required unique edge "GitTask.task"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *GitTaskUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GitTaskUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *GitTaskUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(gittask.Table, gittask.Columns, sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.RepoID(); ok {
|
||||
_spec.SetField(gittask.FieldRepoID, field.TypeUUID, value)
|
||||
}
|
||||
if _u.mutation.RepoIDCleared() {
|
||||
_spec.ClearField(gittask.FieldRepoID, field.TypeUUID)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectType(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectType, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectID(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectID, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SubjectIDCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectNumber(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedSubjectNumber(); ok {
|
||||
_spec.AddField(gittask.FieldSubjectNumber, field.TypeInt, value)
|
||||
}
|
||||
if _u.mutation.SubjectNumberCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectNumber, field.TypeInt)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectURL(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectURL, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SubjectURLCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectURL, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectTitle(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectTitle, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SubjectTitleCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectTitle, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PromptID(); ok {
|
||||
_spec.SetField(gittask.FieldPromptID, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.PromptIDCleared() {
|
||||
_spec.ClearField(gittask.FieldPromptID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.ShowURL(); ok {
|
||||
_spec.SetField(gittask.FieldShowURL, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ShowURLCleared() {
|
||||
_spec.ClearField(gittask.FieldShowURL, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.GithubInstallationID(); ok {
|
||||
_spec.SetField(gittask.FieldGithubInstallationID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedGithubInstallationID(); ok {
|
||||
_spec.AddField(gittask.FieldGithubInstallationID, field.TypeInt64, value)
|
||||
}
|
||||
if _u.mutation.GithubInstallationIDCleared() {
|
||||
_spec.ClearField(gittask.FieldGithubInstallationID, field.TypeInt64)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(gittask.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.TaskCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
Table: gittask.TaskTable,
|
||||
Columns: []string{gittask.TaskColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.TaskIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
Table: gittask.TaskTable,
|
||||
Columns: []string{gittask.TaskColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{gittask.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// GitTaskUpdateOne is the builder for updating a single GitTask entity.
|
||||
type GitTaskUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *GitTaskMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetTaskID sets the "task_id" field.
|
||||
func (_u *GitTaskUpdateOne) SetTaskID(v uuid.UUID) *GitTaskUpdateOne {
|
||||
_u.mutation.SetTaskID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableTaskID(v *uuid.UUID) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTaskID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRepoID sets the "repo_id" field.
|
||||
func (_u *GitTaskUpdateOne) SetRepoID(v uuid.UUID) *GitTaskUpdateOne {
|
||||
_u.mutation.SetRepoID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRepoID sets the "repo_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableRepoID(v *uuid.UUID) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRepoID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRepoID clears the value of the "repo_id" field.
|
||||
func (_u *GitTaskUpdateOne) ClearRepoID() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearRepoID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectType sets the "subject_type" field.
|
||||
func (_u *GitTaskUpdateOne) SetSubjectType(v string) *GitTaskUpdateOne {
|
||||
_u.mutation.SetSubjectType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectType sets the "subject_type" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableSubjectType(v *string) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSubjectType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectID sets the "subject_id" field.
|
||||
func (_u *GitTaskUpdateOne) SetSubjectID(v string) *GitTaskUpdateOne {
|
||||
_u.mutation.SetSubjectID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectID sets the "subject_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableSubjectID(v *string) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSubjectID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectID clears the value of the "subject_id" field.
|
||||
func (_u *GitTaskUpdateOne) ClearSubjectID() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearSubjectID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectNumber sets the "subject_number" field.
|
||||
func (_u *GitTaskUpdateOne) SetSubjectNumber(v int) *GitTaskUpdateOne {
|
||||
_u.mutation.ResetSubjectNumber()
|
||||
_u.mutation.SetSubjectNumber(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectNumber sets the "subject_number" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableSubjectNumber(v *int) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSubjectNumber(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSubjectNumber adds value to the "subject_number" field.
|
||||
func (_u *GitTaskUpdateOne) AddSubjectNumber(v int) *GitTaskUpdateOne {
|
||||
_u.mutation.AddSubjectNumber(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectNumber clears the value of the "subject_number" field.
|
||||
func (_u *GitTaskUpdateOne) ClearSubjectNumber() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearSubjectNumber()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectURL sets the "subject_url" field.
|
||||
func (_u *GitTaskUpdateOne) SetSubjectURL(v string) *GitTaskUpdateOne {
|
||||
_u.mutation.SetSubjectURL(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectURL sets the "subject_url" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableSubjectURL(v *string) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSubjectURL(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectURL clears the value of the "subject_url" field.
|
||||
func (_u *GitTaskUpdateOne) ClearSubjectURL() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearSubjectURL()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSubjectTitle sets the "subject_title" field.
|
||||
func (_u *GitTaskUpdateOne) SetSubjectTitle(v string) *GitTaskUpdateOne {
|
||||
_u.mutation.SetSubjectTitle(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSubjectTitle sets the "subject_title" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableSubjectTitle(v *string) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSubjectTitle(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSubjectTitle clears the value of the "subject_title" field.
|
||||
func (_u *GitTaskUpdateOne) ClearSubjectTitle() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearSubjectTitle()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPromptID sets the "prompt_id" field.
|
||||
func (_u *GitTaskUpdateOne) SetPromptID(v string) *GitTaskUpdateOne {
|
||||
_u.mutation.SetPromptID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePromptID sets the "prompt_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillablePromptID(v *string) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetPromptID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearPromptID clears the value of the "prompt_id" field.
|
||||
func (_u *GitTaskUpdateOne) ClearPromptID() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearPromptID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetShowURL sets the "show_url" field.
|
||||
func (_u *GitTaskUpdateOne) SetShowURL(v string) *GitTaskUpdateOne {
|
||||
_u.mutation.SetShowURL(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableShowURL sets the "show_url" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableShowURL(v *string) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetShowURL(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearShowURL clears the value of the "show_url" field.
|
||||
func (_u *GitTaskUpdateOne) ClearShowURL() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearShowURL()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGithubInstallationID sets the "github_installation_id" field.
|
||||
func (_u *GitTaskUpdateOne) SetGithubInstallationID(v int64) *GitTaskUpdateOne {
|
||||
_u.mutation.ResetGithubInstallationID()
|
||||
_u.mutation.SetGithubInstallationID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGithubInstallationID sets the "github_installation_id" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableGithubInstallationID(v *int64) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetGithubInstallationID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddGithubInstallationID adds value to the "github_installation_id" field.
|
||||
func (_u *GitTaskUpdateOne) AddGithubInstallationID(v int64) *GitTaskUpdateOne {
|
||||
_u.mutation.AddGithubInstallationID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearGithubInstallationID clears the value of the "github_installation_id" field.
|
||||
func (_u *GitTaskUpdateOne) ClearGithubInstallationID() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearGithubInstallationID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *GitTaskUpdateOne) SetCreatedAt(v time.Time) *GitTaskUpdateOne {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *GitTaskUpdateOne) SetNillableCreatedAt(v *time.Time) *GitTaskUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTask sets the "task" edge to the Task entity.
|
||||
func (_u *GitTaskUpdateOne) SetTask(v *Task) *GitTaskUpdateOne {
|
||||
return _u.SetTaskID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the GitTaskMutation object of the builder.
|
||||
func (_u *GitTaskUpdateOne) Mutation() *GitTaskMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearTask clears the "task" edge to the Task entity.
|
||||
func (_u *GitTaskUpdateOne) ClearTask() *GitTaskUpdateOne {
|
||||
_u.mutation.ClearTask()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GitTaskUpdate builder.
|
||||
func (_u *GitTaskUpdateOne) Where(ps ...predicate.GitTask) *GitTaskUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (_u *GitTaskUpdateOne) Select(field string, fields ...string) *GitTaskUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated GitTask entity.
|
||||
func (_u *GitTaskUpdateOne) Save(ctx context.Context) (*GitTask, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *GitTaskUpdateOne) SaveX(ctx context.Context) *GitTask {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *GitTaskUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *GitTaskUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *GitTaskUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.SubjectType(); ok {
|
||||
if err := gittask.SubjectTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "subject_type", err: fmt.Errorf(`db: validator failed for field "GitTask.subject_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.TaskCleared() && len(_u.mutation.TaskIDs()) > 0 {
|
||||
return errors.New(`db: clearing a required unique edge "GitTask.task"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *GitTaskUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GitTaskUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *GitTaskUpdateOne) sqlSave(ctx context.Context) (_node *GitTask, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(gittask.Table, gittask.Columns, sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "GitTask.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, gittask.FieldID)
|
||||
for _, f := range fields {
|
||||
if !gittask.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
||||
}
|
||||
if f != gittask.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.RepoID(); ok {
|
||||
_spec.SetField(gittask.FieldRepoID, field.TypeUUID, value)
|
||||
}
|
||||
if _u.mutation.RepoIDCleared() {
|
||||
_spec.ClearField(gittask.FieldRepoID, field.TypeUUID)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectType(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectType, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectID(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectID, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SubjectIDCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectNumber(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedSubjectNumber(); ok {
|
||||
_spec.AddField(gittask.FieldSubjectNumber, field.TypeInt, value)
|
||||
}
|
||||
if _u.mutation.SubjectNumberCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectNumber, field.TypeInt)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectURL(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectURL, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SubjectURLCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectURL, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.SubjectTitle(); ok {
|
||||
_spec.SetField(gittask.FieldSubjectTitle, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SubjectTitleCleared() {
|
||||
_spec.ClearField(gittask.FieldSubjectTitle, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PromptID(); ok {
|
||||
_spec.SetField(gittask.FieldPromptID, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.PromptIDCleared() {
|
||||
_spec.ClearField(gittask.FieldPromptID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.ShowURL(); ok {
|
||||
_spec.SetField(gittask.FieldShowURL, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ShowURLCleared() {
|
||||
_spec.ClearField(gittask.FieldShowURL, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.GithubInstallationID(); ok {
|
||||
_spec.SetField(gittask.FieldGithubInstallationID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedGithubInstallationID(); ok {
|
||||
_spec.AddField(gittask.FieldGithubInstallationID, field.TypeInt64, value)
|
||||
}
|
||||
if _u.mutation.GithubInstallationIDCleared() {
|
||||
_spec.ClearField(gittask.FieldGithubInstallationID, field.TypeInt64)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(gittask.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.TaskCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
Table: gittask.TaskTable,
|
||||
Columns: []string{gittask.TaskColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.TaskIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
Table: gittask.TaskTable,
|
||||
Columns: []string{gittask.TaskColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &GitTask{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{gittask.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
@@ -69,6 +69,18 @@ func (f GitIdentityFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, e
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *db.GitIdentityMutation", m)
|
||||
}
|
||||
|
||||
// The GitTaskFunc type is an adapter to allow the use of ordinary
|
||||
// function as GitTask mutator.
|
||||
type GitTaskFunc func(context.Context, *db.GitTaskMutation) (db.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f GitTaskFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) {
|
||||
if mv, ok := m.(*db.GitTaskMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *db.GitTaskMutation", m)
|
||||
}
|
||||
|
||||
// The HostFunc type is an adapter to allow the use of ordinary
|
||||
// function as Host mutator.
|
||||
type HostFunc func(context.Context, *db.HostMutation) (db.Value, error)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/host"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/image"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/mcptool"
|
||||
@@ -241,6 +242,33 @@ func (f TraverseGitIdentity) Traverse(ctx context.Context, q db.Query) error {
|
||||
return fmt.Errorf("unexpected query type %T. expect *db.GitIdentityQuery", q)
|
||||
}
|
||||
|
||||
// The GitTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
|
||||
type GitTaskFunc func(context.Context, *db.GitTaskQuery) (db.Value, error)
|
||||
|
||||
// Query calls f(ctx, q).
|
||||
func (f GitTaskFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
|
||||
if q, ok := q.(*db.GitTaskQuery); ok {
|
||||
return f(ctx, q)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected query type %T. expect *db.GitTaskQuery", q)
|
||||
}
|
||||
|
||||
// The TraverseGitTask type is an adapter to allow the use of ordinary function as Traverser.
|
||||
type TraverseGitTask func(context.Context, *db.GitTaskQuery) error
|
||||
|
||||
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
||||
func (f TraverseGitTask) Intercept(next db.Querier) db.Querier {
|
||||
return next
|
||||
}
|
||||
|
||||
// Traverse calls f(ctx, q).
|
||||
func (f TraverseGitTask) Traverse(ctx context.Context, q db.Query) error {
|
||||
if q, ok := q.(*db.GitTaskQuery); ok {
|
||||
return f(ctx, q)
|
||||
}
|
||||
return fmt.Errorf("unexpected query type %T. expect *db.GitTaskQuery", q)
|
||||
}
|
||||
|
||||
// The HostFunc type is an adapter to allow the use of ordinary function as a Querier.
|
||||
type HostFunc func(context.Context, *db.HostQuery) (db.Value, error)
|
||||
|
||||
@@ -1172,6 +1200,8 @@ func NewQuery(q db.Query) (Query, error) {
|
||||
return &query[*db.GitBotUserQuery, predicate.GitBotUser, gitbotuser.OrderOption]{typ: db.TypeGitBotUser, tq: q}, nil
|
||||
case *db.GitIdentityQuery:
|
||||
return &query[*db.GitIdentityQuery, predicate.GitIdentity, gitidentity.OrderOption]{typ: db.TypeGitIdentity, tq: q}, nil
|
||||
case *db.GitTaskQuery:
|
||||
return &query[*db.GitTaskQuery, predicate.GitTask, gittask.OrderOption]{typ: db.TypeGitTask, tq: q}, nil
|
||||
case *db.HostQuery:
|
||||
return &query[*db.HostQuery, predicate.Host, host.OrderOption]{typ: db.TypeHost, tq: q}, nil
|
||||
case *db.ImageQuery:
|
||||
|
||||
@@ -152,6 +152,35 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// GitTasksColumns holds the columns for the "git_tasks" table.
|
||||
GitTasksColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "repo_id", Type: field.TypeUUID, Nullable: true},
|
||||
{Name: "subject_type", Type: field.TypeString},
|
||||
{Name: "subject_id", Type: field.TypeString, Nullable: true},
|
||||
{Name: "subject_number", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "subject_url", Type: field.TypeString, Nullable: true},
|
||||
{Name: "subject_title", Type: field.TypeString, Nullable: true},
|
||||
{Name: "prompt_id", Type: field.TypeString, Nullable: true},
|
||||
{Name: "show_url", Type: field.TypeString, Nullable: true, Size: 2147483647},
|
||||
{Name: "github_installation_id", Type: field.TypeInt64, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "task_id", Type: field.TypeUUID, Unique: true},
|
||||
}
|
||||
// GitTasksTable holds the schema information for the "git_tasks" table.
|
||||
GitTasksTable = &schema.Table{
|
||||
Name: "git_tasks",
|
||||
Columns: GitTasksColumns,
|
||||
PrimaryKey: []*schema.Column{GitTasksColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "git_tasks_tasks_git_tasks",
|
||||
Columns: []*schema.Column{GitTasksColumns[11]},
|
||||
RefColumns: []*schema.Column{TasksColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// HostsColumns holds the columns for the "hosts" table.
|
||||
HostsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeString, Unique: true},
|
||||
@@ -1325,6 +1354,7 @@ var (
|
||||
GitBotTasksTable,
|
||||
GitBotUsersTable,
|
||||
GitIdentitiesTable,
|
||||
GitTasksTable,
|
||||
HostsTable,
|
||||
ImagesTable,
|
||||
McpToolsTable,
|
||||
@@ -1385,6 +1415,10 @@ func init() {
|
||||
GitIdentitiesTable.Annotation = &entsql.Annotation{
|
||||
Table: "git_identities",
|
||||
}
|
||||
GitTasksTable.ForeignKeys[0].RefTable = TasksTable
|
||||
GitTasksTable.Annotation = &entsql.Annotation{
|
||||
Table: "git_tasks",
|
||||
}
|
||||
HostsTable.ForeignKeys[0].RefTable = UsersTable
|
||||
HostsTable.Annotation = &entsql.Annotation{
|
||||
Table: "hosts",
|
||||
|
||||
+1216
-3
File diff suppressed because it is too large.
Load diff
@@ -81,6 +81,20 @@ func (_m *GitIdentityQuery) Page(ctx context.Context, page, size int) ([]*GitIde
|
||||
return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
|
||||
}
|
||||
|
||||
func (_m *GitTaskQuery) Page(ctx context.Context, page, size int) ([]*GitTask, *PageInfo, error) {
|
||||
cnt, err := _m.Count(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
offset := size * (page - 1)
|
||||
rs, err := _m.Offset(offset).Limit(size).All(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
has := (page * size) < cnt
|
||||
return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
|
||||
}
|
||||
|
||||
func (_m *HostQuery) Page(ctx context.Context, page, size int) ([]*Host, *PageInfo, error) {
|
||||
cnt, err := _m.Count(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,6 +21,9 @@ type GitBotUser func(*sql.Selector)
|
||||
// GitIdentity is the predicate function for gitidentity builders.
|
||||
type GitIdentity func(*sql.Selector)
|
||||
|
||||
// GitTask is the predicate function for gittask builders.
|
||||
type GitTask func(*sql.Selector)
|
||||
|
||||
// Host is the predicate function for host builders.
|
||||
type Host func(*sql.Selector)
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/host"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/image"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/mcptool"
|
||||
@@ -107,6 +108,16 @@ func init() {
|
||||
gitidentity.DefaultUpdatedAt = gitidentityDescUpdatedAt.Default.(func() time.Time)
|
||||
// gitidentity.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
gitidentity.UpdateDefaultUpdatedAt = gitidentityDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
gittaskFields := schema.GitTask{}.Fields()
|
||||
_ = gittaskFields
|
||||
// gittaskDescSubjectType is the schema descriptor for subject_type field.
|
||||
gittaskDescSubjectType := gittaskFields[3].Descriptor()
|
||||
// gittask.SubjectTypeValidator is a validator for the "subject_type" field. It is called by the builders before save.
|
||||
gittask.SubjectTypeValidator = gittaskDescSubjectType.Validators[0].(func(string) error)
|
||||
// gittaskDescCreatedAt is the schema descriptor for created_at field.
|
||||
gittaskDescCreatedAt := gittaskFields[11].Descriptor()
|
||||
// gittask.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
gittask.DefaultCreatedAt = gittaskDescCreatedAt.Default.(func() time.Time)
|
||||
hostMixin := schema.Host{}.Mixin()
|
||||
hostMixinHooks0 := hostMixin[0].Hooks()
|
||||
host.Hooks[0] = hostMixinHooks0[0]
|
||||
|
||||
+25
-6
@@ -10,6 +10,7 @@ import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/chaitin/MonkeyCode/backend/consts"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/task"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/user"
|
||||
"github.com/google/uuid"
|
||||
@@ -56,6 +57,8 @@ type Task struct {
|
||||
type TaskEdges struct {
|
||||
// ProjectTasks holds the value of the project_tasks edge.
|
||||
ProjectTasks []*ProjectTask `json:"project_tasks,omitempty"`
|
||||
// GitTasks holds the value of the git_tasks edge.
|
||||
GitTasks *GitTask `json:"git_tasks,omitempty"`
|
||||
// User holds the value of the user edge.
|
||||
User *User `json:"user,omitempty"`
|
||||
// Vms holds the value of the vms edge.
|
||||
@@ -68,7 +71,7 @@ type TaskEdges struct {
|
||||
TaskVms []*TaskVirtualMachine `json:"task_vms,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [6]bool
|
||||
loadedTypes [7]bool
|
||||
}
|
||||
|
||||
// ProjectTasksOrErr returns the ProjectTasks value or an error if the edge
|
||||
@@ -80,12 +83,23 @@ func (e TaskEdges) ProjectTasksOrErr() ([]*ProjectTask, error) {
|
||||
return nil, &NotLoadedError{edge: "project_tasks"}
|
||||
}
|
||||
|
||||
// GitTasksOrErr returns the GitTasks value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e TaskEdges) GitTasksOrErr() (*GitTask, error) {
|
||||
if e.GitTasks != nil {
|
||||
return e.GitTasks, nil
|
||||
} else if e.loadedTypes[1] {
|
||||
return nil, &NotFoundError{label: gittask.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "git_tasks"}
|
||||
}
|
||||
|
||||
// UserOrErr returns the User value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e TaskEdges) UserOrErr() (*User, error) {
|
||||
if e.User != nil {
|
||||
return e.User, nil
|
||||
} else if e.loadedTypes[1] {
|
||||
} else if e.loadedTypes[2] {
|
||||
return nil, &NotFoundError{label: user.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "user"}
|
||||
@@ -94,7 +108,7 @@ func (e TaskEdges) UserOrErr() (*User, error) {
|
||||
// VmsOrErr returns the Vms value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e TaskEdges) VmsOrErr() ([]*VirtualMachine, error) {
|
||||
if e.loadedTypes[2] {
|
||||
if e.loadedTypes[3] {
|
||||
return e.Vms, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "vms"}
|
||||
@@ -103,7 +117,7 @@ func (e TaskEdges) VmsOrErr() ([]*VirtualMachine, error) {
|
||||
// GitBotTasksOrErr returns the GitBotTasks value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e TaskEdges) GitBotTasksOrErr() ([]*GitBotTask, error) {
|
||||
if e.loadedTypes[3] {
|
||||
if e.loadedTypes[4] {
|
||||
return e.GitBotTasks, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "git_bot_tasks"}
|
||||
@@ -112,7 +126,7 @@ func (e TaskEdges) GitBotTasksOrErr() ([]*GitBotTask, error) {
|
||||
// ModelSwitchesOrErr returns the ModelSwitches value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e TaskEdges) ModelSwitchesOrErr() ([]*TaskModelSwitch, error) {
|
||||
if e.loadedTypes[4] {
|
||||
if e.loadedTypes[5] {
|
||||
return e.ModelSwitches, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "model_switches"}
|
||||
@@ -121,7 +135,7 @@ func (e TaskEdges) ModelSwitchesOrErr() ([]*TaskModelSwitch, error) {
|
||||
// TaskVmsOrErr returns the TaskVms value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e TaskEdges) TaskVmsOrErr() ([]*TaskVirtualMachine, error) {
|
||||
if e.loadedTypes[5] {
|
||||
if e.loadedTypes[6] {
|
||||
return e.TaskVms, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "task_vms"}
|
||||
@@ -256,6 +270,11 @@ func (_m *Task) QueryProjectTasks() *ProjectTaskQuery {
|
||||
return NewTaskClient(_m.config).QueryProjectTasks(_m)
|
||||
}
|
||||
|
||||
// QueryGitTasks queries the "git_tasks" edge of the Task entity.
|
||||
func (_m *Task) QueryGitTasks() *GitTaskQuery {
|
||||
return NewTaskClient(_m.config).QueryGitTasks(_m)
|
||||
}
|
||||
|
||||
// QueryUser queries the "user" edge of the Task entity.
|
||||
func (_m *Task) QueryUser() *UserQuery {
|
||||
return NewTaskClient(_m.config).QueryUser(_m)
|
||||
|
||||
@@ -43,6 +43,8 @@ const (
|
||||
FieldCompletedAt = "completed_at"
|
||||
// EdgeProjectTasks holds the string denoting the project_tasks edge name in mutations.
|
||||
EdgeProjectTasks = "project_tasks"
|
||||
// EdgeGitTasks holds the string denoting the git_tasks edge name in mutations.
|
||||
EdgeGitTasks = "git_tasks"
|
||||
// EdgeUser holds the string denoting the user edge name in mutations.
|
||||
EdgeUser = "user"
|
||||
// EdgeVms holds the string denoting the vms edge name in mutations.
|
||||
@@ -62,6 +64,13 @@ const (
|
||||
ProjectTasksInverseTable = "project_tasks"
|
||||
// ProjectTasksColumn is the table column denoting the project_tasks relation/edge.
|
||||
ProjectTasksColumn = "task_id"
|
||||
// GitTasksTable is the table that holds the git_tasks relation/edge.
|
||||
GitTasksTable = "git_tasks"
|
||||
// GitTasksInverseTable is the table name for the GitTask entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "gittask" package.
|
||||
GitTasksInverseTable = "git_tasks"
|
||||
// GitTasksColumn is the table column denoting the git_tasks relation/edge.
|
||||
GitTasksColumn = "task_id"
|
||||
// UserTable is the table that holds the user relation/edge.
|
||||
UserTable = "tasks"
|
||||
// UserInverseTable is the table name for the User entity.
|
||||
@@ -238,6 +247,13 @@ func ByProjectTasks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
}
|
||||
}
|
||||
|
||||
// ByGitTasksField orders the results by git_tasks field.
|
||||
func ByGitTasksField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newGitTasksStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
|
||||
// ByUserField orders the results by user field.
|
||||
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
@@ -307,6 +323,13 @@ func newProjectTasksStep() *sqlgraph.Step {
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ProjectTasksTable, ProjectTasksColumn),
|
||||
)
|
||||
}
|
||||
func newGitTasksStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(GitTasksInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, GitTasksTable, GitTasksColumn),
|
||||
)
|
||||
}
|
||||
func newUserStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
|
||||
@@ -960,6 +960,29 @@ func HasProjectTasksWith(preds ...predicate.ProjectTask) predicate.Task {
|
||||
})
|
||||
}
|
||||
|
||||
// HasGitTasks applies the HasEdge predicate on the "git_tasks" edge.
|
||||
func HasGitTasks() predicate.Task {
|
||||
return predicate.Task(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, GitTasksTable, GitTasksColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasGitTasksWith applies the HasEdge predicate on the "git_tasks" edge with a given conditions (other predicates).
|
||||
func HasGitTasksWith(preds ...predicate.GitTask) predicate.Task {
|
||||
return predicate.Task(func(s *sql.Selector) {
|
||||
step := newGitTasksStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasUser applies the HasEdge predicate on the "user" edge.
|
||||
func HasUser() predicate.Task {
|
||||
return predicate.Task(func(s *sql.Selector) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/chaitin/MonkeyCode/backend/consts"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/task"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch"
|
||||
@@ -202,6 +203,25 @@ func (_c *TaskCreate) AddProjectTasks(v ...*ProjectTask) *TaskCreate {
|
||||
return _c.AddProjectTaskIDs(ids...)
|
||||
}
|
||||
|
||||
// SetGitTasksID sets the "git_tasks" edge to the GitTask entity by ID.
|
||||
func (_c *TaskCreate) SetGitTasksID(id uuid.UUID) *TaskCreate {
|
||||
_c.mutation.SetGitTasksID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableGitTasksID sets the "git_tasks" edge to the GitTask entity by ID if the given value is not nil.
|
||||
func (_c *TaskCreate) SetNillableGitTasksID(id *uuid.UUID) *TaskCreate {
|
||||
if id != nil {
|
||||
_c = _c.SetGitTasksID(*id)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGitTasks sets the "git_tasks" edge to the GitTask entity.
|
||||
func (_c *TaskCreate) SetGitTasks(v *GitTask) *TaskCreate {
|
||||
return _c.SetGitTasksID(v.ID)
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (_c *TaskCreate) SetUser(v *User) *TaskCreate {
|
||||
return _c.SetUserID(v.ID)
|
||||
@@ -459,6 +479,22 @@ func (_c *TaskCreate) createSpec() (*Task, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.GitTasksIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
Table: task.GitTasksTable,
|
||||
Columns: []string{task.GitTasksColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/task"
|
||||
@@ -32,6 +33,7 @@ type TaskQuery struct {
|
||||
inters []Interceptor
|
||||
predicates []predicate.Task
|
||||
withProjectTasks *ProjectTaskQuery
|
||||
withGitTasks *GitTaskQuery
|
||||
withUser *UserQuery
|
||||
withVms *VirtualMachineQuery
|
||||
withGitBotTasks *GitBotTaskQuery
|
||||
@@ -96,6 +98,28 @@ func (_q *TaskQuery) QueryProjectTasks() *ProjectTaskQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryGitTasks chains the current query on the "git_tasks" edge.
|
||||
func (_q *TaskQuery) QueryGitTasks() *GitTaskQuery {
|
||||
query := (&GitTaskClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(task.Table, task.FieldID, selector),
|
||||
sqlgraph.To(gittask.Table, gittask.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, task.GitTasksTable, task.GitTasksColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUser chains the current query on the "user" edge.
|
||||
func (_q *TaskQuery) QueryUser() *UserQuery {
|
||||
query := (&UserClient{config: _q.config}).Query()
|
||||
@@ -399,6 +423,7 @@ func (_q *TaskQuery) Clone() *TaskQuery {
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Task{}, _q.predicates...),
|
||||
withProjectTasks: _q.withProjectTasks.Clone(),
|
||||
withGitTasks: _q.withGitTasks.Clone(),
|
||||
withUser: _q.withUser.Clone(),
|
||||
withVms: _q.withVms.Clone(),
|
||||
withGitBotTasks: _q.withGitBotTasks.Clone(),
|
||||
@@ -422,6 +447,17 @@ func (_q *TaskQuery) WithProjectTasks(opts ...func(*ProjectTaskQuery)) *TaskQuer
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithGitTasks tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "git_tasks" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *TaskQuery) WithGitTasks(opts ...func(*GitTaskQuery)) *TaskQuery {
|
||||
query := (&GitTaskClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withGitTasks = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithUser tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "user" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *TaskQuery) WithUser(opts ...func(*UserQuery)) *TaskQuery {
|
||||
@@ -555,8 +591,9 @@ func (_q *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e
|
||||
var (
|
||||
nodes = []*Task{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [6]bool{
|
||||
loadedTypes = [7]bool{
|
||||
_q.withProjectTasks != nil,
|
||||
_q.withGitTasks != nil,
|
||||
_q.withUser != nil,
|
||||
_q.withVms != nil,
|
||||
_q.withGitBotTasks != nil,
|
||||
@@ -592,6 +629,12 @@ func (_q *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withGitTasks; query != nil {
|
||||
if err := _q.loadGitTasks(ctx, query, nodes, nil,
|
||||
func(n *Task, e *GitTask) { n.Edges.GitTasks = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withUser; query != nil {
|
||||
if err := _q.loadUser(ctx, query, nodes, nil,
|
||||
func(n *Task, e *User) { n.Edges.User = e }); err != nil {
|
||||
@@ -659,6 +702,33 @@ func (_q *TaskQuery) loadProjectTasks(ctx context.Context, query *ProjectTaskQue
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *TaskQuery) loadGitTasks(ctx context.Context, query *GitTaskQuery, nodes []*Task, init func(*Task), assign func(*Task, *GitTask)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Task)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
}
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(gittask.FieldTaskID)
|
||||
}
|
||||
query.Where(predicate.GitTask(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(task.GitTasksColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.TaskID
|
||||
node, ok := nodeids[fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "task_id" returned %v for node %v`, fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *TaskQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Task, init func(*Task), assign func(*Task, *User)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Task)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/chaitin/MonkeyCode/backend/consts"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
||||
"github.com/chaitin/MonkeyCode/backend/db/task"
|
||||
@@ -262,6 +263,25 @@ func (_u *TaskUpdate) AddProjectTasks(v ...*ProjectTask) *TaskUpdate {
|
||||
return _u.AddProjectTaskIDs(ids...)
|
||||
}
|
||||
|
||||
// SetGitTasksID sets the "git_tasks" edge to the GitTask entity by ID.
|
||||
func (_u *TaskUpdate) SetGitTasksID(id uuid.UUID) *TaskUpdate {
|
||||
_u.mutation.SetGitTasksID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGitTasksID sets the "git_tasks" edge to the GitTask entity by ID if the given value is not nil.
|
||||
func (_u *TaskUpdate) SetNillableGitTasksID(id *uuid.UUID) *TaskUpdate {
|
||||
if id != nil {
|
||||
_u = _u.SetGitTasksID(*id)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGitTasks sets the "git_tasks" edge to the GitTask entity.
|
||||
func (_u *TaskUpdate) SetGitTasks(v *GitTask) *TaskUpdate {
|
||||
return _u.SetGitTasksID(v.ID)
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (_u *TaskUpdate) SetUser(v *User) *TaskUpdate {
|
||||
return _u.SetUserID(v.ID)
|
||||
@@ -353,6 +373,12 @@ func (_u *TaskUpdate) RemoveProjectTasks(v ...*ProjectTask) *TaskUpdate {
|
||||
return _u.RemoveProjectTaskIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearGitTasks clears the "git_tasks" edge to the GitTask entity.
|
||||
func (_u *TaskUpdate) ClearGitTasks() *TaskUpdate {
|
||||
_u.mutation.ClearGitTasks()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUser clears the "user" edge to the User entity.
|
||||
func (_u *TaskUpdate) ClearUser() *TaskUpdate {
|
||||
_u.mutation.ClearUser()
|
||||
@@ -615,6 +641,35 @@ func (_u *TaskUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.GitTasksCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
Table: task.GitTasksTable,
|
||||
Columns: []string{task.GitTasksColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.GitTasksIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
Table: task.GitTasksTable,
|
||||
Columns: []string{task.GitTasksColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
@@ -1083,6 +1138,25 @@ func (_u *TaskUpdateOne) AddProjectTasks(v ...*ProjectTask) *TaskUpdateOne {
|
||||
return _u.AddProjectTaskIDs(ids...)
|
||||
}
|
||||
|
||||
// SetGitTasksID sets the "git_tasks" edge to the GitTask entity by ID.
|
||||
func (_u *TaskUpdateOne) SetGitTasksID(id uuid.UUID) *TaskUpdateOne {
|
||||
_u.mutation.SetGitTasksID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGitTasksID sets the "git_tasks" edge to the GitTask entity by ID if the given value is not nil.
|
||||
func (_u *TaskUpdateOne) SetNillableGitTasksID(id *uuid.UUID) *TaskUpdateOne {
|
||||
if id != nil {
|
||||
_u = _u.SetGitTasksID(*id)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGitTasks sets the "git_tasks" edge to the GitTask entity.
|
||||
func (_u *TaskUpdateOne) SetGitTasks(v *GitTask) *TaskUpdateOne {
|
||||
return _u.SetGitTasksID(v.ID)
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (_u *TaskUpdateOne) SetUser(v *User) *TaskUpdateOne {
|
||||
return _u.SetUserID(v.ID)
|
||||
@@ -1174,6 +1248,12 @@ func (_u *TaskUpdateOne) RemoveProjectTasks(v ...*ProjectTask) *TaskUpdateOne {
|
||||
return _u.RemoveProjectTaskIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearGitTasks clears the "git_tasks" edge to the GitTask entity.
|
||||
func (_u *TaskUpdateOne) ClearGitTasks() *TaskUpdateOne {
|
||||
_u.mutation.ClearGitTasks()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUser clears the "user" edge to the User entity.
|
||||
func (_u *TaskUpdateOne) ClearUser() *TaskUpdateOne {
|
||||
_u.mutation.ClearUser()
|
||||
@@ -1466,6 +1546,35 @@ func (_u *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.GitTasksCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
Table: task.GitTasksTable,
|
||||
Columns: []string{task.GitTasksColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.GitTasksIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
Table: task.GitTasksTable,
|
||||
Columns: []string{task.GitTasksColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
||||
@@ -24,6 +24,8 @@ type Tx struct {
|
||||
GitBotUser *GitBotUserClient
|
||||
// GitIdentity is the client for interacting with the GitIdentity builders.
|
||||
GitIdentity *GitIdentityClient
|
||||
// GitTask is the client for interacting with the GitTask builders.
|
||||
GitTask *GitTaskClient
|
||||
// Host is the client for interacting with the Host builders.
|
||||
Host *HostClient
|
||||
// Image is the client for interacting with the Image builders.
|
||||
@@ -228,6 +230,7 @@ func (tx *Tx) init() {
|
||||
tx.GitBotTask = NewGitBotTaskClient(tx.config)
|
||||
tx.GitBotUser = NewGitBotUserClient(tx.config)
|
||||
tx.GitIdentity = NewGitIdentityClient(tx.config)
|
||||
tx.GitTask = NewGitTaskClient(tx.config)
|
||||
tx.Host = NewHostClient(tx.config)
|
||||
tx.Image = NewImageClient(tx.config)
|
||||
tx.MCPTool = NewMCPToolClient(tx.config)
|
||||
|
||||
@@ -18,7 +18,7 @@ type GitTaskUsecase interface {
|
||||
|
||||
// GitTaskRepoInterface GitTask 数据访问接口
|
||||
type GitTaskRepoInterface interface {
|
||||
Create(ctx context.Context, req CreateGitTaskReq, fn func(user *db.User, t *db.Task, m *db.Model, i *db.Image) (*taskflow.VirtualMachine, error)) (*db.Task, error)
|
||||
Create(ctx context.Context, req CreateGitTaskReq, fn func(user *db.User, t *db.Task, m *db.Model) (*taskflow.VirtualMachine, error)) (*db.Task, error)
|
||||
}
|
||||
|
||||
// CreateGitTaskReq 创建 GitTask 请求
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type GitTask struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (GitTask) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Table("git_tasks"),
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the GitTask.
|
||||
func (GitTask) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.UUID("id", uuid.UUID{}),
|
||||
field.UUID("task_id", uuid.UUID{}),
|
||||
field.UUID("repo_id", uuid.UUID{}).Optional(),
|
||||
field.String("subject_type").NotEmpty(),
|
||||
field.String("subject_id").Optional(),
|
||||
field.Int("subject_number").Optional(),
|
||||
field.String("subject_url").Optional(),
|
||||
field.String("subject_title").Optional(),
|
||||
field.String("prompt_id").Optional(),
|
||||
field.Text("show_url").Optional(),
|
||||
field.Int64("github_installation_id").Optional(),
|
||||
field.Time("created_at").Default(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the GitTask.
|
||||
func (GitTask) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("task", Task.Type).Ref("git_tasks").Field("task_id").Unique().Required(),
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ func (Task) Fields() []ent.Field {
|
||||
func (Task) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("project_tasks", ProjectTask.Type),
|
||||
edge.To("git_tasks", GitTask.Type).Unique(),
|
||||
edge.From("user", User.Type).Ref("tasks").Field("user_id").Unique().Required(),
|
||||
edge.From("vms", VirtualMachine.Type).Through("task_vms", TaskVirtualMachine.Type).Ref("tasks"),
|
||||
edge.To("git_bot_tasks", GitBotTask.Type),
|
||||
|
||||
@@ -51,6 +51,7 @@ func TaskConcurrencyHook(next ent.Mutator) ent.Mutator {
|
||||
Where(
|
||||
task.UserIDEQ(userID),
|
||||
task.StatusIn(consts.TaskStatusPending, consts.TaskStatusProcessing),
|
||||
task.HasProjectTasks(),
|
||||
).
|
||||
Count(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
)
|
||||
@@ -25,12 +26,20 @@ func NewLogger(cfg *Config) *slog.Logger {
|
||||
level.Set(slog.LevelWarn)
|
||||
}
|
||||
base := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: level,
|
||||
Level: level,
|
||||
ReplaceAttr: replaceAttr,
|
||||
})
|
||||
handler := &ContextLogger{Handler: base}
|
||||
return slog.New(handler)
|
||||
}
|
||||
|
||||
func replaceAttr(_ []string, attr slog.Attr) slog.Attr {
|
||||
if err, ok := attr.Value.Any().(error); ok && err != nil && err.Error() == "" {
|
||||
attr.Value = slog.StringValue(fmt.Sprintf("%T", err))
|
||||
}
|
||||
return attr
|
||||
}
|
||||
|
||||
func SetLevel(lv string) {
|
||||
switch lv {
|
||||
case "debug":
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type emptyError struct{}
|
||||
|
||||
func (emptyError) Error() string { return "" }
|
||||
|
||||
func TestReplaceAttrKeepsEmptyErrorVisible(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
l := slog.New(slog.NewJSONHandler(&buf, &slog.HandlerOptions{
|
||||
ReplaceAttr: replaceAttr,
|
||||
}))
|
||||
|
||||
l.Error("failed", "error", emptyError{})
|
||||
|
||||
var got map[string]any
|
||||
if err := json.Unmarshal(buf.Bytes(), &got); err != nil {
|
||||
t.Fatalf("unmarshal log: %v", err)
|
||||
}
|
||||
if got["error"] == "" {
|
||||
t.Fatal("error attr is empty")
|
||||
}
|
||||
if got["error"] != "logger.emptyError" {
|
||||
t.Fatalf("error attr = %v, want logger.emptyError", got["error"])
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user