From e11caf79ab9eeffc14999b9effa150d5588a6480 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Fri, 21 Aug 2026 13:26:39 +0200 Subject: [PATCH 1/2] registration form database schema changes --- components/backend/Schema.md | 61 + components/backend/db/schema/answer.go | 74 + components/backend/db/schema/hackathon.go | 2 + components/backend/db/schema/question.go | 85 + components/backend/db/schema/user.go | 9 + components/backend/ent/answer.go | 210 + components/backend/ent/answer/answer.go | 172 + components/backend/ent/answer/where.go | 348 + components/backend/ent/answer_create.go | 352 + components/backend/ent/answer_delete.go | 88 + components/backend/ent/answer_query.go | 682 ++ components/backend/ent/answer_update.go | 537 + components/backend/ent/client.go | 466 +- components/backend/ent/ent.go | 4 + components/backend/ent/hackathon.go | 26 +- components/backend/ent/hackathon/hackathon.go | 30 + components/backend/ent/hackathon/where.go | 23 + components/backend/ent/hackathon_create.go | 32 + components/backend/ent/hackathon_query.go | 77 +- components/backend/ent/hackathon_update.go | 163 + components/backend/ent/hook/hook.go | 24 + components/backend/ent/migrate/schema.go | 96 + components/backend/ent/mutation.go | 9173 ++++++++++------- components/backend/ent/predicate/predicate.go | 6 + components/backend/ent/question.go | 290 + components/backend/ent/question/question.go | 259 + components/backend/ent/question/where.go | 494 + components/backend/ent/question_create.go | 480 + components/backend/ent/question_delete.go | 88 + components/backend/ent/question_query.go | 839 ++ components/backend/ent/question_update.go | 822 ++ components/backend/ent/runtime/runtime.go | 52 + components/backend/ent/tx.go | 8 +- components/backend/ent/user.go | 64 +- components/backend/ent/user/user.go | 90 + components/backend/ent/user/where.go | 69 + components/backend/ent/user_create.go | 95 + components/backend/ent/user_query.go | 225 +- components/backend/ent/user_update.go | 488 + components/backend/go.sum | 26 + 40 files changed, 13536 insertions(+), 3593 deletions(-) create mode 100644 components/backend/db/schema/answer.go create mode 100644 components/backend/db/schema/question.go create mode 100644 components/backend/ent/answer.go create mode 100644 components/backend/ent/answer/answer.go create mode 100644 components/backend/ent/answer/where.go create mode 100644 components/backend/ent/answer_create.go create mode 100644 components/backend/ent/answer_delete.go create mode 100644 components/backend/ent/answer_query.go create mode 100644 components/backend/ent/answer_update.go create mode 100644 components/backend/ent/question.go create mode 100644 components/backend/ent/question/question.go create mode 100644 components/backend/ent/question/where.go create mode 100644 components/backend/ent/question_create.go create mode 100644 components/backend/ent/question_delete.go create mode 100644 components/backend/ent/question_query.go create mode 100644 components/backend/ent/question_update.go diff --git a/components/backend/Schema.md b/components/backend/Schema.md index 0d76626b..50b17bee 100644 --- a/components/backend/Schema.md +++ b/components/backend/Schema.md @@ -1,5 +1,31 @@ # Database Schema +## Answer + +A participant's answer to a registration question. One answer per user per question. + +### Fields + +| Column | Type | Required | Unique | Immutable | Default | Description | +|--------|------|----------|--------|-----------|---------|-------------| +| `question_id` | uuid.UUID | yes | no | no | no | The question this answer belongs to. | +| `user_id` | uuid.UUID | yes | no | no | no | The user who submitted this answer. | +| `value` | string | yes | no | no | no | The answer value. For bool questions, stored as "true" or "false". | +| `type` | enum(text, bool) | yes | no | no | no | The type of the question (for readability when reading answers). | +| `created_at` | time.Time | yes | no | yes | yes | Timestamp when the answer was first submitted. | +| `updated_at` | time.Time | yes | no | no | yes | Timestamp of the last update. | + +### Relationships + +| Edge | Target | Relation | Inverse | Required | Description | +|------|--------|----------|---------|----------|-------------| +| `question` | Question | M2O | yes | yes | The question this answer belongs to. | +| `user` | User | M2O | yes | yes | The user who submitted this answer. | + +### Indexes + +- `question_id, user_id` *(unique)* + ## Hackathon A hackathon event containing tracks, projects, phases, and participants. @@ -28,6 +54,7 @@ A hackathon event containing tracks, projects, phases, and participants. | `phases` | Phase | O2M | no | no | Temporal phases (e.g. ideation, hacking, judging). | | `state` | HackathonState | O2O | no | no | Configuration state for this hackathon. | | `vote_categories` | VoteCategory | O2M | no | no | Voting categories scoped to this hackathon. | +| `questions` | Question | O2M | no | no | Registration questions configured for this hackathon. | | `owners` | User | M2M | no | no | Users who are owners of this hackathon (in addition to the creator). | | `creator` | User | M2O | yes | yes | The user who created this hackathon. | | `modifier` | User | M2O | yes | yes | The user who last modified this hackathon. | @@ -184,6 +211,37 @@ A project proposal within a hackathon track. - `title` - `status` +## Question + +A registration question configured by a hackathon owner. + +### Fields + +| Column | Type | Required | Unique | Immutable | Default | Description | +|--------|------|----------|--------|-----------|---------|-------------| +| `hackathon_id` | uuid.UUID | yes | no | no | no | The hackathon this question belongs to. | +| `key` | string | yes | no | no | no | Unique identifier for the question within the hackathon. | +| `label` | string | yes | no | no | no | Display label for the question. | +| `type` | enum(text, bool) | yes | no | no | no | The type of answer expected from participants. | +| `mandatory` | bool | yes | no | no | yes | Whether the participant must answer this question to join. | +| `order` | int | yes | no | no | yes | Display order; lower values appear first. | +| `created_at` | time.Time | yes | no | yes | yes | Timestamp when the question was created. | +| `modified_at` | time.Time | yes | no | no | yes | Timestamp of the last modification. | + +### Relationships + +| Edge | Target | Relation | Inverse | Required | Description | +|------|--------|----------|---------|----------|-------------| +| `hackathon` | Hackathon | M2O | yes | yes | The hackathon this question belongs to. | +| `creator` | User | M2O | yes | yes | The user who created the question. | +| `modifier` | User | M2O | yes | yes | The user who last modified the question. | +| `answers` | Answer | O2M | no | no | Answers submitted by participants for this question. | + +### Indexes + +- `key, hackathon_id` *(unique)* +- `order` + ## Submission A versioned submission from a team for a project. @@ -317,6 +375,9 @@ An authenticated user, synced from Keycloak on first login. | `modified_submissions` | Submission | O2M | no | no | Submissions this user last modified. | | `created_tracks` | Track | O2M | no | no | Tracks this user created. | | `modified_tracks` | Track | O2M | no | no | Tracks this user last modified. | +| `created_questions` | Question | O2M | no | no | Registration questions this user created. | +| `modified_questions` | Question | O2M | no | no | Registration questions this user last modified. | +| `created_answers` | Answer | O2M | no | no | Registration answers this user submitted. | | `modified_states` | HackathonState | O2M | no | no | Hackathon settings this user last modified. | | `preferred_projects` | Project | M2M | no | no | Projects this user has marked as preferred. | | `votes` | Vote | O2M | no | no | Votes cast by this user. | diff --git a/components/backend/db/schema/answer.go b/components/backend/db/schema/answer.go new file mode 100644 index 00000000..363f86dd --- /dev/null +++ b/components/backend/db/schema/answer.go @@ -0,0 +1,74 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" +) + +// Answer holds the schema definition for a participant's answer to a registration question. +type Answer struct { + ent.Schema +} + +func (Answer) Annotations() []schema.Annotation { + return []schema.Annotation{ + schema.Comment( + "A participant's answer to a registration question. One answer per user per question.", + ), + } +} + +// Fields of the Answer. +func (Answer) Fields() []ent.Field { + return []ent.Field{ + field.UUID("question_id", uuid.UUID{}). + Comment("The question this answer belongs to."), + field.UUID("user_id", uuid.UUID{}). + Comment("The user who submitted this answer."), + field.String("value"). + Comment("The answer value. For bool questions, stored as \"true\" or \"false\"."), + field.Enum("type"). + Values("text", "bool"). + Comment("The type of the question (for readability when reading answers)."), + field.Time("created_at"). + Immutable(). + Default(time.Now). + Comment("Timestamp when the answer was first submitted."), + field.Time("updated_at"). + Default(time.Now).UpdateDefault(time.Now). + Comment("Timestamp of the last update."), + } +} + +// Edges of the Answer. +func (Answer) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("question", Question.Type). + Ref("answers").Unique().Required(). + Field("question_id"). + Comment("The question this answer belongs to."), + edge.From("user", User.Type). + Ref("created_answers").Unique().Required(). + Field("user_id"). + Comment("The user who submitted this answer."), + } +} + +// Indexes of the Answer. +func (Answer) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("question_id", "user_id").Unique(), + } +} + +func (Answer) Mixin() []ent.Mixin { + return []ent.Mixin{ + UUIDMixin{}, + } +} diff --git a/components/backend/db/schema/hackathon.go b/components/backend/db/schema/hackathon.go index 74f9b348..294b5af1 100644 --- a/components/backend/db/schema/hackathon.go +++ b/components/backend/db/schema/hackathon.go @@ -69,6 +69,8 @@ func (Hackathon) Edges() []ent.Edge { Comment("Configuration state for this hackathon."), edge.To("vote_categories", VoteCategory.Type). Comment("Voting categories scoped to this hackathon."), + edge.To("questions", Question.Type). + Comment("Registration questions configured for this hackathon."), edge.To("owners", User.Type). Comment("Users who are owners of this hackathon (in addition to the creator)."), edge.From("creator", User.Type). diff --git a/components/backend/db/schema/question.go b/components/backend/db/schema/question.go new file mode 100644 index 00000000..01416fbe --- /dev/null +++ b/components/backend/db/schema/question.go @@ -0,0 +1,85 @@ +package schema + +import ( + "regexp" + "time" + + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" +) + +// Question holds the schema definition for the registration question entity. +type Question struct { + ent.Schema +} + +func (Question) Annotations() []schema.Annotation { + return []schema.Annotation{ + schema.Comment("A registration question configured by a hackathon owner."), + } +} + +// Fields of the Question. +func (Question) Fields() []ent.Field { + return []ent.Field{ + field.UUID("hackathon_id", uuid.UUID{}). + Comment("The hackathon this question belongs to."), + field.String("key"). + Match(regexp.MustCompile(`^[a-z][a-z0-9_]*$`)). + Comment("Unique identifier for the question within the hackathon."), + field.String("label"). + Comment("Display label for the question."), + field.Enum("type"). + Values("text", "bool"). + Comment("The type of answer expected from participants."), + field.Bool("mandatory"). + Default(false). + Comment("Whether the participant must answer this question to join."), + field.Int("order"). + Default(0). + Comment("Display order; lower values appear first."), + field.Time("created_at"). + Immutable(). + Default(time.Now). + Comment("Timestamp when the question was created."), + field.Time("modified_at"). + Default(time.Now).UpdateDefault(time.Now). + Comment("Timestamp of the last modification."), + } +} + +// Edges of the Question. +func (Question) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("hackathon", Hackathon.Type). + Ref("questions").Unique().Required(). + Field("hackathon_id"). + Comment("The hackathon this question belongs to."), + edge.From("creator", User.Type). + Ref("created_questions").Unique().Required().Immutable(). + Comment("The user who created the question."), + edge.From("modifier", User.Type). + Ref("modified_questions").Unique().Required(). + Comment("The user who last modified the question."), + edge.To("answers", Answer.Type). + Comment("Answers submitted by participants for this question."), + } +} + +// Indexes of the Question. +func (Question) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("key", "hackathon_id").Unique(), + index.Fields("order"), + } +} + +func (Question) Mixin() []ent.Mixin { + return []ent.Mixin{ + UUIDMixin{}, + } +} diff --git a/components/backend/db/schema/user.go b/components/backend/db/schema/user.go index e49fe899..28ebc9de 100644 --- a/components/backend/db/schema/user.go +++ b/components/backend/db/schema/user.go @@ -91,6 +91,15 @@ func (User) Edges() []ent.Edge { edge.To("modified_tracks", Track.Type). Annotations(entsql.OnDelete(entsql.Restrict)). Comment("Tracks this user last modified."), + edge.To("created_questions", Question.Type). + Annotations(entsql.OnDelete(entsql.Restrict)). + Comment("Registration questions this user created."), + edge.To("modified_questions", Question.Type). + Annotations(entsql.OnDelete(entsql.Restrict)). + Comment("Registration questions this user last modified."), + edge.To("created_answers", Answer.Type). + Annotations(entsql.OnDelete(entsql.Restrict)). + Comment("Registration answers this user submitted."), edge.To("modified_states", HackathonState.Type). Annotations(entsql.OnDelete(entsql.Restrict)). Comment("Hackathon settings this user last modified."), diff --git a/components/backend/ent/answer.go b/components/backend/ent/answer.go new file mode 100644 index 00000000..d194a037 --- /dev/null +++ b/components/backend/ent/answer.go @@ -0,0 +1,210 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// A participant's answer to a registration question. One answer per user per question. +type Answer struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // The question this answer belongs to. + QuestionID uuid.UUID `json:"question_id,omitempty"` + // The user who submitted this answer. + UserID uuid.UUID `json:"user_id,omitempty"` + // The answer value. For bool questions, stored as "true" or "false". + Value string `json:"value,omitempty"` + // The type of the question (for readability when reading answers). + Type answer.Type `json:"type,omitempty"` + // Timestamp when the answer was first submitted. + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of the last update. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AnswerQuery when eager-loading is set. + Edges AnswerEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AnswerEdges holds the relations/edges for other nodes in the graph. +type AnswerEdges struct { + // The question this answer belongs to. + Question *Question `json:"question,omitempty"` + // The user who submitted this answer. + User *User `json:"user,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// QuestionOrErr returns the Question value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e AnswerEdges) QuestionOrErr() (*Question, error) { + if e.Question != nil { + return e.Question, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: question.Label} + } + return nil, &NotLoadedError{edge: "question"} +} + +// 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 AnswerEdges) UserOrErr() (*User, error) { + if e.User != nil { + return e.User, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: user.Label} + } + return nil, &NotLoadedError{edge: "user"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Answer) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case answer.FieldValue, answer.FieldType: + values[i] = new(sql.NullString) + case answer.FieldCreatedAt, answer.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case answer.FieldID, answer.FieldQuestionID, answer.FieldUserID: + 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 Answer fields. +func (_m *Answer) 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 answer.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 answer.FieldQuestionID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field question_id", values[i]) + } else if value != nil { + _m.QuestionID = *value + } + case answer.FieldUserID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value != nil { + _m.UserID = *value + } + case answer.FieldValue: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field value", values[i]) + } else if value.Valid { + _m.Value = value.String + } + case answer.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = answer.Type(value.String) + } + case answer.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 + } + case answer.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// GetValue returns the ent.Value that was dynamically selected and assigned to the Answer. +// This includes values selected through modifiers, order, etc. +func (_m *Answer) GetValue(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryQuestion queries the "question" edge of the Answer entity. +func (_m *Answer) QueryQuestion() *QuestionQuery { + return NewAnswerClient(_m.config).QueryQuestion(_m) +} + +// QueryUser queries the "user" edge of the Answer entity. +func (_m *Answer) QueryUser() *UserQuery { + return NewAnswerClient(_m.config).QueryUser(_m) +} + +// Update returns a builder for updating this Answer. +// Note that you need to call Answer.Unwrap() before calling this method if this Answer +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *Answer) Update() *AnswerUpdateOne { + return NewAnswerClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the Answer 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 *Answer) Unwrap() *Answer { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: Answer is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *Answer) String() string { + var builder strings.Builder + builder.WriteString("Answer(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("question_id=") + builder.WriteString(fmt.Sprintf("%v", _m.QuestionID)) + builder.WriteString(", ") + builder.WriteString("user_id=") + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) + builder.WriteString(", ") + builder.WriteString("value=") + builder.WriteString(_m.Value) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", _m.Type)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// Answers is a parsable slice of Answer. +type Answers []*Answer diff --git a/components/backend/ent/answer/answer.go b/components/backend/ent/answer/answer.go new file mode 100644 index 00000000..1e1166fd --- /dev/null +++ b/components/backend/ent/answer/answer.go @@ -0,0 +1,172 @@ +// Code generated by ent, DO NOT EDIT. + +package answer + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the answer type in the database. + Label = "answer" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldQuestionID holds the string denoting the question_id field in the database. + FieldQuestionID = "question_id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldValue holds the string denoting the value field in the database. + FieldValue = "value" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // EdgeQuestion holds the string denoting the question edge name in mutations. + EdgeQuestion = "question" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // Table holds the table name of the answer in the database. + Table = "answers" + // QuestionTable is the table that holds the question relation/edge. + QuestionTable = "answers" + // QuestionInverseTable is the table name for the Question entity. + // It exists in this package in order to avoid circular dependency with the "question" package. + QuestionInverseTable = "questions" + // QuestionColumn is the table column denoting the question relation/edge. + QuestionColumn = "question_id" + // UserTable is the table that holds the user relation/edge. + UserTable = "answers" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" +) + +// Columns holds all SQL columns for answer fields. +var Columns = []string{ + FieldID, + FieldQuestionID, + FieldUserID, + FieldValue, + FieldType, + FieldCreatedAt, + FieldUpdatedAt, +} + +// 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 ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// Type defines the type for the "type" enum field. +type Type string + +// Type values. +const ( + TypeText Type = "text" + TypeBool Type = "bool" +) + +func (_type Type) String() string { + return string(_type) +} + +// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save. +func TypeValidator(_type Type) error { + switch _type { + case TypeText, TypeBool: + return nil + default: + return fmt.Errorf("answer: invalid enum value for type field: %q", _type) + } +} + +// OrderOption defines the ordering options for the Answer 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() +} + +// ByQuestionID orders the results by the question_id field. +func ByQuestionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldQuestionID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByValue orders the results by the value field. +func ByValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldValue, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByQuestionField orders the results by question field. +func ByQuestionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newQuestionStep(), sql.OrderByField(field, opts...)) + } +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} +func newQuestionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(QuestionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, QuestionTable, QuestionColumn), + ) +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) +} diff --git a/components/backend/ent/answer/where.go b/components/backend/ent/answer/where.go new file mode 100644 index 00000000..be5bd6a6 --- /dev/null +++ b/components/backend/ent/answer/where.go @@ -0,0 +1,348 @@ +// Code generated by ent, DO NOT EDIT. + +package answer + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldLTE(FieldID, id)) +} + +// QuestionID applies equality check predicate on the "question_id" field. It's identical to QuestionIDEQ. +func QuestionID(v uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldQuestionID, v)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldUserID, v)) +} + +// Value applies equality check predicate on the "value" field. It's identical to ValueEQ. +func Value(v string) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldValue, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// QuestionIDEQ applies the EQ predicate on the "question_id" field. +func QuestionIDEQ(v uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldQuestionID, v)) +} + +// QuestionIDNEQ applies the NEQ predicate on the "question_id" field. +func QuestionIDNEQ(v uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldNEQ(FieldQuestionID, v)) +} + +// QuestionIDIn applies the In predicate on the "question_id" field. +func QuestionIDIn(vs ...uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldIn(FieldQuestionID, vs...)) +} + +// QuestionIDNotIn applies the NotIn predicate on the "question_id" field. +func QuestionIDNotIn(vs ...uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldNotIn(FieldQuestionID, vs...)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...uuid.UUID) predicate.Answer { + return predicate.Answer(sql.FieldNotIn(FieldUserID, vs...)) +} + +// ValueEQ applies the EQ predicate on the "value" field. +func ValueEQ(v string) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldValue, v)) +} + +// ValueNEQ applies the NEQ predicate on the "value" field. +func ValueNEQ(v string) predicate.Answer { + return predicate.Answer(sql.FieldNEQ(FieldValue, v)) +} + +// ValueIn applies the In predicate on the "value" field. +func ValueIn(vs ...string) predicate.Answer { + return predicate.Answer(sql.FieldIn(FieldValue, vs...)) +} + +// ValueNotIn applies the NotIn predicate on the "value" field. +func ValueNotIn(vs ...string) predicate.Answer { + return predicate.Answer(sql.FieldNotIn(FieldValue, vs...)) +} + +// ValueGT applies the GT predicate on the "value" field. +func ValueGT(v string) predicate.Answer { + return predicate.Answer(sql.FieldGT(FieldValue, v)) +} + +// ValueGTE applies the GTE predicate on the "value" field. +func ValueGTE(v string) predicate.Answer { + return predicate.Answer(sql.FieldGTE(FieldValue, v)) +} + +// ValueLT applies the LT predicate on the "value" field. +func ValueLT(v string) predicate.Answer { + return predicate.Answer(sql.FieldLT(FieldValue, v)) +} + +// ValueLTE applies the LTE predicate on the "value" field. +func ValueLTE(v string) predicate.Answer { + return predicate.Answer(sql.FieldLTE(FieldValue, v)) +} + +// ValueContains applies the Contains predicate on the "value" field. +func ValueContains(v string) predicate.Answer { + return predicate.Answer(sql.FieldContains(FieldValue, v)) +} + +// ValueHasPrefix applies the HasPrefix predicate on the "value" field. +func ValueHasPrefix(v string) predicate.Answer { + return predicate.Answer(sql.FieldHasPrefix(FieldValue, v)) +} + +// ValueHasSuffix applies the HasSuffix predicate on the "value" field. +func ValueHasSuffix(v string) predicate.Answer { + return predicate.Answer(sql.FieldHasSuffix(FieldValue, v)) +} + +// ValueEqualFold applies the EqualFold predicate on the "value" field. +func ValueEqualFold(v string) predicate.Answer { + return predicate.Answer(sql.FieldEqualFold(FieldValue, v)) +} + +// ValueContainsFold applies the ContainsFold predicate on the "value" field. +func ValueContainsFold(v string) predicate.Answer { + return predicate.Answer(sql.FieldContainsFold(FieldValue, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v Type) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v Type) predicate.Answer { + return predicate.Answer(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...Type) predicate.Answer { + return predicate.Answer(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...Type) predicate.Answer { + return predicate.Answer(sql.FieldNotIn(FieldType, vs...)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Answer { + return predicate.Answer(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Answer { + return predicate.Answer(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Answer { + return predicate.Answer(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Answer { + return predicate.Answer(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Answer { + return predicate.Answer(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// HasQuestion applies the HasEdge predicate on the "question" edge. +func HasQuestion() predicate.Answer { + return predicate.Answer(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, QuestionTable, QuestionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasQuestionWith applies the HasEdge predicate on the "question" edge with a given conditions (other predicates). +func HasQuestionWith(preds ...predicate.Question) predicate.Answer { + return predicate.Answer(func(s *sql.Selector) { + step := newQuestionStep() + 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.Answer { + return predicate.Answer(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.Answer { + return predicate.Answer(func(s *sql.Selector) { + step := newUserStep() + 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.Answer) predicate.Answer { + return predicate.Answer(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Answer) predicate.Answer { + return predicate.Answer(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Answer) predicate.Answer { + return predicate.Answer(sql.NotPredicates(p)) +} diff --git a/components/backend/ent/answer_create.go b/components/backend/ent/answer_create.go new file mode 100644 index 00000000..fffb3fdb --- /dev/null +++ b/components/backend/ent/answer_create.go @@ -0,0 +1,352 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// AnswerCreate is the builder for creating a Answer entity. +type AnswerCreate struct { + config + mutation *AnswerMutation + hooks []Hook +} + +// SetQuestionID sets the "question_id" field. +func (_c *AnswerCreate) SetQuestionID(v uuid.UUID) *AnswerCreate { + _c.mutation.SetQuestionID(v) + return _c +} + +// SetUserID sets the "user_id" field. +func (_c *AnswerCreate) SetUserID(v uuid.UUID) *AnswerCreate { + _c.mutation.SetUserID(v) + return _c +} + +// SetValue sets the "value" field. +func (_c *AnswerCreate) SetValue(v string) *AnswerCreate { + _c.mutation.SetValue(v) + return _c +} + +// SetType sets the "type" field. +func (_c *AnswerCreate) SetType(v answer.Type) *AnswerCreate { + _c.mutation.SetType(v) + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AnswerCreate) SetCreatedAt(v time.Time) *AnswerCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AnswerCreate) SetNillableCreatedAt(v *time.Time) *AnswerCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AnswerCreate) SetUpdatedAt(v time.Time) *AnswerCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AnswerCreate) SetNillableUpdatedAt(v *time.Time) *AnswerCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AnswerCreate) SetID(v uuid.UUID) *AnswerCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AnswerCreate) SetNillableID(v *uuid.UUID) *AnswerCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetQuestion sets the "question" edge to the Question entity. +func (_c *AnswerCreate) SetQuestion(v *Question) *AnswerCreate { + return _c.SetQuestionID(v.ID) +} + +// SetUser sets the "user" edge to the User entity. +func (_c *AnswerCreate) SetUser(v *User) *AnswerCreate { + return _c.SetUserID(v.ID) +} + +// Mutation returns the AnswerMutation object of the builder. +func (_c *AnswerCreate) Mutation() *AnswerMutation { + return _c.mutation +} + +// Save creates the Answer in the database. +func (_c *AnswerCreate) Save(ctx context.Context) (*Answer, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AnswerCreate) SaveX(ctx context.Context) *Answer { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AnswerCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AnswerCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AnswerCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := answer.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := answer.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := answer.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AnswerCreate) check() error { + if _, ok := _c.mutation.QuestionID(); !ok { + return &ValidationError{Name: "question_id", err: errors.New(`ent: missing required field "Answer.question_id"`)} + } + if _, ok := _c.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "Answer.user_id"`)} + } + if _, ok := _c.mutation.Value(); !ok { + return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "Answer.value"`)} + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Answer.type"`)} + } + if v, ok := _c.mutation.GetType(); ok { + if err := answer.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Answer.type": %w`, err)} + } + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Answer.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Answer.updated_at"`)} + } + if len(_c.mutation.QuestionIDs()) == 0 { + return &ValidationError{Name: "question", err: errors.New(`ent: missing required edge "Answer.question"`)} + } + if len(_c.mutation.UserIDs()) == 0 { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Answer.user"`)} + } + return nil +} + +func (_c *AnswerCreate) sqlSave(ctx context.Context) (*Answer, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AnswerCreate) createSpec() (*Answer, *sqlgraph.CreateSpec) { + var ( + _node = &Answer{config: _c.config} + _spec = sqlgraph.NewCreateSpec(answer.Table, sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Value(); ok { + _spec.SetField(answer.FieldValue, field.TypeString, value) + _node.Value = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(answer.FieldType, field.TypeEnum, value) + _node.Type = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(answer.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(answer.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if nodes := _c.mutation.QuestionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.QuestionTable, + Columns: []string{answer.QuestionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.QuestionID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.UserTable, + Columns: []string{answer.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.UserID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// AnswerCreateBulk is the builder for creating many Answer entities in bulk. +type AnswerCreateBulk struct { + config + err error + builders []*AnswerCreate +} + +// Save creates the Answer entities in the database. +func (_c *AnswerCreateBulk) Save(ctx context.Context) ([]*Answer, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Answer, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AnswerMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AnswerCreateBulk) SaveX(ctx context.Context) []*Answer { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AnswerCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AnswerCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/components/backend/ent/answer_delete.go b/components/backend/ent/answer_delete.go new file mode 100644 index 00000000..88acc443 --- /dev/null +++ b/components/backend/ent/answer_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" +) + +// AnswerDelete is the builder for deleting a Answer entity. +type AnswerDelete struct { + config + hooks []Hook + mutation *AnswerMutation +} + +// Where appends a list predicates to the AnswerDelete builder. +func (_d *AnswerDelete) Where(ps ...predicate.Answer) *AnswerDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AnswerDelete) 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 *AnswerDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AnswerDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(answer.Table, sqlgraph.NewFieldSpec(answer.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 +} + +// AnswerDeleteOne is the builder for deleting a single Answer entity. +type AnswerDeleteOne struct { + _d *AnswerDelete +} + +// Where appends a list predicates to the AnswerDelete builder. +func (_d *AnswerDeleteOne) Where(ps ...predicate.Answer) *AnswerDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AnswerDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{answer.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AnswerDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/components/backend/ent/answer_query.go b/components/backend/ent/answer_query.go new file mode 100644 index 00000000..e2b794f8 --- /dev/null +++ b/components/backend/ent/answer_query.go @@ -0,0 +1,682 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// AnswerQuery is the builder for querying Answer entities. +type AnswerQuery struct { + config + ctx *QueryContext + order []answer.OrderOption + inters []Interceptor + predicates []predicate.Answer + withQuestion *QuestionQuery + withUser *UserQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AnswerQuery builder. +func (_q *AnswerQuery) Where(ps ...predicate.Answer) *AnswerQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AnswerQuery) Limit(limit int) *AnswerQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AnswerQuery) Offset(offset int) *AnswerQuery { + _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 *AnswerQuery) Unique(unique bool) *AnswerQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AnswerQuery) Order(o ...answer.OrderOption) *AnswerQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryQuestion chains the current query on the "question" edge. +func (_q *AnswerQuery) QueryQuestion() *QuestionQuery { + query := (&QuestionClient{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(answer.Table, answer.FieldID, selector), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, answer.QuestionTable, answer.QuestionColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryUser chains the current query on the "user" edge. +func (_q *AnswerQuery) QueryUser() *UserQuery { + query := (&UserClient{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(answer.Table, answer.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, answer.UserTable, answer.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Answer entity from the query. +// Returns a *NotFoundError when no Answer was found. +func (_q *AnswerQuery) First(ctx context.Context) (*Answer, 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{answer.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AnswerQuery) FirstX(ctx context.Context) *Answer { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Answer ID from the query. +// Returns a *NotFoundError when no Answer ID was found. +func (_q *AnswerQuery) 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{answer.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AnswerQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Answer entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Answer entity is found. +// Returns a *NotFoundError when no Answer entities are found. +func (_q *AnswerQuery) Only(ctx context.Context) (*Answer, 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{answer.Label} + default: + return nil, &NotSingularError{answer.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AnswerQuery) OnlyX(ctx context.Context) *Answer { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Answer ID in the query. +// Returns a *NotSingularError when more than one Answer ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AnswerQuery) 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{answer.Label} + default: + err = &NotSingularError{answer.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AnswerQuery) 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 Answers. +func (_q *AnswerQuery) All(ctx context.Context) ([]*Answer, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Answer, *AnswerQuery]() + return withInterceptors[[]*Answer](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AnswerQuery) AllX(ctx context.Context) []*Answer { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Answer IDs. +func (_q *AnswerQuery) 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(answer.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AnswerQuery) 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 *AnswerQuery) 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[*AnswerQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AnswerQuery) 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 *AnswerQuery) 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("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AnswerQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AnswerQuery 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 *AnswerQuery) Clone() *AnswerQuery { + if _q == nil { + return nil + } + return &AnswerQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]answer.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Answer{}, _q.predicates...), + withQuestion: _q.withQuestion.Clone(), + withUser: _q.withUser.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithQuestion tells the query-builder to eager-load the nodes that are connected to +// the "question" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AnswerQuery) WithQuestion(opts ...func(*QuestionQuery)) *AnswerQuery { + query := (&QuestionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withQuestion = 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 *AnswerQuery) WithUser(opts ...func(*UserQuery)) *AnswerQuery { + query := (&UserClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withUser = 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 { +// QuestionID uuid.UUID `json:"question_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Answer.Query(). +// GroupBy(answer.FieldQuestionID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *AnswerQuery) GroupBy(field string, fields ...string) *AnswerGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AnswerGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = answer.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 { +// QuestionID uuid.UUID `json:"question_id,omitempty"` +// } +// +// client.Answer.Query(). +// Select(answer.FieldQuestionID). +// Scan(ctx, &v) +func (_q *AnswerQuery) Select(fields ...string) *AnswerSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AnswerSelect{AnswerQuery: _q} + sbuild.label = answer.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AnswerSelect configured with the given aggregations. +func (_q *AnswerQuery) Aggregate(fns ...AggregateFunc) *AnswerSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AnswerQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !answer.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: 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 *AnswerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Answer, error) { + var ( + nodes = []*Answer{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withQuestion != nil, + _q.withUser != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Answer).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Answer{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + 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.withQuestion; query != nil { + if err := _q.loadQuestion(ctx, query, nodes, nil, + func(n *Answer, e *Question) { n.Edges.Question = e }); err != nil { + return nil, err + } + } + if query := _q.withUser; query != nil { + if err := _q.loadUser(ctx, query, nodes, nil, + func(n *Answer, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AnswerQuery) loadQuestion(ctx context.Context, query *QuestionQuery, nodes []*Answer, init func(*Answer), assign func(*Answer, *Question)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Answer) + for i := range nodes { + fk := nodes[i].QuestionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(question.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 "question_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *AnswerQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Answer, init func(*Answer), assign func(*Answer, *User)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Answer) + for i := range nodes { + fk := nodes[i].UserID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "user_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *AnswerQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _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 *AnswerQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(answer.Table, answer.Columns, sqlgraph.NewFieldSpec(answer.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, answer.FieldID) + for i := range fields { + if fields[i] != answer.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withQuestion != nil { + _spec.Node.AddColumnOnce(answer.FieldQuestionID) + } + if _q.withUser != nil { + _spec.Node.AddColumnOnce(answer.FieldUserID) + } + } + 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 *AnswerQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(answer.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = answer.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 _, 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 +} + +// AnswerGroupBy is the group-by builder for Answer entities. +type AnswerGroupBy struct { + selector + build *AnswerQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AnswerGroupBy) Aggregate(fns ...AggregateFunc) *AnswerGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AnswerGroupBy) 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[*AnswerQuery, *AnswerGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AnswerGroupBy) sqlScan(ctx context.Context, root *AnswerQuery, 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) +} + +// AnswerSelect is the builder for selecting fields of Answer entities. +type AnswerSelect struct { + *AnswerQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AnswerSelect) Aggregate(fns ...AggregateFunc) *AnswerSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AnswerSelect) 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[*AnswerQuery, *AnswerSelect](ctx, _s.AnswerQuery, _s, _s.inters, v) +} + +func (_s *AnswerSelect) sqlScan(ctx context.Context, root *AnswerQuery, 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) +} diff --git a/components/backend/ent/answer_update.go b/components/backend/ent/answer_update.go new file mode 100644 index 00000000..c991fb65 --- /dev/null +++ b/components/backend/ent/answer_update.go @@ -0,0 +1,537 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// AnswerUpdate is the builder for updating Answer entities. +type AnswerUpdate struct { + config + hooks []Hook + mutation *AnswerMutation +} + +// Where appends a list predicates to the AnswerUpdate builder. +func (_u *AnswerUpdate) Where(ps ...predicate.Answer) *AnswerUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetQuestionID sets the "question_id" field. +func (_u *AnswerUpdate) SetQuestionID(v uuid.UUID) *AnswerUpdate { + _u.mutation.SetQuestionID(v) + return _u +} + +// SetNillableQuestionID sets the "question_id" field if the given value is not nil. +func (_u *AnswerUpdate) SetNillableQuestionID(v *uuid.UUID) *AnswerUpdate { + if v != nil { + _u.SetQuestionID(*v) + } + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *AnswerUpdate) SetUserID(v uuid.UUID) *AnswerUpdate { + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *AnswerUpdate) SetNillableUserID(v *uuid.UUID) *AnswerUpdate { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// SetValue sets the "value" field. +func (_u *AnswerUpdate) SetValue(v string) *AnswerUpdate { + _u.mutation.SetValue(v) + return _u +} + +// SetNillableValue sets the "value" field if the given value is not nil. +func (_u *AnswerUpdate) SetNillableValue(v *string) *AnswerUpdate { + if v != nil { + _u.SetValue(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *AnswerUpdate) SetType(v answer.Type) *AnswerUpdate { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *AnswerUpdate) SetNillableType(v *answer.Type) *AnswerUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AnswerUpdate) SetUpdatedAt(v time.Time) *AnswerUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetQuestion sets the "question" edge to the Question entity. +func (_u *AnswerUpdate) SetQuestion(v *Question) *AnswerUpdate { + return _u.SetQuestionID(v.ID) +} + +// SetUser sets the "user" edge to the User entity. +func (_u *AnswerUpdate) SetUser(v *User) *AnswerUpdate { + return _u.SetUserID(v.ID) +} + +// Mutation returns the AnswerMutation object of the builder. +func (_u *AnswerUpdate) Mutation() *AnswerMutation { + return _u.mutation +} + +// ClearQuestion clears the "question" edge to the Question entity. +func (_u *AnswerUpdate) ClearQuestion() *AnswerUpdate { + _u.mutation.ClearQuestion() + return _u +} + +// ClearUser clears the "user" edge to the User entity. +func (_u *AnswerUpdate) ClearUser() *AnswerUpdate { + _u.mutation.ClearUser() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AnswerUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AnswerUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AnswerUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AnswerUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AnswerUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := answer.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AnswerUpdate) check() error { + if v, ok := _u.mutation.GetType(); ok { + if err := answer.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Answer.type": %w`, err)} + } + } + if _u.mutation.QuestionCleared() && len(_u.mutation.QuestionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Answer.question"`) + } + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Answer.user"`) + } + return nil +} + +func (_u *AnswerUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(answer.Table, answer.Columns, sqlgraph.NewFieldSpec(answer.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.Value(); ok { + _spec.SetField(answer.FieldValue, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(answer.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(answer.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.QuestionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.QuestionTable, + Columns: []string{answer.QuestionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.QuestionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.QuestionTable, + Columns: []string{answer.QuestionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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, + Inverse: true, + Table: answer.UserTable, + Columns: []string{answer.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.UserTable, + Columns: []string{answer.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{answer.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AnswerUpdateOne is the builder for updating a single Answer entity. +type AnswerUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AnswerMutation +} + +// SetQuestionID sets the "question_id" field. +func (_u *AnswerUpdateOne) SetQuestionID(v uuid.UUID) *AnswerUpdateOne { + _u.mutation.SetQuestionID(v) + return _u +} + +// SetNillableQuestionID sets the "question_id" field if the given value is not nil. +func (_u *AnswerUpdateOne) SetNillableQuestionID(v *uuid.UUID) *AnswerUpdateOne { + if v != nil { + _u.SetQuestionID(*v) + } + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *AnswerUpdateOne) SetUserID(v uuid.UUID) *AnswerUpdateOne { + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *AnswerUpdateOne) SetNillableUserID(v *uuid.UUID) *AnswerUpdateOne { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// SetValue sets the "value" field. +func (_u *AnswerUpdateOne) SetValue(v string) *AnswerUpdateOne { + _u.mutation.SetValue(v) + return _u +} + +// SetNillableValue sets the "value" field if the given value is not nil. +func (_u *AnswerUpdateOne) SetNillableValue(v *string) *AnswerUpdateOne { + if v != nil { + _u.SetValue(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *AnswerUpdateOne) SetType(v answer.Type) *AnswerUpdateOne { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *AnswerUpdateOne) SetNillableType(v *answer.Type) *AnswerUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AnswerUpdateOne) SetUpdatedAt(v time.Time) *AnswerUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetQuestion sets the "question" edge to the Question entity. +func (_u *AnswerUpdateOne) SetQuestion(v *Question) *AnswerUpdateOne { + return _u.SetQuestionID(v.ID) +} + +// SetUser sets the "user" edge to the User entity. +func (_u *AnswerUpdateOne) SetUser(v *User) *AnswerUpdateOne { + return _u.SetUserID(v.ID) +} + +// Mutation returns the AnswerMutation object of the builder. +func (_u *AnswerUpdateOne) Mutation() *AnswerMutation { + return _u.mutation +} + +// ClearQuestion clears the "question" edge to the Question entity. +func (_u *AnswerUpdateOne) ClearQuestion() *AnswerUpdateOne { + _u.mutation.ClearQuestion() + return _u +} + +// ClearUser clears the "user" edge to the User entity. +func (_u *AnswerUpdateOne) ClearUser() *AnswerUpdateOne { + _u.mutation.ClearUser() + return _u +} + +// Where appends a list predicates to the AnswerUpdate builder. +func (_u *AnswerUpdateOne) Where(ps ...predicate.Answer) *AnswerUpdateOne { + _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 *AnswerUpdateOne) Select(field string, fields ...string) *AnswerUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated Answer entity. +func (_u *AnswerUpdateOne) Save(ctx context.Context) (*Answer, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AnswerUpdateOne) SaveX(ctx context.Context) *Answer { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AnswerUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AnswerUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AnswerUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := answer.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AnswerUpdateOne) check() error { + if v, ok := _u.mutation.GetType(); ok { + if err := answer.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Answer.type": %w`, err)} + } + } + if _u.mutation.QuestionCleared() && len(_u.mutation.QuestionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Answer.question"`) + } + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Answer.user"`) + } + return nil +} + +func (_u *AnswerUpdateOne) sqlSave(ctx context.Context) (_node *Answer, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(answer.Table, answer.Columns, sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Answer.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, answer.FieldID) + for _, f := range fields { + if !answer.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != answer.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.Value(); ok { + _spec.SetField(answer.FieldValue, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(answer.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(answer.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.QuestionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.QuestionTable, + Columns: []string{answer.QuestionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.QuestionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.QuestionTable, + Columns: []string{answer.QuestionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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, + Inverse: true, + Table: answer.UserTable, + Columns: []string{answer.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: answer.UserTable, + Columns: []string{answer.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Answer{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{answer.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/components/backend/ent/client.go b/components/backend/ent/client.go index daf4f0ac..3cc878eb 100644 --- a/components/backend/ent/client.go +++ b/components/backend/ent/client.go @@ -16,12 +16,14 @@ import ( "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathonstate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/participant" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/submission" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/team" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/teamparticipant" @@ -37,6 +39,8 @@ type Client struct { config // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema + // Answer is the client for interacting with the Answer builders. + Answer *AnswerClient // Hackathon is the client for interacting with the Hackathon builders. Hackathon *HackathonClient // HackathonState is the client for interacting with the HackathonState builders. @@ -49,6 +53,8 @@ type Client struct { Phase *PhaseClient // Project is the client for interacting with the Project builders. Project *ProjectClient + // Question is the client for interacting with the Question builders. + Question *QuestionClient // Submission is the client for interacting with the Submission builders. Submission *SubmissionClient // Team is the client for interacting with the Team builders. @@ -76,12 +82,14 @@ func NewClient(opts ...Option) *Client { func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) + c.Answer = NewAnswerClient(c.config) c.Hackathon = NewHackathonClient(c.config) c.HackathonState = NewHackathonStateClient(c.config) c.Page = NewPageClient(c.config) c.Participant = NewParticipantClient(c.config) c.Phase = NewPhaseClient(c.config) c.Project = NewProjectClient(c.config) + c.Question = NewQuestionClient(c.config) c.Submission = NewSubmissionClient(c.config) c.Team = NewTeamClient(c.config) c.TeamParticipant = NewTeamParticipantClient(c.config) @@ -182,12 +190,14 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { return &Tx{ ctx: ctx, config: cfg, + Answer: NewAnswerClient(cfg), Hackathon: NewHackathonClient(cfg), HackathonState: NewHackathonStateClient(cfg), Page: NewPageClient(cfg), Participant: NewParticipantClient(cfg), Phase: NewPhaseClient(cfg), Project: NewProjectClient(cfg), + Question: NewQuestionClient(cfg), Submission: NewSubmissionClient(cfg), Team: NewTeamClient(cfg), TeamParticipant: NewTeamParticipantClient(cfg), @@ -215,12 +225,14 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) return &Tx{ ctx: ctx, config: cfg, + Answer: NewAnswerClient(cfg), Hackathon: NewHackathonClient(cfg), HackathonState: NewHackathonStateClient(cfg), Page: NewPageClient(cfg), Participant: NewParticipantClient(cfg), Phase: NewPhaseClient(cfg), Project: NewProjectClient(cfg), + Question: NewQuestionClient(cfg), Submission: NewSubmissionClient(cfg), Team: NewTeamClient(cfg), TeamParticipant: NewTeamParticipantClient(cfg), @@ -235,7 +247,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). -// Hackathon. +// Answer. // Query(). // Count(ctx) func (c *Client) Debug() *Client { @@ -258,9 +270,9 @@ 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.Hackathon, c.HackathonState, c.Page, c.Participant, c.Phase, c.Project, - c.Submission, c.Team, c.TeamParticipant, c.Track, c.User, c.Vote, - c.VoteCategory, c.VoteResult, + c.Answer, c.Hackathon, c.HackathonState, c.Page, c.Participant, c.Phase, + c.Project, c.Question, c.Submission, c.Team, c.TeamParticipant, c.Track, + c.User, c.Vote, c.VoteCategory, c.VoteResult, } { n.Use(hooks...) } @@ -270,9 +282,9 @@ 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.Hackathon, c.HackathonState, c.Page, c.Participant, c.Phase, c.Project, - c.Submission, c.Team, c.TeamParticipant, c.Track, c.User, c.Vote, - c.VoteCategory, c.VoteResult, + c.Answer, c.Hackathon, c.HackathonState, c.Page, c.Participant, c.Phase, + c.Project, c.Question, c.Submission, c.Team, c.TeamParticipant, c.Track, + c.User, c.Vote, c.VoteCategory, c.VoteResult, } { n.Intercept(interceptors...) } @@ -281,6 +293,8 @@ func (c *Client) Intercept(interceptors ...Interceptor) { // Mutate implements the ent.Mutator interface. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { + case *AnswerMutation: + return c.Answer.mutate(ctx, m) case *HackathonMutation: return c.Hackathon.mutate(ctx, m) case *HackathonStateMutation: @@ -293,6 +307,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Phase.mutate(ctx, m) case *ProjectMutation: return c.Project.mutate(ctx, m) + case *QuestionMutation: + return c.Question.mutate(ctx, m) case *SubmissionMutation: return c.Submission.mutate(ctx, m) case *TeamMutation: @@ -314,6 +330,171 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { } } +// AnswerClient is a client for the Answer schema. +type AnswerClient struct { + config +} + +// NewAnswerClient returns a client for the Answer from the given config. +func NewAnswerClient(c config) *AnswerClient { + return &AnswerClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `answer.Hooks(f(g(h())))`. +func (c *AnswerClient) Use(hooks ...Hook) { + c.hooks.Answer = append(c.hooks.Answer, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `answer.Intercept(f(g(h())))`. +func (c *AnswerClient) Intercept(interceptors ...Interceptor) { + c.inters.Answer = append(c.inters.Answer, interceptors...) +} + +// Create returns a builder for creating a Answer entity. +func (c *AnswerClient) Create() *AnswerCreate { + mutation := newAnswerMutation(c.config, OpCreate) + return &AnswerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Answer entities. +func (c *AnswerClient) CreateBulk(builders ...*AnswerCreate) *AnswerCreateBulk { + return &AnswerCreateBulk{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 *AnswerClient) MapCreateBulk(slice any, setFunc func(*AnswerCreate, int)) *AnswerCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AnswerCreateBulk{err: fmt.Errorf("calling to AnswerClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AnswerCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AnswerCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Answer. +func (c *AnswerClient) Update() *AnswerUpdate { + mutation := newAnswerMutation(c.config, OpUpdate) + return &AnswerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AnswerClient) UpdateOne(_m *Answer) *AnswerUpdateOne { + mutation := newAnswerMutation(c.config, OpUpdateOne, withAnswer(_m)) + return &AnswerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AnswerClient) UpdateOneID(id uuid.UUID) *AnswerUpdateOne { + mutation := newAnswerMutation(c.config, OpUpdateOne, withAnswerID(id)) + return &AnswerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Answer. +func (c *AnswerClient) Delete() *AnswerDelete { + mutation := newAnswerMutation(c.config, OpDelete) + return &AnswerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AnswerClient) DeleteOne(_m *Answer) *AnswerDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AnswerClient) DeleteOneID(id uuid.UUID) *AnswerDeleteOne { + builder := c.Delete().Where(answer.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AnswerDeleteOne{builder} +} + +// Query returns a query builder for Answer. +func (c *AnswerClient) Query() *AnswerQuery { + return &AnswerQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAnswer}, + inters: c.Interceptors(), + } +} + +// Get returns a Answer entity by its id. +func (c *AnswerClient) Get(ctx context.Context, id uuid.UUID) (*Answer, error) { + return c.Query().Where(answer.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AnswerClient) GetX(ctx context.Context, id uuid.UUID) *Answer { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryQuestion queries the question edge of a Answer. +func (c *AnswerClient) QueryQuestion(_m *Answer) *QuestionQuery { + query := (&QuestionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(answer.Table, answer.FieldID, id), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, answer.QuestionTable, answer.QuestionColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryUser queries the user edge of a Answer. +func (c *AnswerClient) QueryUser(_m *Answer) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(answer.Table, answer.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, answer.UserTable, answer.UserColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AnswerClient) Hooks() []Hook { + return c.hooks.Answer +} + +// Interceptors returns the client interceptors. +func (c *AnswerClient) Interceptors() []Interceptor { + return c.inters.Answer +} + +func (c *AnswerClient) mutate(ctx context.Context, m *AnswerMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AnswerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AnswerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AnswerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AnswerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Answer mutation op: %q", m.Op()) + } +} + // HackathonClient is a client for the Hackathon schema. type HackathonClient struct { config @@ -534,6 +715,22 @@ func (c *HackathonClient) QueryVoteCategories(_m *Hackathon) *VoteCategoryQuery return query } +// QueryQuestions queries the questions edge of a Hackathon. +func (c *HackathonClient) QueryQuestions(_m *Hackathon) *QuestionQuery { + query := (&QuestionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(hackathon.Table, hackathon.FieldID, id), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, hackathon.QuestionsTable, hackathon.QuestionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryOwners queries the owners edge of a Hackathon. func (c *HackathonClient) QueryOwners(_m *Hackathon) *UserQuery { query := (&UserClient{config: c.config}).Query() @@ -1591,6 +1788,203 @@ func (c *ProjectClient) mutate(ctx context.Context, m *ProjectMutation) (Value, } } +// QuestionClient is a client for the Question schema. +type QuestionClient struct { + config +} + +// NewQuestionClient returns a client for the Question from the given config. +func NewQuestionClient(c config) *QuestionClient { + return &QuestionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `question.Hooks(f(g(h())))`. +func (c *QuestionClient) Use(hooks ...Hook) { + c.hooks.Question = append(c.hooks.Question, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `question.Intercept(f(g(h())))`. +func (c *QuestionClient) Intercept(interceptors ...Interceptor) { + c.inters.Question = append(c.inters.Question, interceptors...) +} + +// Create returns a builder for creating a Question entity. +func (c *QuestionClient) Create() *QuestionCreate { + mutation := newQuestionMutation(c.config, OpCreate) + return &QuestionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Question entities. +func (c *QuestionClient) CreateBulk(builders ...*QuestionCreate) *QuestionCreateBulk { + return &QuestionCreateBulk{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 *QuestionClient) MapCreateBulk(slice any, setFunc func(*QuestionCreate, int)) *QuestionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &QuestionCreateBulk{err: fmt.Errorf("calling to QuestionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*QuestionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &QuestionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Question. +func (c *QuestionClient) Update() *QuestionUpdate { + mutation := newQuestionMutation(c.config, OpUpdate) + return &QuestionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *QuestionClient) UpdateOne(_m *Question) *QuestionUpdateOne { + mutation := newQuestionMutation(c.config, OpUpdateOne, withQuestion(_m)) + return &QuestionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *QuestionClient) UpdateOneID(id uuid.UUID) *QuestionUpdateOne { + mutation := newQuestionMutation(c.config, OpUpdateOne, withQuestionID(id)) + return &QuestionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Question. +func (c *QuestionClient) Delete() *QuestionDelete { + mutation := newQuestionMutation(c.config, OpDelete) + return &QuestionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *QuestionClient) DeleteOne(_m *Question) *QuestionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *QuestionClient) DeleteOneID(id uuid.UUID) *QuestionDeleteOne { + builder := c.Delete().Where(question.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &QuestionDeleteOne{builder} +} + +// Query returns a query builder for Question. +func (c *QuestionClient) Query() *QuestionQuery { + return &QuestionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeQuestion}, + inters: c.Interceptors(), + } +} + +// Get returns a Question entity by its id. +func (c *QuestionClient) Get(ctx context.Context, id uuid.UUID) (*Question, error) { + return c.Query().Where(question.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *QuestionClient) GetX(ctx context.Context, id uuid.UUID) *Question { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryHackathon queries the hackathon edge of a Question. +func (c *QuestionClient) QueryHackathon(_m *Question) *HackathonQuery { + query := (&HackathonClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(question.Table, question.FieldID, id), + sqlgraph.To(hackathon.Table, hackathon.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, question.HackathonTable, question.HackathonColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryCreator queries the creator edge of a Question. +func (c *QuestionClient) QueryCreator(_m *Question) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(question.Table, question.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, question.CreatorTable, question.CreatorColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryModifier queries the modifier edge of a Question. +func (c *QuestionClient) QueryModifier(_m *Question) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(question.Table, question.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, question.ModifierTable, question.ModifierColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAnswers queries the answers edge of a Question. +func (c *QuestionClient) QueryAnswers(_m *Question) *AnswerQuery { + query := (&AnswerClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(question.Table, question.FieldID, id), + sqlgraph.To(answer.Table, answer.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, question.AnswersTable, question.AnswersColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *QuestionClient) Hooks() []Hook { + return c.hooks.Question +} + +// Interceptors returns the client interceptors. +func (c *QuestionClient) Interceptors() []Interceptor { + return c.inters.Question +} + +func (c *QuestionClient) mutate(ctx context.Context, m *QuestionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&QuestionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&QuestionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&QuestionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&QuestionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Question mutation op: %q", m.Op()) + } +} + // SubmissionClient is a client for the Submission schema. type SubmissionClient struct { config @@ -2726,6 +3120,54 @@ func (c *UserClient) QueryModifiedTracks(_m *User) *TrackQuery { return query } +// QueryCreatedQuestions queries the created_questions edge of a User. +func (c *UserClient) QueryCreatedQuestions(_m *User) *QuestionQuery { + query := (&QuestionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.CreatedQuestionsTable, user.CreatedQuestionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryModifiedQuestions queries the modified_questions edge of a User. +func (c *UserClient) QueryModifiedQuestions(_m *User) *QuestionQuery { + query := (&QuestionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.ModifiedQuestionsTable, user.ModifiedQuestionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryCreatedAnswers queries the created_answers edge of a User. +func (c *UserClient) QueryCreatedAnswers(_m *User) *AnswerQuery { + query := (&AnswerClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(answer.Table, answer.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.CreatedAnswersTable, user.CreatedAnswersColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryModifiedStates queries the modified_states edge of a User. func (c *UserClient) QueryModifiedStates(_m *User) *HackathonStateQuery { query := (&HackathonStateClient{config: c.config}).Query() @@ -3410,11 +3852,13 @@ func (c *VoteResultClient) mutate(ctx context.Context, m *VoteResultMutation) (V // hooks and interceptors per client, for fast access. type ( hooks struct { - Hackathon, HackathonState, Page, Participant, Phase, Project, Submission, Team, - TeamParticipant, Track, User, Vote, VoteCategory, VoteResult []ent.Hook + Answer, Hackathon, HackathonState, Page, Participant, Phase, Project, Question, + Submission, Team, TeamParticipant, Track, User, Vote, VoteCategory, + VoteResult []ent.Hook } inters struct { - Hackathon, HackathonState, Page, Participant, Phase, Project, Submission, Team, - TeamParticipant, Track, User, Vote, VoteCategory, VoteResult []ent.Interceptor + Answer, Hackathon, HackathonState, Page, Participant, Phase, Project, Question, + Submission, Team, TeamParticipant, Track, User, Vote, VoteCategory, + VoteResult []ent.Interceptor } ) diff --git a/components/backend/ent/ent.go b/components/backend/ent/ent.go index 703eaefc..4f7ce58c 100644 --- a/components/backend/ent/ent.go +++ b/components/backend/ent/ent.go @@ -12,12 +12,14 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathonstate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/participant" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/submission" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/team" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/teamparticipant" @@ -86,12 +88,14 @@ var ( func checkColumn(t, c string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + answer.Table: answer.ValidColumn, hackathon.Table: hackathon.ValidColumn, hackathonstate.Table: hackathonstate.ValidColumn, page.Table: page.ValidColumn, participant.Table: participant.ValidColumn, phase.Table: phase.ValidColumn, project.Table: project.ValidColumn, + question.Table: question.ValidColumn, submission.Table: submission.ValidColumn, team.Table: team.ValidColumn, teamparticipant.Table: teamparticipant.ValidColumn, diff --git a/components/backend/ent/hackathon.go b/components/backend/ent/hackathon.go index 4094a29a..46629b75 100644 --- a/components/backend/ent/hackathon.go +++ b/components/backend/ent/hackathon.go @@ -61,6 +61,8 @@ type HackathonEdges struct { State *HackathonState `json:"state,omitempty"` // Voting categories scoped to this hackathon. VoteCategories []*VoteCategory `json:"vote_categories,omitempty"` + // Registration questions configured for this hackathon. + Questions []*Question `json:"questions,omitempty"` // Users who are owners of this hackathon (in addition to the creator). Owners []*User `json:"owners,omitempty"` // The user who created this hackathon. @@ -71,7 +73,7 @@ type HackathonEdges struct { Participants []*Participant `json:"participants,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [11]bool + loadedTypes [12]bool } // TracksOrErr returns the Tracks value or an error if the edge @@ -139,10 +141,19 @@ func (e HackathonEdges) VoteCategoriesOrErr() ([]*VoteCategory, error) { return nil, &NotLoadedError{edge: "vote_categories"} } +// QuestionsOrErr returns the Questions value or an error if the edge +// was not loaded in eager-loading. +func (e HackathonEdges) QuestionsOrErr() ([]*Question, error) { + if e.loadedTypes[7] { + return e.Questions, nil + } + return nil, &NotLoadedError{edge: "questions"} +} + // OwnersOrErr returns the Owners value or an error if the edge // was not loaded in eager-loading. func (e HackathonEdges) OwnersOrErr() ([]*User, error) { - if e.loadedTypes[7] { + if e.loadedTypes[8] { return e.Owners, nil } return nil, &NotLoadedError{edge: "owners"} @@ -153,7 +164,7 @@ func (e HackathonEdges) OwnersOrErr() ([]*User, error) { func (e HackathonEdges) CreatorOrErr() (*User, error) { if e.Creator != nil { return e.Creator, nil - } else if e.loadedTypes[8] { + } else if e.loadedTypes[9] { return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "creator"} @@ -164,7 +175,7 @@ func (e HackathonEdges) CreatorOrErr() (*User, error) { func (e HackathonEdges) ModifierOrErr() (*User, error) { if e.Modifier != nil { return e.Modifier, nil - } else if e.loadedTypes[9] { + } else if e.loadedTypes[10] { return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "modifier"} @@ -173,7 +184,7 @@ func (e HackathonEdges) ModifierOrErr() (*User, error) { // ParticipantsOrErr returns the Participants value or an error if the edge // was not loaded in eager-loading. func (e HackathonEdges) ParticipantsOrErr() ([]*Participant, error) { - if e.loadedTypes[10] { + if e.loadedTypes[11] { return e.Participants, nil } return nil, &NotLoadedError{edge: "participants"} @@ -336,6 +347,11 @@ func (_m *Hackathon) QueryVoteCategories() *VoteCategoryQuery { return NewHackathonClient(_m.config).QueryVoteCategories(_m) } +// QueryQuestions queries the "questions" edge of the Hackathon entity. +func (_m *Hackathon) QueryQuestions() *QuestionQuery { + return NewHackathonClient(_m.config).QueryQuestions(_m) +} + // QueryOwners queries the "owners" edge of the Hackathon entity. func (_m *Hackathon) QueryOwners() *UserQuery { return NewHackathonClient(_m.config).QueryOwners(_m) diff --git a/components/backend/ent/hackathon/hackathon.go b/components/backend/ent/hackathon/hackathon.go index 4b8e8ef8..e749e263 100644 --- a/components/backend/ent/hackathon/hackathon.go +++ b/components/backend/ent/hackathon/hackathon.go @@ -46,6 +46,8 @@ const ( EdgeState = "state" // EdgeVoteCategories holds the string denoting the vote_categories edge name in mutations. EdgeVoteCategories = "vote_categories" + // EdgeQuestions holds the string denoting the questions edge name in mutations. + EdgeQuestions = "questions" // EdgeOwners holds the string denoting the owners edge name in mutations. EdgeOwners = "owners" // EdgeCreator holds the string denoting the creator edge name in mutations. @@ -103,6 +105,13 @@ const ( VoteCategoriesInverseTable = "vote_categories" // VoteCategoriesColumn is the table column denoting the vote_categories relation/edge. VoteCategoriesColumn = "hackathon_vote_categories" + // QuestionsTable is the table that holds the questions relation/edge. + QuestionsTable = "questions" + // QuestionsInverseTable is the table name for the Question entity. + // It exists in this package in order to avoid circular dependency with the "question" package. + QuestionsInverseTable = "questions" + // QuestionsColumn is the table column denoting the questions relation/edge. + QuestionsColumn = "hackathon_id" // OwnersTable is the table that holds the owners relation/edge. The primary key declared below. OwnersTable = "hackathon_owners" // OwnersInverseTable is the table name for the User entity. @@ -351,6 +360,20 @@ func ByVoteCategories(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// ByQuestionsCount orders the results by questions count. +func ByQuestionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newQuestionsStep(), opts...) + } +} + +// ByQuestions orders the results by questions terms. +func ByQuestions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newQuestionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByOwnersCount orders the results by owners count. func ByOwnersCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -441,6 +464,13 @@ func newVoteCategoriesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, VoteCategoriesTable, VoteCategoriesColumn), ) } +func newQuestionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(QuestionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, QuestionsTable, QuestionsColumn), + ) +} func newOwnersStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/components/backend/ent/hackathon/where.go b/components/backend/ent/hackathon/where.go index e3138af7..1c2fd32f 100644 --- a/components/backend/ent/hackathon/where.go +++ b/components/backend/ent/hackathon/where.go @@ -667,6 +667,29 @@ func HasVoteCategoriesWith(preds ...predicate.VoteCategory) predicate.Hackathon }) } +// HasQuestions applies the HasEdge predicate on the "questions" edge. +func HasQuestions() predicate.Hackathon { + return predicate.Hackathon(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, QuestionsTable, QuestionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasQuestionsWith applies the HasEdge predicate on the "questions" edge with a given conditions (other predicates). +func HasQuestionsWith(preds ...predicate.Question) predicate.Hackathon { + return predicate.Hackathon(func(s *sql.Selector) { + step := newQuestionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasOwners applies the HasEdge predicate on the "owners" edge. func HasOwners() predicate.Hackathon { return predicate.Hackathon(func(s *sql.Selector) { diff --git a/components/backend/ent/hackathon_create.go b/components/backend/ent/hackathon_create.go index 119542ce..e06d7854 100644 --- a/components/backend/ent/hackathon_create.go +++ b/components/backend/ent/hackathon_create.go @@ -16,6 +16,7 @@ import ( "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/track" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/votecategory" @@ -247,6 +248,21 @@ func (_c *HackathonCreate) AddVoteCategories(v ...*VoteCategory) *HackathonCreat return _c.AddVoteCategoryIDs(ids...) } +// AddQuestionIDs adds the "questions" edge to the Question entity by IDs. +func (_c *HackathonCreate) AddQuestionIDs(ids ...uuid.UUID) *HackathonCreate { + _c.mutation.AddQuestionIDs(ids...) + return _c +} + +// AddQuestions adds the "questions" edges to the Question entity. +func (_c *HackathonCreate) AddQuestions(v ...*Question) *HackathonCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddQuestionIDs(ids...) +} + // AddOwnerIDs adds the "owners" edge to the User entity by IDs. func (_c *HackathonCreate) AddOwnerIDs(ids ...uuid.UUID) *HackathonCreate { _c.mutation.AddOwnerIDs(ids...) @@ -546,6 +562,22 @@ func (_c *HackathonCreate) createSpec() (*Hackathon, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := _c.mutation.QuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: hackathon.QuestionsTable, + Columns: []string{hackathon.QuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.OwnersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/components/backend/ent/hackathon_query.go b/components/backend/ent/hackathon_query.go index 07c98079..b08ae5f2 100644 --- a/components/backend/ent/hackathon_query.go +++ b/components/backend/ent/hackathon_query.go @@ -20,6 +20,7 @@ import ( "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/track" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/votecategory" @@ -39,6 +40,7 @@ type HackathonQuery struct { withPhases *PhaseQuery withState *HackathonStateQuery withVoteCategories *VoteCategoryQuery + withQuestions *QuestionQuery withOwners *UserQuery withCreator *UserQuery withModifier *UserQuery @@ -234,6 +236,28 @@ func (_q *HackathonQuery) QueryVoteCategories() *VoteCategoryQuery { return query } +// QueryQuestions chains the current query on the "questions" edge. +func (_q *HackathonQuery) QueryQuestions() *QuestionQuery { + query := (&QuestionClient{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(hackathon.Table, hackathon.FieldID, selector), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, hackathon.QuestionsTable, hackathon.QuestionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryOwners chains the current query on the "owners" edge. func (_q *HackathonQuery) QueryOwners() *UserQuery { query := (&UserClient{config: _q.config}).Query() @@ -521,6 +545,7 @@ func (_q *HackathonQuery) Clone() *HackathonQuery { withPhases: _q.withPhases.Clone(), withState: _q.withState.Clone(), withVoteCategories: _q.withVoteCategories.Clone(), + withQuestions: _q.withQuestions.Clone(), withOwners: _q.withOwners.Clone(), withCreator: _q.withCreator.Clone(), withModifier: _q.withModifier.Clone(), @@ -608,6 +633,17 @@ func (_q *HackathonQuery) WithVoteCategories(opts ...func(*VoteCategoryQuery)) * return _q } +// WithQuestions tells the query-builder to eager-load the nodes that are connected to +// the "questions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *HackathonQuery) WithQuestions(opts ...func(*QuestionQuery)) *HackathonQuery { + query := (&QuestionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withQuestions = query + return _q +} + // WithOwners tells the query-builder to eager-load the nodes that are connected to // the "owners" edge. The optional arguments are used to configure the query builder of the edge. func (_q *HackathonQuery) WithOwners(opts ...func(*UserQuery)) *HackathonQuery { @@ -731,7 +767,7 @@ func (_q *HackathonQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ha nodes = []*Hackathon{} withFKs = _q.withFKs _spec = _q.querySpec() - loadedTypes = [11]bool{ + loadedTypes = [12]bool{ _q.withTracks != nil, _q.withProjects != nil, _q.withParticipatingUsers != nil, @@ -739,6 +775,7 @@ func (_q *HackathonQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ha _q.withPhases != nil, _q.withState != nil, _q.withVoteCategories != nil, + _q.withQuestions != nil, _q.withOwners != nil, _q.withCreator != nil, _q.withModifier != nil, @@ -817,6 +854,13 @@ func (_q *HackathonQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ha return nil, err } } + if query := _q.withQuestions; query != nil { + if err := _q.loadQuestions(ctx, query, nodes, + func(n *Hackathon) { n.Edges.Questions = []*Question{} }, + func(n *Hackathon, e *Question) { n.Edges.Questions = append(n.Edges.Questions, e) }); err != nil { + return nil, err + } + } if query := _q.withOwners; query != nil { if err := _q.loadOwners(ctx, query, nodes, func(n *Hackathon) { n.Edges.Owners = []*User{} }, @@ -1090,6 +1134,37 @@ func (_q *HackathonQuery) loadVoteCategories(ctx context.Context, query *VoteCat } return nil } +func (_q *HackathonQuery) loadQuestions(ctx context.Context, query *QuestionQuery, nodes []*Hackathon, init func(*Hackathon), assign func(*Hackathon, *Question)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Hackathon) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(question.FieldHackathonID) + } + query.Where(predicate.Question(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(hackathon.QuestionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.HackathonID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "hackathon_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (_q *HackathonQuery) loadOwners(ctx context.Context, query *UserQuery, nodes []*Hackathon, init func(*Hackathon), assign func(*Hackathon, *User)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[uuid.UUID]*Hackathon) diff --git a/components/backend/ent/hackathon_update.go b/components/backend/ent/hackathon_update.go index c165b9ed..88ab9c05 100644 --- a/components/backend/ent/hackathon_update.go +++ b/components/backend/ent/hackathon_update.go @@ -18,6 +18,7 @@ import ( "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/track" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/votecategory" @@ -259,6 +260,21 @@ func (_u *HackathonUpdate) AddVoteCategories(v ...*VoteCategory) *HackathonUpdat return _u.AddVoteCategoryIDs(ids...) } +// AddQuestionIDs adds the "questions" edge to the Question entity by IDs. +func (_u *HackathonUpdate) AddQuestionIDs(ids ...uuid.UUID) *HackathonUpdate { + _u.mutation.AddQuestionIDs(ids...) + return _u +} + +// AddQuestions adds the "questions" edges to the Question entity. +func (_u *HackathonUpdate) AddQuestions(v ...*Question) *HackathonUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddQuestionIDs(ids...) +} + // AddOwnerIDs adds the "owners" edge to the User entity by IDs. func (_u *HackathonUpdate) AddOwnerIDs(ids ...uuid.UUID) *HackathonUpdate { _u.mutation.AddOwnerIDs(ids...) @@ -422,6 +438,27 @@ func (_u *HackathonUpdate) RemoveVoteCategories(v ...*VoteCategory) *HackathonUp return _u.RemoveVoteCategoryIDs(ids...) } +// ClearQuestions clears all "questions" edges to the Question entity. +func (_u *HackathonUpdate) ClearQuestions() *HackathonUpdate { + _u.mutation.ClearQuestions() + return _u +} + +// RemoveQuestionIDs removes the "questions" edge to Question entities by IDs. +func (_u *HackathonUpdate) RemoveQuestionIDs(ids ...uuid.UUID) *HackathonUpdate { + _u.mutation.RemoveQuestionIDs(ids...) + return _u +} + +// RemoveQuestions removes "questions" edges to Question entities. +func (_u *HackathonUpdate) RemoveQuestions(v ...*Question) *HackathonUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveQuestionIDs(ids...) +} + // ClearOwners clears all "owners" edges to the User entity. func (_u *HackathonUpdate) ClearOwners() *HackathonUpdate { _u.mutation.ClearOwners() @@ -862,6 +899,51 @@ func (_u *HackathonUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.QuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: hackathon.QuestionsTable, + Columns: []string{hackathon.QuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedQuestionsIDs(); len(nodes) > 0 && !_u.mutation.QuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: hackathon.QuestionsTable, + Columns: []string{hackathon.QuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.QuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: hackathon.QuestionsTable, + Columns: []string{hackathon.QuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.OwnersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -1179,6 +1261,21 @@ func (_u *HackathonUpdateOne) AddVoteCategories(v ...*VoteCategory) *HackathonUp return _u.AddVoteCategoryIDs(ids...) } +// AddQuestionIDs adds the "questions" edge to the Question entity by IDs. +func (_u *HackathonUpdateOne) AddQuestionIDs(ids ...uuid.UUID) *HackathonUpdateOne { + _u.mutation.AddQuestionIDs(ids...) + return _u +} + +// AddQuestions adds the "questions" edges to the Question entity. +func (_u *HackathonUpdateOne) AddQuestions(v ...*Question) *HackathonUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddQuestionIDs(ids...) +} + // AddOwnerIDs adds the "owners" edge to the User entity by IDs. func (_u *HackathonUpdateOne) AddOwnerIDs(ids ...uuid.UUID) *HackathonUpdateOne { _u.mutation.AddOwnerIDs(ids...) @@ -1342,6 +1439,27 @@ func (_u *HackathonUpdateOne) RemoveVoteCategories(v ...*VoteCategory) *Hackatho return _u.RemoveVoteCategoryIDs(ids...) } +// ClearQuestions clears all "questions" edges to the Question entity. +func (_u *HackathonUpdateOne) ClearQuestions() *HackathonUpdateOne { + _u.mutation.ClearQuestions() + return _u +} + +// RemoveQuestionIDs removes the "questions" edge to Question entities by IDs. +func (_u *HackathonUpdateOne) RemoveQuestionIDs(ids ...uuid.UUID) *HackathonUpdateOne { + _u.mutation.RemoveQuestionIDs(ids...) + return _u +} + +// RemoveQuestions removes "questions" edges to Question entities. +func (_u *HackathonUpdateOne) RemoveQuestions(v ...*Question) *HackathonUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveQuestionIDs(ids...) +} + // ClearOwners clears all "owners" edges to the User entity. func (_u *HackathonUpdateOne) ClearOwners() *HackathonUpdateOne { _u.mutation.ClearOwners() @@ -1812,6 +1930,51 @@ func (_u *HackathonUpdateOne) sqlSave(ctx context.Context) (_node *Hackathon, er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.QuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: hackathon.QuestionsTable, + Columns: []string{hackathon.QuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedQuestionsIDs(); len(nodes) > 0 && !_u.mutation.QuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: hackathon.QuestionsTable, + Columns: []string{hackathon.QuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.QuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: hackathon.QuestionsTable, + Columns: []string{hackathon.QuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.OwnersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/components/backend/ent/hook/hook.go b/components/backend/ent/hook/hook.go index e9fff380..f49147b4 100644 --- a/components/backend/ent/hook/hook.go +++ b/components/backend/ent/hook/hook.go @@ -9,6 +9,18 @@ import ( "github.com/swissdatasciencecenter/hackagon/components/backend/ent" ) +// The AnswerFunc type is an adapter to allow the use of ordinary +// function as Answer mutator. +type AnswerFunc func(context.Context, *ent.AnswerMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f AnswerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.AnswerMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AnswerMutation", m) +} + // The HackathonFunc type is an adapter to allow the use of ordinary // function as Hackathon mutator. type HackathonFunc func(context.Context, *ent.HackathonMutation) (ent.Value, error) @@ -81,6 +93,18 @@ func (f ProjectFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, err return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ProjectMutation", m) } +// The QuestionFunc type is an adapter to allow the use of ordinary +// function as Question mutator. +type QuestionFunc func(context.Context, *ent.QuestionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f QuestionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.QuestionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.QuestionMutation", m) +} + // The SubmissionFunc type is an adapter to allow the use of ordinary // function as Submission mutator. type SubmissionFunc func(context.Context, *ent.SubmissionMutation) (ent.Value, error) diff --git a/components/backend/ent/migrate/schema.go b/components/backend/ent/migrate/schema.go index 5f011c23..a5db0e5d 100644 --- a/components/backend/ent/migrate/schema.go +++ b/components/backend/ent/migrate/schema.go @@ -8,6 +8,43 @@ import ( ) var ( + // AnswersColumns holds the columns for the "answers" table. + AnswersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "value", Type: field.TypeString}, + {Name: "type", Type: field.TypeEnum, Enums: []string{"text", "bool"}}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "question_id", Type: field.TypeUUID}, + {Name: "user_id", Type: field.TypeUUID}, + } + // AnswersTable holds the schema information for the "answers" table. + AnswersTable = &schema.Table{ + Name: "answers", + Columns: AnswersColumns, + PrimaryKey: []*schema.Column{AnswersColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "answers_questions_answers", + Columns: []*schema.Column{AnswersColumns[5]}, + RefColumns: []*schema.Column{QuestionsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "answers_users_created_answers", + Columns: []*schema.Column{AnswersColumns[6]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.Restrict, + }, + }, + Indexes: []*schema.Index{ + { + Name: "answer_question_id_user_id", + Unique: true, + Columns: []*schema.Column{AnswersColumns[5], AnswersColumns[6]}, + }, + }, + } // HackathonsColumns holds the columns for the "hackathons" table. HackathonsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -319,6 +356,58 @@ var ( }, }, } + // QuestionsColumns holds the columns for the "questions" table. + QuestionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "key", Type: field.TypeString}, + {Name: "label", Type: field.TypeString}, + {Name: "type", Type: field.TypeEnum, Enums: []string{"text", "bool"}}, + {Name: "mandatory", Type: field.TypeBool, Default: false}, + {Name: "order", Type: field.TypeInt, Default: 0}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "modified_at", Type: field.TypeTime}, + {Name: "hackathon_id", Type: field.TypeUUID}, + {Name: "user_created_questions", Type: field.TypeUUID}, + {Name: "user_modified_questions", Type: field.TypeUUID}, + } + // QuestionsTable holds the schema information for the "questions" table. + QuestionsTable = &schema.Table{ + Name: "questions", + Columns: QuestionsColumns, + PrimaryKey: []*schema.Column{QuestionsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "questions_hackathons_questions", + Columns: []*schema.Column{QuestionsColumns[8]}, + RefColumns: []*schema.Column{HackathonsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "questions_users_created_questions", + Columns: []*schema.Column{QuestionsColumns[9]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.Restrict, + }, + { + Symbol: "questions_users_modified_questions", + Columns: []*schema.Column{QuestionsColumns[10]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.Restrict, + }, + }, + Indexes: []*schema.Index{ + { + Name: "question_key_hackathon_id", + Unique: true, + Columns: []*schema.Column{QuestionsColumns[1], QuestionsColumns[8]}, + }, + { + Name: "question_order", + Unique: false, + Columns: []*schema.Column{QuestionsColumns[5]}, + }, + }, + } // SubmissionsColumns holds the columns for the "submissions" table. SubmissionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -671,12 +760,14 @@ var ( } // Tables holds all the tables in the schema. Tables = []*schema.Table{ + AnswersTable, HackathonsTable, HackathonStatesTable, PagesTable, ParticipantsTable, PhasesTable, ProjectsTable, + QuestionsTable, SubmissionsTable, TeamsTable, TeamParticipantsTable, @@ -692,6 +783,8 @@ var ( ) func init() { + AnswersTable.ForeignKeys[0].RefTable = QuestionsTable + AnswersTable.ForeignKeys[1].RefTable = UsersTable HackathonsTable.ForeignKeys[0].RefTable = PhasesTable HackathonsTable.ForeignKeys[1].RefTable = UsersTable HackathonsTable.ForeignKeys[2].RefTable = UsersTable @@ -711,6 +804,9 @@ func init() { ProjectsTable.ForeignKeys[1].RefTable = TracksTable ProjectsTable.ForeignKeys[2].RefTable = UsersTable ProjectsTable.ForeignKeys[3].RefTable = UsersTable + QuestionsTable.ForeignKeys[0].RefTable = HackathonsTable + QuestionsTable.ForeignKeys[1].RefTable = UsersTable + QuestionsTable.ForeignKeys[2].RefTable = UsersTable SubmissionsTable.ForeignKeys[0].RefTable = ProjectsTable SubmissionsTable.ForeignKeys[1].RefTable = TeamsTable SubmissionsTable.ForeignKeys[2].RefTable = UsersTable diff --git a/components/backend/ent/mutation.go b/components/backend/ent/mutation.go index e5bd248a..946eb019 100644 --- a/components/backend/ent/mutation.go +++ b/components/backend/ent/mutation.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathonstate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" @@ -19,6 +20,7 @@ import ( "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/submission" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/team" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/teamparticipant" @@ -38,12 +40,14 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. + TypeAnswer = "Answer" TypeHackathon = "Hackathon" TypeHackathonState = "HackathonState" TypePage = "Page" TypeParticipant = "Participant" TypePhase = "Phase" TypeProject = "Project" + TypeQuestion = "Question" TypeSubmission = "Submission" TypeTeam = "Team" TypeTeamParticipant = "TeamParticipant" @@ -54,64 +58,37 @@ const ( TypeVoteResult = "VoteResult" ) -// HackathonMutation represents an operation that mutates the Hackathon nodes in the graph. -type HackathonMutation struct { +// AnswerMutation represents an operation that mutates the Answer nodes in the graph. +type AnswerMutation struct { config - op Op - typ string - id *uuid.UUID - name *string - starts_at *time.Time - ends_at *time.Time - created_at *time.Time - modified_at *time.Time - visibility *hackathon.Visibility - description *string - logo *string - clearedFields map[string]struct{} - tracks map[uuid.UUID]struct{} - removedtracks map[uuid.UUID]struct{} - clearedtracks bool - projects map[uuid.UUID]struct{} - removedprojects map[uuid.UUID]struct{} - clearedprojects bool - participating_users map[uuid.UUID]struct{} - removedparticipating_users map[uuid.UUID]struct{} - clearedparticipating_users bool - pages map[uuid.UUID]struct{} - removedpages map[uuid.UUID]struct{} - clearedpages bool - phases map[uuid.UUID]struct{} - removedphases map[uuid.UUID]struct{} - clearedphases bool - state *uuid.UUID - clearedstate bool - vote_categories map[uuid.UUID]struct{} - removedvote_categories map[uuid.UUID]struct{} - clearedvote_categories bool - owners map[uuid.UUID]struct{} - removedowners map[uuid.UUID]struct{} - clearedowners bool - creator *uuid.UUID - clearedcreator bool - modifier *uuid.UUID - clearedmodifier bool - done bool - oldValue func(context.Context) (*Hackathon, error) - predicates []predicate.Hackathon -} - -var _ ent.Mutation = (*HackathonMutation)(nil) - -// hackathonOption allows management of the mutation configuration using functional options. -type hackathonOption func(*HackathonMutation) - -// newHackathonMutation creates new mutation for the Hackathon entity. -func newHackathonMutation(c config, op Op, opts ...hackathonOption) *HackathonMutation { - m := &HackathonMutation{ + op Op + typ string + id *uuid.UUID + value *string + _type *answer.Type + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + question *uuid.UUID + clearedquestion bool + user *uuid.UUID + cleareduser bool + done bool + oldValue func(context.Context) (*Answer, error) + predicates []predicate.Answer +} + +var _ ent.Mutation = (*AnswerMutation)(nil) + +// answerOption allows management of the mutation configuration using functional options. +type answerOption func(*AnswerMutation) + +// newAnswerMutation creates new mutation for the Answer entity. +func newAnswerMutation(c config, op Op, opts ...answerOption) *AnswerMutation { + m := &AnswerMutation{ config: c, op: op, - typ: TypeHackathon, + typ: TypeAnswer, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -120,20 +97,20 @@ func newHackathonMutation(c config, op Op, opts ...hackathonOption) *HackathonMu return m } -// withHackathonID sets the ID field of the mutation. -func withHackathonID(id uuid.UUID) hackathonOption { - return func(m *HackathonMutation) { +// withAnswerID sets the ID field of the mutation. +func withAnswerID(id uuid.UUID) answerOption { + return func(m *AnswerMutation) { var ( err error once sync.Once - value *Hackathon + value *Answer ) - m.oldValue = func(ctx context.Context) (*Hackathon, error) { + m.oldValue = func(ctx context.Context) (*Answer, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Hackathon.Get(ctx, id) + value, err = m.Client().Answer.Get(ctx, id) } }) return value, err @@ -142,10 +119,10 @@ func withHackathonID(id uuid.UUID) hackathonOption { } } -// withHackathon sets the old Hackathon of the mutation. -func withHackathon(node *Hackathon) hackathonOption { - return func(m *HackathonMutation) { - m.oldValue = func(context.Context) (*Hackathon, error) { +// withAnswer sets the old Answer of the mutation. +func withAnswer(node *Answer) answerOption { + return func(m *AnswerMutation) { + m.oldValue = func(context.Context) (*Answer, error) { return node, nil } m.id = &node.ID @@ -154,7 +131,7 @@ func withHackathon(node *Hackathon) hackathonOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m HackathonMutation) Client() *Client { +func (m AnswerMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -162,7 +139,7 @@ func (m HackathonMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m HackathonMutation) Tx() (*Tx, error) { +func (m AnswerMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -172,14 +149,14 @@ func (m HackathonMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Hackathon entities. -func (m *HackathonMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of Answer entities. +func (m *AnswerMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *HackathonMutation) ID() (id uuid.UUID, exists bool) { +func (m *AnswerMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -190,7 +167,7 @@ func (m *HackathonMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *HackathonMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AnswerMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -199,1455 +176,3226 @@ func (m *HackathonMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Hackathon.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Answer.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetName sets the "name" field. -func (m *HackathonMutation) SetName(s string) { - m.name = &s +// SetQuestionID sets the "question_id" field. +func (m *AnswerMutation) SetQuestionID(u uuid.UUID) { + m.question = &u } -// Name returns the value of the "name" field in the mutation. -func (m *HackathonMutation) Name() (r string, exists bool) { - v := m.name +// QuestionID returns the value of the "question_id" field in the mutation. +func (m *AnswerMutation) QuestionID() (r uuid.UUID, exists bool) { + v := m.question if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// OldQuestionID returns the old "question_id" field's value of the Answer entity. +// If the Answer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldName(ctx context.Context) (v string, err error) { +func (m *AnswerMutation) OldQuestionID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldQuestionID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldQuestionID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldQuestionID: %w", err) } - return oldValue.Name, nil + return oldValue.QuestionID, nil } -// ResetName resets all changes to the "name" field. -func (m *HackathonMutation) ResetName() { - m.name = nil +// ResetQuestionID resets all changes to the "question_id" field. +func (m *AnswerMutation) ResetQuestionID() { + m.question = nil } -// SetStartsAt sets the "starts_at" field. -func (m *HackathonMutation) SetStartsAt(t time.Time) { - m.starts_at = &t +// SetUserID sets the "user_id" field. +func (m *AnswerMutation) SetUserID(u uuid.UUID) { + m.user = &u } -// StartsAt returns the value of the "starts_at" field in the mutation. -func (m *HackathonMutation) StartsAt() (r time.Time, exists bool) { - v := m.starts_at +// UserID returns the value of the "user_id" field in the mutation. +func (m *AnswerMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user if v == nil { return } return *v, true } -// OldStartsAt returns the old "starts_at" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the Answer entity. +// If the Answer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldStartsAt(ctx context.Context) (v *time.Time, err error) { +func (m *AnswerMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStartsAt is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStartsAt requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldStartsAt: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.StartsAt, nil -} - -// ClearStartsAt clears the value of the "starts_at" field. -func (m *HackathonMutation) ClearStartsAt() { - m.starts_at = nil - m.clearedFields[hackathon.FieldStartsAt] = struct{}{} -} - -// StartsAtCleared returns if the "starts_at" field was cleared in this mutation. -func (m *HackathonMutation) StartsAtCleared() bool { - _, ok := m.clearedFields[hackathon.FieldStartsAt] - return ok + return oldValue.UserID, nil } -// ResetStartsAt resets all changes to the "starts_at" field. -func (m *HackathonMutation) ResetStartsAt() { - m.starts_at = nil - delete(m.clearedFields, hackathon.FieldStartsAt) +// ResetUserID resets all changes to the "user_id" field. +func (m *AnswerMutation) ResetUserID() { + m.user = nil } -// SetEndsAt sets the "ends_at" field. -func (m *HackathonMutation) SetEndsAt(t time.Time) { - m.ends_at = &t +// SetValue sets the "value" field. +func (m *AnswerMutation) SetValue(s string) { + m.value = &s } -// EndsAt returns the value of the "ends_at" field in the mutation. -func (m *HackathonMutation) EndsAt() (r time.Time, exists bool) { - v := m.ends_at +// Value returns the value of the "value" field in the mutation. +func (m *AnswerMutation) Value() (r string, exists bool) { + v := m.value if v == nil { return } return *v, true } -// OldEndsAt returns the old "ends_at" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// OldValue returns the old "value" field's value of the Answer entity. +// If the Answer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldEndsAt(ctx context.Context) (v *time.Time, err error) { +func (m *AnswerMutation) OldValue(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEndsAt is only allowed on UpdateOne operations") + return v, errors.New("OldValue is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEndsAt requires an ID field in the mutation") + return v, errors.New("OldValue requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEndsAt: %w", err) + return v, fmt.Errorf("querying old value for OldValue: %w", err) } - return oldValue.EndsAt, nil -} - -// ClearEndsAt clears the value of the "ends_at" field. -func (m *HackathonMutation) ClearEndsAt() { - m.ends_at = nil - m.clearedFields[hackathon.FieldEndsAt] = struct{}{} -} - -// EndsAtCleared returns if the "ends_at" field was cleared in this mutation. -func (m *HackathonMutation) EndsAtCleared() bool { - _, ok := m.clearedFields[hackathon.FieldEndsAt] - return ok + return oldValue.Value, nil } -// ResetEndsAt resets all changes to the "ends_at" field. -func (m *HackathonMutation) ResetEndsAt() { - m.ends_at = nil - delete(m.clearedFields, hackathon.FieldEndsAt) +// ResetValue resets all changes to the "value" field. +func (m *AnswerMutation) ResetValue() { + m.value = nil } -// SetCreatedAt sets the "created_at" field. -func (m *HackathonMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetType sets the "type" field. +func (m *AnswerMutation) SetType(a answer.Type) { + m._type = &a } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *HackathonMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// GetType returns the value of the "type" field in the mutation. +func (m *AnswerMutation) GetType() (r answer.Type, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// OldType returns the old "type" field's value of the Answer entity. +// If the Answer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AnswerMutation) OldType(ctx context.Context) (v answer.Type, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.Type, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *HackathonMutation) ResetCreatedAt() { - m.created_at = nil +// ResetType resets all changes to the "type" field. +func (m *AnswerMutation) ResetType() { + m._type = nil } -// SetModifiedAt sets the "modified_at" field. -func (m *HackathonMutation) SetModifiedAt(t time.Time) { - m.modified_at = &t +// SetCreatedAt sets the "created_at" field. +func (m *AnswerMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// ModifiedAt returns the value of the "modified_at" field in the mutation. -func (m *HackathonMutation) ModifiedAt() (r time.Time, exists bool) { - v := m.modified_at +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AnswerMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldModifiedAt returns the old "modified_at" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the Answer entity. +// If the Answer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { +func (m *AnswerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModifiedAt requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.ModifiedAt, nil + return oldValue.CreatedAt, nil } -// ResetModifiedAt resets all changes to the "modified_at" field. -func (m *HackathonMutation) ResetModifiedAt() { - m.modified_at = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AnswerMutation) ResetCreatedAt() { + m.created_at = nil } -// SetVisibility sets the "visibility" field. -func (m *HackathonMutation) SetVisibility(h hackathon.Visibility) { - m.visibility = &h +// SetUpdatedAt sets the "updated_at" field. +func (m *AnswerMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// Visibility returns the value of the "visibility" field in the mutation. -func (m *HackathonMutation) Visibility() (r hackathon.Visibility, exists bool) { - v := m.visibility +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AnswerMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at if v == nil { return } return *v, true } -// OldVisibility returns the old "visibility" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the Answer entity. +// If the Answer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldVisibility(ctx context.Context) (v hackathon.Visibility, err error) { +func (m *AnswerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVisibility is only allowed on UpdateOne operations") + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVisibility requires an ID field in the mutation") + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVisibility: %w", err) + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } - return oldValue.Visibility, nil + return oldValue.UpdatedAt, nil } -// ResetVisibility resets all changes to the "visibility" field. -func (m *HackathonMutation) ResetVisibility() { - m.visibility = nil +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AnswerMutation) ResetUpdatedAt() { + m.updated_at = nil } -// SetDescription sets the "description" field. -func (m *HackathonMutation) SetDescription(s string) { - m.description = &s +// ClearQuestion clears the "question" edge to the Question entity. +func (m *AnswerMutation) ClearQuestion() { + m.clearedquestion = true + m.clearedFields[answer.FieldQuestionID] = struct{}{} } -// Description returns the value of the "description" field in the mutation. -func (m *HackathonMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true +// QuestionCleared reports if the "question" edge to the Question entity was cleared. +func (m *AnswerMutation) QuestionCleared() bool { + return m.clearedquestion } -// OldDescription returns the old "description" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) +// QuestionIDs returns the "question" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// QuestionID instead. It exists only for internal usage by the builders. +func (m *AnswerMutation) QuestionIDs() (ids []uuid.UUID) { + if id := m.question; id != nil { + ids = append(ids, *id) } - return oldValue.Description, nil + return } -// ClearDescription clears the value of the "description" field. -func (m *HackathonMutation) ClearDescription() { - m.description = nil - m.clearedFields[hackathon.FieldDescription] = struct{}{} +// ResetQuestion resets all changes to the "question" edge. +func (m *AnswerMutation) ResetQuestion() { + m.question = nil + m.clearedquestion = false } -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *HackathonMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[hackathon.FieldDescription] - return ok +// ClearUser clears the "user" edge to the User entity. +func (m *AnswerMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[answer.FieldUserID] = struct{}{} } -// ResetDescription resets all changes to the "description" field. -func (m *HackathonMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, hackathon.FieldDescription) +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *AnswerMutation) UserCleared() bool { + return m.cleareduser } -// SetLogo sets the "logo" field. -func (m *HackathonMutation) SetLogo(s string) { - m.logo = &s +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *AnswerMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return } -// Logo returns the value of the "logo" field in the mutation. -func (m *HackathonMutation) Logo() (r string, exists bool) { - v := m.logo - if v == nil { - return - } - return *v, true +// ResetUser resets all changes to the "user" edge. +func (m *AnswerMutation) ResetUser() { + m.user = nil + m.cleareduser = false } -// OldLogo returns the old "logo" field's value of the Hackathon entity. -// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonMutation) OldLogo(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLogo is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLogo requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLogo: %w", err) +// Where appends a list predicates to the AnswerMutation builder. +func (m *AnswerMutation) Where(ps ...predicate.Answer) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the AnswerMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *AnswerMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Answer, len(ps)) + for i := range ps { + p[i] = ps[i] } - return oldValue.Logo, nil + m.Where(p...) } -// ClearLogo clears the value of the "logo" field. -func (m *HackathonMutation) ClearLogo() { - m.logo = nil - m.clearedFields[hackathon.FieldLogo] = struct{}{} +// Op returns the operation name. +func (m *AnswerMutation) Op() Op { + return m.op } -// LogoCleared returns if the "logo" field was cleared in this mutation. -func (m *HackathonMutation) LogoCleared() bool { - _, ok := m.clearedFields[hackathon.FieldLogo] - return ok +// SetOp allows setting the mutation operation. +func (m *AnswerMutation) SetOp(op Op) { + m.op = op } -// ResetLogo resets all changes to the "logo" field. -func (m *HackathonMutation) ResetLogo() { - m.logo = nil - delete(m.clearedFields, hackathon.FieldLogo) +// Type returns the node type of this mutation (Answer). +func (m *AnswerMutation) Type() string { + return m.typ } -// AddTrackIDs adds the "tracks" edge to the Track entity by ids. -func (m *HackathonMutation) AddTrackIDs(ids ...uuid.UUID) { - if m.tracks == nil { - m.tracks = make(map[uuid.UUID]struct{}) +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *AnswerMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.question != nil { + fields = append(fields, answer.FieldQuestionID) } - for i := range ids { - m.tracks[ids[i]] = struct{}{} + if m.user != nil { + fields = append(fields, answer.FieldUserID) + } + if m.value != nil { + fields = append(fields, answer.FieldValue) + } + if m._type != nil { + fields = append(fields, answer.FieldType) + } + if m.created_at != nil { + fields = append(fields, answer.FieldCreatedAt) } + if m.updated_at != nil { + fields = append(fields, answer.FieldUpdatedAt) + } + return fields } -// ClearTracks clears the "tracks" edge to the Track entity. -func (m *HackathonMutation) ClearTracks() { - m.clearedtracks = true +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *AnswerMutation) Field(name string) (ent.Value, bool) { + switch name { + case answer.FieldQuestionID: + return m.QuestionID() + case answer.FieldUserID: + return m.UserID() + case answer.FieldValue: + return m.Value() + case answer.FieldType: + return m.GetType() + case answer.FieldCreatedAt: + return m.CreatedAt() + case answer.FieldUpdatedAt: + return m.UpdatedAt() + } + return nil, false } -// TracksCleared reports if the "tracks" edge to the Track entity was cleared. -func (m *HackathonMutation) TracksCleared() bool { - return m.clearedtracks +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *AnswerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case answer.FieldQuestionID: + return m.OldQuestionID(ctx) + case answer.FieldUserID: + return m.OldUserID(ctx) + case answer.FieldValue: + return m.OldValue(ctx) + case answer.FieldType: + return m.OldType(ctx) + case answer.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case answer.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + } + return nil, fmt.Errorf("unknown Answer field %s", name) } -// RemoveTrackIDs removes the "tracks" edge to the Track entity by IDs. -func (m *HackathonMutation) RemoveTrackIDs(ids ...uuid.UUID) { - if m.removedtracks == nil { - m.removedtracks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.tracks, ids[i]) - m.removedtracks[ids[i]] = struct{}{} +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AnswerMutation) SetField(name string, value ent.Value) error { + switch name { + case answer.FieldQuestionID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetQuestionID(v) + return nil + case answer.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case answer.FieldValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetValue(v) + return nil + case answer.FieldType: + v, ok := value.(answer.Type) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case answer.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case answer.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } + return fmt.Errorf("unknown Answer field %s", name) } -// RemovedTracks returns the removed IDs of the "tracks" edge to the Track entity. -func (m *HackathonMutation) RemovedTracksIDs() (ids []uuid.UUID) { - for id := range m.removedtracks { - ids = append(ids, id) - } - return +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *AnswerMutation) AddedFields() []string { + return nil } -// TracksIDs returns the "tracks" edge IDs in the mutation. -func (m *HackathonMutation) TracksIDs() (ids []uuid.UUID) { - for id := range m.tracks { - ids = append(ids, id) +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *AnswerMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AnswerMutation) AddField(name string, value ent.Value) error { + switch name { } - return + return fmt.Errorf("unknown Answer numeric field %s", name) } -// ResetTracks resets all changes to the "tracks" edge. -func (m *HackathonMutation) ResetTracks() { - m.tracks = nil - m.clearedtracks = false - m.removedtracks = nil +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *AnswerMutation) ClearedFields() []string { + return nil } -// AddProjectIDs adds the "projects" edge to the Project entity by ids. -func (m *HackathonMutation) AddProjectIDs(ids ...uuid.UUID) { - if m.projects == nil { - m.projects = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.projects[ids[i]] = struct{}{} - } +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *AnswerMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok } -// ClearProjects clears the "projects" edge to the Project entity. -func (m *HackathonMutation) ClearProjects() { - m.clearedprojects = true +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *AnswerMutation) ClearField(name string) error { + return fmt.Errorf("unknown Answer nullable field %s", name) } -// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. -func (m *HackathonMutation) ProjectsCleared() bool { - return m.clearedprojects +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *AnswerMutation) ResetField(name string) error { + switch name { + case answer.FieldQuestionID: + m.ResetQuestionID() + return nil + case answer.FieldUserID: + m.ResetUserID() + return nil + case answer.FieldValue: + m.ResetValue() + return nil + case answer.FieldType: + m.ResetType() + return nil + case answer.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case answer.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + } + return fmt.Errorf("unknown Answer field %s", name) } -// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. -func (m *HackathonMutation) RemoveProjectIDs(ids ...uuid.UUID) { - if m.removedprojects == nil { - m.removedprojects = make(map[uuid.UUID]struct{}) +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *AnswerMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.question != nil { + edges = append(edges, answer.EdgeQuestion) } - for i := range ids { - delete(m.projects, ids[i]) - m.removedprojects[ids[i]] = struct{}{} + if m.user != nil { + edges = append(edges, answer.EdgeUser) } + return edges } -// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. -func (m *HackathonMutation) RemovedProjectsIDs() (ids []uuid.UUID) { - for id := range m.removedprojects { - ids = append(ids, id) +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *AnswerMutation) AddedIDs(name string) []ent.Value { + switch name { + case answer.EdgeQuestion: + if id := m.question; id != nil { + return []ent.Value{*id} + } + case answer.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } } - return + return nil } -// ProjectsIDs returns the "projects" edge IDs in the mutation. -func (m *HackathonMutation) ProjectsIDs() (ids []uuid.UUID) { - for id := range m.projects { - ids = append(ids, id) - } - return +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *AnswerMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges } -// ResetProjects resets all changes to the "projects" edge. -func (m *HackathonMutation) ResetProjects() { - m.projects = nil - m.clearedprojects = false - m.removedprojects = nil +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *AnswerMutation) RemovedIDs(name string) []ent.Value { + return nil } -// AddParticipatingUserIDs adds the "participating_users" edge to the User entity by ids. -func (m *HackathonMutation) AddParticipatingUserIDs(ids ...uuid.UUID) { - if m.participating_users == nil { - m.participating_users = make(map[uuid.UUID]struct{}) +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *AnswerMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedquestion { + edges = append(edges, answer.EdgeQuestion) } - for i := range ids { - m.participating_users[ids[i]] = struct{}{} + if m.cleareduser { + edges = append(edges, answer.EdgeUser) } + return edges } -// ClearParticipatingUsers clears the "participating_users" edge to the User entity. -func (m *HackathonMutation) ClearParticipatingUsers() { - m.clearedparticipating_users = true -} - -// ParticipatingUsersCleared reports if the "participating_users" edge to the User entity was cleared. -func (m *HackathonMutation) ParticipatingUsersCleared() bool { - return m.clearedparticipating_users -} - -// RemoveParticipatingUserIDs removes the "participating_users" edge to the User entity by IDs. -func (m *HackathonMutation) RemoveParticipatingUserIDs(ids ...uuid.UUID) { - if m.removedparticipating_users == nil { - m.removedparticipating_users = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.participating_users, ids[i]) - m.removedparticipating_users[ids[i]] = struct{}{} +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *AnswerMutation) EdgeCleared(name string) bool { + switch name { + case answer.EdgeQuestion: + return m.clearedquestion + case answer.EdgeUser: + return m.cleareduser } + return false } -// RemovedParticipatingUsers returns the removed IDs of the "participating_users" edge to the User entity. -func (m *HackathonMutation) RemovedParticipatingUsersIDs() (ids []uuid.UUID) { - for id := range m.removedparticipating_users { - ids = append(ids, id) +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *AnswerMutation) ClearEdge(name string) error { + switch name { + case answer.EdgeQuestion: + m.ClearQuestion() + return nil + case answer.EdgeUser: + m.ClearUser() + return nil } - return + return fmt.Errorf("unknown Answer unique edge %s", name) } -// ParticipatingUsersIDs returns the "participating_users" edge IDs in the mutation. -func (m *HackathonMutation) ParticipatingUsersIDs() (ids []uuid.UUID) { - for id := range m.participating_users { - ids = append(ids, id) +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *AnswerMutation) ResetEdge(name string) error { + switch name { + case answer.EdgeQuestion: + m.ResetQuestion() + return nil + case answer.EdgeUser: + m.ResetUser() + return nil } - return -} - -// ResetParticipatingUsers resets all changes to the "participating_users" edge. -func (m *HackathonMutation) ResetParticipatingUsers() { - m.participating_users = nil - m.clearedparticipating_users = false - m.removedparticipating_users = nil + return fmt.Errorf("unknown Answer edge %s", name) } -// AddPageIDs adds the "pages" edge to the Page entity by ids. -func (m *HackathonMutation) AddPageIDs(ids ...uuid.UUID) { - if m.pages == nil { - m.pages = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.pages[ids[i]] = struct{}{} - } +// HackathonMutation represents an operation that mutates the Hackathon nodes in the graph. +type HackathonMutation struct { + config + op Op + typ string + id *uuid.UUID + name *string + starts_at *time.Time + ends_at *time.Time + created_at *time.Time + modified_at *time.Time + visibility *hackathon.Visibility + description *string + logo *string + clearedFields map[string]struct{} + tracks map[uuid.UUID]struct{} + removedtracks map[uuid.UUID]struct{} + clearedtracks bool + projects map[uuid.UUID]struct{} + removedprojects map[uuid.UUID]struct{} + clearedprojects bool + participating_users map[uuid.UUID]struct{} + removedparticipating_users map[uuid.UUID]struct{} + clearedparticipating_users bool + pages map[uuid.UUID]struct{} + removedpages map[uuid.UUID]struct{} + clearedpages bool + phases map[uuid.UUID]struct{} + removedphases map[uuid.UUID]struct{} + clearedphases bool + state *uuid.UUID + clearedstate bool + vote_categories map[uuid.UUID]struct{} + removedvote_categories map[uuid.UUID]struct{} + clearedvote_categories bool + questions map[uuid.UUID]struct{} + removedquestions map[uuid.UUID]struct{} + clearedquestions bool + owners map[uuid.UUID]struct{} + removedowners map[uuid.UUID]struct{} + clearedowners bool + creator *uuid.UUID + clearedcreator bool + modifier *uuid.UUID + clearedmodifier bool + done bool + oldValue func(context.Context) (*Hackathon, error) + predicates []predicate.Hackathon } -// ClearPages clears the "pages" edge to the Page entity. -func (m *HackathonMutation) ClearPages() { - m.clearedpages = true -} +var _ ent.Mutation = (*HackathonMutation)(nil) -// PagesCleared reports if the "pages" edge to the Page entity was cleared. -func (m *HackathonMutation) PagesCleared() bool { - return m.clearedpages -} +// hackathonOption allows management of the mutation configuration using functional options. +type hackathonOption func(*HackathonMutation) -// RemovePageIDs removes the "pages" edge to the Page entity by IDs. -func (m *HackathonMutation) RemovePageIDs(ids ...uuid.UUID) { - if m.removedpages == nil { - m.removedpages = make(map[uuid.UUID]struct{}) +// newHackathonMutation creates new mutation for the Hackathon entity. +func newHackathonMutation(c config, op Op, opts ...hackathonOption) *HackathonMutation { + m := &HackathonMutation{ + config: c, + op: op, + typ: TypeHackathon, + clearedFields: make(map[string]struct{}), } - for i := range ids { - delete(m.pages, ids[i]) - m.removedpages[ids[i]] = struct{}{} + for _, opt := range opts { + opt(m) } + return m } -// RemovedPages returns the removed IDs of the "pages" edge to the Page entity. -func (m *HackathonMutation) RemovedPagesIDs() (ids []uuid.UUID) { - for id := range m.removedpages { - ids = append(ids, id) +// withHackathonID sets the ID field of the mutation. +func withHackathonID(id uuid.UUID) hackathonOption { + return func(m *HackathonMutation) { + var ( + err error + once sync.Once + value *Hackathon + ) + m.oldValue = func(ctx context.Context) (*Hackathon, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Hackathon.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - return } -// PagesIDs returns the "pages" edge IDs in the mutation. -func (m *HackathonMutation) PagesIDs() (ids []uuid.UUID) { - for id := range m.pages { - ids = append(ids, id) +// withHackathon sets the old Hackathon of the mutation. +func withHackathon(node *Hackathon) hackathonOption { + return func(m *HackathonMutation) { + m.oldValue = func(context.Context) (*Hackathon, error) { + return node, nil + } + m.id = &node.ID } - return } -// ResetPages resets all changes to the "pages" edge. -func (m *HackathonMutation) ResetPages() { - m.pages = nil - m.clearedpages = false - m.removedpages = nil +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m HackathonMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// AddPhaseIDs adds the "phases" edge to the Phase entity by ids. -func (m *HackathonMutation) AddPhaseIDs(ids ...uuid.UUID) { - if m.phases == nil { - m.phases = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.phases[ids[i]] = struct{}{} +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m HackathonMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ClearPhases clears the "phases" edge to the Phase entity. -func (m *HackathonMutation) ClearPhases() { - m.clearedphases = true +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Hackathon entities. +func (m *HackathonMutation) SetID(id uuid.UUID) { + m.id = &id } -// PhasesCleared reports if the "phases" edge to the Phase entity was cleared. -func (m *HackathonMutation) PhasesCleared() bool { - return m.clearedphases +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *HackathonMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// RemovePhaseIDs removes the "phases" edge to the Phase entity by IDs. -func (m *HackathonMutation) RemovePhaseIDs(ids ...uuid.UUID) { - if m.removedphases == nil { - m.removedphases = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.phases, ids[i]) - m.removedphases[ids[i]] = struct{}{} +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *HackathonMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Hackathon.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// RemovedPhases returns the removed IDs of the "phases" edge to the Phase entity. -func (m *HackathonMutation) RemovedPhasesIDs() (ids []uuid.UUID) { - for id := range m.removedphases { - ids = append(ids, id) - } - return +// SetName sets the "name" field. +func (m *HackathonMutation) SetName(s string) { + m.name = &s } -// PhasesIDs returns the "phases" edge IDs in the mutation. -func (m *HackathonMutation) PhasesIDs() (ids []uuid.UUID) { - for id := range m.phases { - ids = append(ids, id) +// Name returns the value of the "name" field in the mutation. +func (m *HackathonMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return } - return -} - -// ResetPhases resets all changes to the "phases" edge. -func (m *HackathonMutation) ResetPhases() { - m.phases = nil - m.clearedphases = false - m.removedphases = nil + return *v, true } -// SetStateID sets the "state" edge to the HackathonState entity by id. -func (m *HackathonMutation) SetStateID(id uuid.UUID) { - m.state = &id +// OldName returns the old "name" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil } -// ClearState clears the "state" edge to the HackathonState entity. -func (m *HackathonMutation) ClearState() { - m.clearedstate = true +// ResetName resets all changes to the "name" field. +func (m *HackathonMutation) ResetName() { + m.name = nil } -// StateCleared reports if the "state" edge to the HackathonState entity was cleared. -func (m *HackathonMutation) StateCleared() bool { - return m.clearedstate +// SetStartsAt sets the "starts_at" field. +func (m *HackathonMutation) SetStartsAt(t time.Time) { + m.starts_at = &t } -// StateID returns the "state" edge ID in the mutation. -func (m *HackathonMutation) StateID() (id uuid.UUID, exists bool) { - if m.state != nil { - return *m.state, true +// StartsAt returns the value of the "starts_at" field in the mutation. +func (m *HackathonMutation) StartsAt() (r time.Time, exists bool) { + v := m.starts_at + if v == nil { + return } - return + return *v, true } -// StateIDs returns the "state" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// StateID instead. It exists only for internal usage by the builders. -func (m *HackathonMutation) StateIDs() (ids []uuid.UUID) { - if id := m.state; id != nil { - ids = append(ids, *id) +// OldStartsAt returns the old "starts_at" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldStartsAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStartsAt is only allowed on UpdateOne operations") } - return -} - -// ResetState resets all changes to the "state" edge. -func (m *HackathonMutation) ResetState() { - m.state = nil - m.clearedstate = false -} - -// AddVoteCategoryIDs adds the "vote_categories" edge to the VoteCategory entity by ids. -func (m *HackathonMutation) AddVoteCategoryIDs(ids ...uuid.UUID) { - if m.vote_categories == nil { - m.vote_categories = make(map[uuid.UUID]struct{}) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStartsAt requires an ID field in the mutation") } - for i := range ids { - m.vote_categories[ids[i]] = struct{}{} + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStartsAt: %w", err) } + return oldValue.StartsAt, nil } -// ClearVoteCategories clears the "vote_categories" edge to the VoteCategory entity. -func (m *HackathonMutation) ClearVoteCategories() { - m.clearedvote_categories = true +// ClearStartsAt clears the value of the "starts_at" field. +func (m *HackathonMutation) ClearStartsAt() { + m.starts_at = nil + m.clearedFields[hackathon.FieldStartsAt] = struct{}{} } -// VoteCategoriesCleared reports if the "vote_categories" edge to the VoteCategory entity was cleared. -func (m *HackathonMutation) VoteCategoriesCleared() bool { - return m.clearedvote_categories +// StartsAtCleared returns if the "starts_at" field was cleared in this mutation. +func (m *HackathonMutation) StartsAtCleared() bool { + _, ok := m.clearedFields[hackathon.FieldStartsAt] + return ok } -// RemoveVoteCategoryIDs removes the "vote_categories" edge to the VoteCategory entity by IDs. -func (m *HackathonMutation) RemoveVoteCategoryIDs(ids ...uuid.UUID) { - if m.removedvote_categories == nil { - m.removedvote_categories = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.vote_categories, ids[i]) - m.removedvote_categories[ids[i]] = struct{}{} - } +// ResetStartsAt resets all changes to the "starts_at" field. +func (m *HackathonMutation) ResetStartsAt() { + m.starts_at = nil + delete(m.clearedFields, hackathon.FieldStartsAt) } -// RemovedVoteCategories returns the removed IDs of the "vote_categories" edge to the VoteCategory entity. -func (m *HackathonMutation) RemovedVoteCategoriesIDs() (ids []uuid.UUID) { - for id := range m.removedvote_categories { - ids = append(ids, id) - } - return +// SetEndsAt sets the "ends_at" field. +func (m *HackathonMutation) SetEndsAt(t time.Time) { + m.ends_at = &t } -// VoteCategoriesIDs returns the "vote_categories" edge IDs in the mutation. -func (m *HackathonMutation) VoteCategoriesIDs() (ids []uuid.UUID) { - for id := range m.vote_categories { - ids = append(ids, id) +// EndsAt returns the value of the "ends_at" field in the mutation. +func (m *HackathonMutation) EndsAt() (r time.Time, exists bool) { + v := m.ends_at + if v == nil { + return } - return -} - -// ResetVoteCategories resets all changes to the "vote_categories" edge. -func (m *HackathonMutation) ResetVoteCategories() { - m.vote_categories = nil - m.clearedvote_categories = false - m.removedvote_categories = nil + return *v, true } -// AddOwnerIDs adds the "owners" edge to the User entity by ids. -func (m *HackathonMutation) AddOwnerIDs(ids ...uuid.UUID) { - if m.owners == nil { - m.owners = make(map[uuid.UUID]struct{}) +// OldEndsAt returns the old "ends_at" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldEndsAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEndsAt is only allowed on UpdateOne operations") } - for i := range ids { - m.owners[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEndsAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEndsAt: %w", err) } + return oldValue.EndsAt, nil } -// ClearOwners clears the "owners" edge to the User entity. -func (m *HackathonMutation) ClearOwners() { - m.clearedowners = true +// ClearEndsAt clears the value of the "ends_at" field. +func (m *HackathonMutation) ClearEndsAt() { + m.ends_at = nil + m.clearedFields[hackathon.FieldEndsAt] = struct{}{} } -// OwnersCleared reports if the "owners" edge to the User entity was cleared. -func (m *HackathonMutation) OwnersCleared() bool { - return m.clearedowners +// EndsAtCleared returns if the "ends_at" field was cleared in this mutation. +func (m *HackathonMutation) EndsAtCleared() bool { + _, ok := m.clearedFields[hackathon.FieldEndsAt] + return ok } -// RemoveOwnerIDs removes the "owners" edge to the User entity by IDs. -func (m *HackathonMutation) RemoveOwnerIDs(ids ...uuid.UUID) { - if m.removedowners == nil { - m.removedowners = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.owners, ids[i]) - m.removedowners[ids[i]] = struct{}{} - } +// ResetEndsAt resets all changes to the "ends_at" field. +func (m *HackathonMutation) ResetEndsAt() { + m.ends_at = nil + delete(m.clearedFields, hackathon.FieldEndsAt) } -// RemovedOwners returns the removed IDs of the "owners" edge to the User entity. -func (m *HackathonMutation) RemovedOwnersIDs() (ids []uuid.UUID) { - for id := range m.removedowners { - ids = append(ids, id) - } - return +// SetCreatedAt sets the "created_at" field. +func (m *HackathonMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// OwnersIDs returns the "owners" edge IDs in the mutation. -func (m *HackathonMutation) OwnersIDs() (ids []uuid.UUID) { - for id := range m.owners { - ids = append(ids, id) +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *HackathonMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return } - return + return *v, true } -// ResetOwners resets all changes to the "owners" edge. -func (m *HackathonMutation) ResetOwners() { - m.owners = nil - m.clearedowners = false - m.removedowners = nil +// OldCreatedAt returns the old "created_at" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil } -// SetCreatorID sets the "creator" edge to the User entity by id. -func (m *HackathonMutation) SetCreatorID(id uuid.UUID) { - m.creator = &id +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *HackathonMutation) ResetCreatedAt() { + m.created_at = nil } -// ClearCreator clears the "creator" edge to the User entity. -func (m *HackathonMutation) ClearCreator() { - m.clearedcreator = true +// SetModifiedAt sets the "modified_at" field. +func (m *HackathonMutation) SetModifiedAt(t time.Time) { + m.modified_at = &t } -// CreatorCleared reports if the "creator" edge to the User entity was cleared. -func (m *HackathonMutation) CreatorCleared() bool { - return m.clearedcreator +// ModifiedAt returns the value of the "modified_at" field in the mutation. +func (m *HackathonMutation) ModifiedAt() (r time.Time, exists bool) { + v := m.modified_at + if v == nil { + return + } + return *v, true } -// CreatorID returns the "creator" edge ID in the mutation. -func (m *HackathonMutation) CreatorID() (id uuid.UUID, exists bool) { - if m.creator != nil { - return *m.creator, true +// OldModifiedAt returns the old "modified_at" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) + } + return oldValue.ModifiedAt, nil } -// CreatorIDs returns the "creator" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// CreatorID instead. It exists only for internal usage by the builders. -func (m *HackathonMutation) CreatorIDs() (ids []uuid.UUID) { - if id := m.creator; id != nil { - ids = append(ids, *id) - } - return +// ResetModifiedAt resets all changes to the "modified_at" field. +func (m *HackathonMutation) ResetModifiedAt() { + m.modified_at = nil } -// ResetCreator resets all changes to the "creator" edge. -func (m *HackathonMutation) ResetCreator() { - m.creator = nil - m.clearedcreator = false +// SetVisibility sets the "visibility" field. +func (m *HackathonMutation) SetVisibility(h hackathon.Visibility) { + m.visibility = &h } -// SetModifierID sets the "modifier" edge to the User entity by id. -func (m *HackathonMutation) SetModifierID(id uuid.UUID) { - m.modifier = &id +// Visibility returns the value of the "visibility" field in the mutation. +func (m *HackathonMutation) Visibility() (r hackathon.Visibility, exists bool) { + v := m.visibility + if v == nil { + return + } + return *v, true } -// ClearModifier clears the "modifier" edge to the User entity. -func (m *HackathonMutation) ClearModifier() { - m.clearedmodifier = true +// OldVisibility returns the old "visibility" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldVisibility(ctx context.Context) (v hackathon.Visibility, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVisibility is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVisibility requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVisibility: %w", err) + } + return oldValue.Visibility, nil } -// ModifierCleared reports if the "modifier" edge to the User entity was cleared. -func (m *HackathonMutation) ModifierCleared() bool { - return m.clearedmodifier +// ResetVisibility resets all changes to the "visibility" field. +func (m *HackathonMutation) ResetVisibility() { + m.visibility = nil } -// ModifierID returns the "modifier" edge ID in the mutation. -func (m *HackathonMutation) ModifierID() (id uuid.UUID, exists bool) { - if m.modifier != nil { - return *m.modifier, true - } - return +// SetDescription sets the "description" field. +func (m *HackathonMutation) SetDescription(s string) { + m.description = &s } -// ModifierIDs returns the "modifier" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ModifierID instead. It exists only for internal usage by the builders. -func (m *HackathonMutation) ModifierIDs() (ids []uuid.UUID) { - if id := m.modifier; id != nil { - ids = append(ids, *id) +// Description returns the value of the "description" field in the mutation. +func (m *HackathonMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return } - return + return *v, true } -// ResetModifier resets all changes to the "modifier" edge. -func (m *HackathonMutation) ResetModifier() { - m.modifier = nil - m.clearedmodifier = false +// OldDescription returns the old "description" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil } -// Where appends a list predicates to the HackathonMutation builder. -func (m *HackathonMutation) Where(ps ...predicate.Hackathon) { - m.predicates = append(m.predicates, ps...) +// ClearDescription clears the value of the "description" field. +func (m *HackathonMutation) ClearDescription() { + m.description = nil + m.clearedFields[hackathon.FieldDescription] = struct{}{} } -// WhereP appends storage-level predicates to the HackathonMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *HackathonMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Hackathon, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *HackathonMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[hackathon.FieldDescription] + return ok } -// Op returns the operation name. -func (m *HackathonMutation) Op() Op { - return m.op +// ResetDescription resets all changes to the "description" field. +func (m *HackathonMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, hackathon.FieldDescription) } -// SetOp allows setting the mutation operation. -func (m *HackathonMutation) SetOp(op Op) { - m.op = op +// SetLogo sets the "logo" field. +func (m *HackathonMutation) SetLogo(s string) { + m.logo = &s } -// Type returns the node type of this mutation (Hackathon). -func (m *HackathonMutation) Type() string { - return m.typ +// Logo returns the value of the "logo" field in the mutation. +func (m *HackathonMutation) Logo() (r string, exists bool) { + v := m.logo + if v == nil { + return + } + return *v, true } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *HackathonMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.name != nil { - fields = append(fields, hackathon.FieldName) - } - if m.starts_at != nil { - fields = append(fields, hackathon.FieldStartsAt) - } - if m.ends_at != nil { - fields = append(fields, hackathon.FieldEndsAt) - } - if m.created_at != nil { - fields = append(fields, hackathon.FieldCreatedAt) +// OldLogo returns the old "logo" field's value of the Hackathon entity. +// If the Hackathon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonMutation) OldLogo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLogo is only allowed on UpdateOne operations") } - if m.modified_at != nil { - fields = append(fields, hackathon.FieldModifiedAt) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLogo requires an ID field in the mutation") } - if m.visibility != nil { - fields = append(fields, hackathon.FieldVisibility) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLogo: %w", err) } - if m.description != nil { - fields = append(fields, hackathon.FieldDescription) + return oldValue.Logo, nil +} + +// ClearLogo clears the value of the "logo" field. +func (m *HackathonMutation) ClearLogo() { + m.logo = nil + m.clearedFields[hackathon.FieldLogo] = struct{}{} +} + +// LogoCleared returns if the "logo" field was cleared in this mutation. +func (m *HackathonMutation) LogoCleared() bool { + _, ok := m.clearedFields[hackathon.FieldLogo] + return ok +} + +// ResetLogo resets all changes to the "logo" field. +func (m *HackathonMutation) ResetLogo() { + m.logo = nil + delete(m.clearedFields, hackathon.FieldLogo) +} + +// AddTrackIDs adds the "tracks" edge to the Track entity by ids. +func (m *HackathonMutation) AddTrackIDs(ids ...uuid.UUID) { + if m.tracks == nil { + m.tracks = make(map[uuid.UUID]struct{}) } - if m.logo != nil { - fields = append(fields, hackathon.FieldLogo) + for i := range ids { + m.tracks[ids[i]] = struct{}{} } - return fields } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *HackathonMutation) Field(name string) (ent.Value, bool) { - switch name { - case hackathon.FieldName: - return m.Name() - case hackathon.FieldStartsAt: - return m.StartsAt() - case hackathon.FieldEndsAt: - return m.EndsAt() - case hackathon.FieldCreatedAt: - return m.CreatedAt() - case hackathon.FieldModifiedAt: - return m.ModifiedAt() - case hackathon.FieldVisibility: - return m.Visibility() - case hackathon.FieldDescription: - return m.Description() - case hackathon.FieldLogo: - return m.Logo() +// ClearTracks clears the "tracks" edge to the Track entity. +func (m *HackathonMutation) ClearTracks() { + m.clearedtracks = true +} + +// TracksCleared reports if the "tracks" edge to the Track entity was cleared. +func (m *HackathonMutation) TracksCleared() bool { + return m.clearedtracks +} + +// RemoveTrackIDs removes the "tracks" edge to the Track entity by IDs. +func (m *HackathonMutation) RemoveTrackIDs(ids ...uuid.UUID) { + if m.removedtracks == nil { + m.removedtracks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.tracks, ids[i]) + m.removedtracks[ids[i]] = struct{}{} } - return nil, false } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. +// RemovedTracks returns the removed IDs of the "tracks" edge to the Track entity. +func (m *HackathonMutation) RemovedTracksIDs() (ids []uuid.UUID) { + for id := range m.removedtracks { + ids = append(ids, id) + } + return +} + +// TracksIDs returns the "tracks" edge IDs in the mutation. +func (m *HackathonMutation) TracksIDs() (ids []uuid.UUID) { + for id := range m.tracks { + ids = append(ids, id) + } + return +} + +// ResetTracks resets all changes to the "tracks" edge. +func (m *HackathonMutation) ResetTracks() { + m.tracks = nil + m.clearedtracks = false + m.removedtracks = nil +} + +// AddProjectIDs adds the "projects" edge to the Project entity by ids. +func (m *HackathonMutation) AddProjectIDs(ids ...uuid.UUID) { + if m.projects == nil { + m.projects = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.projects[ids[i]] = struct{}{} + } +} + +// ClearProjects clears the "projects" edge to the Project entity. +func (m *HackathonMutation) ClearProjects() { + m.clearedprojects = true +} + +// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. +func (m *HackathonMutation) ProjectsCleared() bool { + return m.clearedprojects +} + +// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. +func (m *HackathonMutation) RemoveProjectIDs(ids ...uuid.UUID) { + if m.removedprojects == nil { + m.removedprojects = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.projects, ids[i]) + m.removedprojects[ids[i]] = struct{}{} + } +} + +// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. +func (m *HackathonMutation) RemovedProjectsIDs() (ids []uuid.UUID) { + for id := range m.removedprojects { + ids = append(ids, id) + } + return +} + +// ProjectsIDs returns the "projects" edge IDs in the mutation. +func (m *HackathonMutation) ProjectsIDs() (ids []uuid.UUID) { + for id := range m.projects { + ids = append(ids, id) + } + return +} + +// ResetProjects resets all changes to the "projects" edge. +func (m *HackathonMutation) ResetProjects() { + m.projects = nil + m.clearedprojects = false + m.removedprojects = nil +} + +// AddParticipatingUserIDs adds the "participating_users" edge to the User entity by ids. +func (m *HackathonMutation) AddParticipatingUserIDs(ids ...uuid.UUID) { + if m.participating_users == nil { + m.participating_users = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.participating_users[ids[i]] = struct{}{} + } +} + +// ClearParticipatingUsers clears the "participating_users" edge to the User entity. +func (m *HackathonMutation) ClearParticipatingUsers() { + m.clearedparticipating_users = true +} + +// ParticipatingUsersCleared reports if the "participating_users" edge to the User entity was cleared. +func (m *HackathonMutation) ParticipatingUsersCleared() bool { + return m.clearedparticipating_users +} + +// RemoveParticipatingUserIDs removes the "participating_users" edge to the User entity by IDs. +func (m *HackathonMutation) RemoveParticipatingUserIDs(ids ...uuid.UUID) { + if m.removedparticipating_users == nil { + m.removedparticipating_users = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.participating_users, ids[i]) + m.removedparticipating_users[ids[i]] = struct{}{} + } +} + +// RemovedParticipatingUsers returns the removed IDs of the "participating_users" edge to the User entity. +func (m *HackathonMutation) RemovedParticipatingUsersIDs() (ids []uuid.UUID) { + for id := range m.removedparticipating_users { + ids = append(ids, id) + } + return +} + +// ParticipatingUsersIDs returns the "participating_users" edge IDs in the mutation. +func (m *HackathonMutation) ParticipatingUsersIDs() (ids []uuid.UUID) { + for id := range m.participating_users { + ids = append(ids, id) + } + return +} + +// ResetParticipatingUsers resets all changes to the "participating_users" edge. +func (m *HackathonMutation) ResetParticipatingUsers() { + m.participating_users = nil + m.clearedparticipating_users = false + m.removedparticipating_users = nil +} + +// AddPageIDs adds the "pages" edge to the Page entity by ids. +func (m *HackathonMutation) AddPageIDs(ids ...uuid.UUID) { + if m.pages == nil { + m.pages = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.pages[ids[i]] = struct{}{} + } +} + +// ClearPages clears the "pages" edge to the Page entity. +func (m *HackathonMutation) ClearPages() { + m.clearedpages = true +} + +// PagesCleared reports if the "pages" edge to the Page entity was cleared. +func (m *HackathonMutation) PagesCleared() bool { + return m.clearedpages +} + +// RemovePageIDs removes the "pages" edge to the Page entity by IDs. +func (m *HackathonMutation) RemovePageIDs(ids ...uuid.UUID) { + if m.removedpages == nil { + m.removedpages = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.pages, ids[i]) + m.removedpages[ids[i]] = struct{}{} + } +} + +// RemovedPages returns the removed IDs of the "pages" edge to the Page entity. +func (m *HackathonMutation) RemovedPagesIDs() (ids []uuid.UUID) { + for id := range m.removedpages { + ids = append(ids, id) + } + return +} + +// PagesIDs returns the "pages" edge IDs in the mutation. +func (m *HackathonMutation) PagesIDs() (ids []uuid.UUID) { + for id := range m.pages { + ids = append(ids, id) + } + return +} + +// ResetPages resets all changes to the "pages" edge. +func (m *HackathonMutation) ResetPages() { + m.pages = nil + m.clearedpages = false + m.removedpages = nil +} + +// AddPhaseIDs adds the "phases" edge to the Phase entity by ids. +func (m *HackathonMutation) AddPhaseIDs(ids ...uuid.UUID) { + if m.phases == nil { + m.phases = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.phases[ids[i]] = struct{}{} + } +} + +// ClearPhases clears the "phases" edge to the Phase entity. +func (m *HackathonMutation) ClearPhases() { + m.clearedphases = true +} + +// PhasesCleared reports if the "phases" edge to the Phase entity was cleared. +func (m *HackathonMutation) PhasesCleared() bool { + return m.clearedphases +} + +// RemovePhaseIDs removes the "phases" edge to the Phase entity by IDs. +func (m *HackathonMutation) RemovePhaseIDs(ids ...uuid.UUID) { + if m.removedphases == nil { + m.removedphases = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.phases, ids[i]) + m.removedphases[ids[i]] = struct{}{} + } +} + +// RemovedPhases returns the removed IDs of the "phases" edge to the Phase entity. +func (m *HackathonMutation) RemovedPhasesIDs() (ids []uuid.UUID) { + for id := range m.removedphases { + ids = append(ids, id) + } + return +} + +// PhasesIDs returns the "phases" edge IDs in the mutation. +func (m *HackathonMutation) PhasesIDs() (ids []uuid.UUID) { + for id := range m.phases { + ids = append(ids, id) + } + return +} + +// ResetPhases resets all changes to the "phases" edge. +func (m *HackathonMutation) ResetPhases() { + m.phases = nil + m.clearedphases = false + m.removedphases = nil +} + +// SetStateID sets the "state" edge to the HackathonState entity by id. +func (m *HackathonMutation) SetStateID(id uuid.UUID) { + m.state = &id +} + +// ClearState clears the "state" edge to the HackathonState entity. +func (m *HackathonMutation) ClearState() { + m.clearedstate = true +} + +// StateCleared reports if the "state" edge to the HackathonState entity was cleared. +func (m *HackathonMutation) StateCleared() bool { + return m.clearedstate +} + +// StateID returns the "state" edge ID in the mutation. +func (m *HackathonMutation) StateID() (id uuid.UUID, exists bool) { + if m.state != nil { + return *m.state, true + } + return +} + +// StateIDs returns the "state" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// StateID instead. It exists only for internal usage by the builders. +func (m *HackathonMutation) StateIDs() (ids []uuid.UUID) { + if id := m.state; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetState resets all changes to the "state" edge. +func (m *HackathonMutation) ResetState() { + m.state = nil + m.clearedstate = false +} + +// AddVoteCategoryIDs adds the "vote_categories" edge to the VoteCategory entity by ids. +func (m *HackathonMutation) AddVoteCategoryIDs(ids ...uuid.UUID) { + if m.vote_categories == nil { + m.vote_categories = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.vote_categories[ids[i]] = struct{}{} + } +} + +// ClearVoteCategories clears the "vote_categories" edge to the VoteCategory entity. +func (m *HackathonMutation) ClearVoteCategories() { + m.clearedvote_categories = true +} + +// VoteCategoriesCleared reports if the "vote_categories" edge to the VoteCategory entity was cleared. +func (m *HackathonMutation) VoteCategoriesCleared() bool { + return m.clearedvote_categories +} + +// RemoveVoteCategoryIDs removes the "vote_categories" edge to the VoteCategory entity by IDs. +func (m *HackathonMutation) RemoveVoteCategoryIDs(ids ...uuid.UUID) { + if m.removedvote_categories == nil { + m.removedvote_categories = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.vote_categories, ids[i]) + m.removedvote_categories[ids[i]] = struct{}{} + } +} + +// RemovedVoteCategories returns the removed IDs of the "vote_categories" edge to the VoteCategory entity. +func (m *HackathonMutation) RemovedVoteCategoriesIDs() (ids []uuid.UUID) { + for id := range m.removedvote_categories { + ids = append(ids, id) + } + return +} + +// VoteCategoriesIDs returns the "vote_categories" edge IDs in the mutation. +func (m *HackathonMutation) VoteCategoriesIDs() (ids []uuid.UUID) { + for id := range m.vote_categories { + ids = append(ids, id) + } + return +} + +// ResetVoteCategories resets all changes to the "vote_categories" edge. +func (m *HackathonMutation) ResetVoteCategories() { + m.vote_categories = nil + m.clearedvote_categories = false + m.removedvote_categories = nil +} + +// AddQuestionIDs adds the "questions" edge to the Question entity by ids. +func (m *HackathonMutation) AddQuestionIDs(ids ...uuid.UUID) { + if m.questions == nil { + m.questions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.questions[ids[i]] = struct{}{} + } +} + +// ClearQuestions clears the "questions" edge to the Question entity. +func (m *HackathonMutation) ClearQuestions() { + m.clearedquestions = true +} + +// QuestionsCleared reports if the "questions" edge to the Question entity was cleared. +func (m *HackathonMutation) QuestionsCleared() bool { + return m.clearedquestions +} + +// RemoveQuestionIDs removes the "questions" edge to the Question entity by IDs. +func (m *HackathonMutation) RemoveQuestionIDs(ids ...uuid.UUID) { + if m.removedquestions == nil { + m.removedquestions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.questions, ids[i]) + m.removedquestions[ids[i]] = struct{}{} + } +} + +// RemovedQuestions returns the removed IDs of the "questions" edge to the Question entity. +func (m *HackathonMutation) RemovedQuestionsIDs() (ids []uuid.UUID) { + for id := range m.removedquestions { + ids = append(ids, id) + } + return +} + +// QuestionsIDs returns the "questions" edge IDs in the mutation. +func (m *HackathonMutation) QuestionsIDs() (ids []uuid.UUID) { + for id := range m.questions { + ids = append(ids, id) + } + return +} + +// ResetQuestions resets all changes to the "questions" edge. +func (m *HackathonMutation) ResetQuestions() { + m.questions = nil + m.clearedquestions = false + m.removedquestions = nil +} + +// AddOwnerIDs adds the "owners" edge to the User entity by ids. +func (m *HackathonMutation) AddOwnerIDs(ids ...uuid.UUID) { + if m.owners == nil { + m.owners = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.owners[ids[i]] = struct{}{} + } +} + +// ClearOwners clears the "owners" edge to the User entity. +func (m *HackathonMutation) ClearOwners() { + m.clearedowners = true +} + +// OwnersCleared reports if the "owners" edge to the User entity was cleared. +func (m *HackathonMutation) OwnersCleared() bool { + return m.clearedowners +} + +// RemoveOwnerIDs removes the "owners" edge to the User entity by IDs. +func (m *HackathonMutation) RemoveOwnerIDs(ids ...uuid.UUID) { + if m.removedowners == nil { + m.removedowners = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.owners, ids[i]) + m.removedowners[ids[i]] = struct{}{} + } +} + +// RemovedOwners returns the removed IDs of the "owners" edge to the User entity. +func (m *HackathonMutation) RemovedOwnersIDs() (ids []uuid.UUID) { + for id := range m.removedowners { + ids = append(ids, id) + } + return +} + +// OwnersIDs returns the "owners" edge IDs in the mutation. +func (m *HackathonMutation) OwnersIDs() (ids []uuid.UUID) { + for id := range m.owners { + ids = append(ids, id) + } + return +} + +// ResetOwners resets all changes to the "owners" edge. +func (m *HackathonMutation) ResetOwners() { + m.owners = nil + m.clearedowners = false + m.removedowners = nil +} + +// SetCreatorID sets the "creator" edge to the User entity by id. +func (m *HackathonMutation) SetCreatorID(id uuid.UUID) { + m.creator = &id +} + +// ClearCreator clears the "creator" edge to the User entity. +func (m *HackathonMutation) ClearCreator() { + m.clearedcreator = true +} + +// CreatorCleared reports if the "creator" edge to the User entity was cleared. +func (m *HackathonMutation) CreatorCleared() bool { + return m.clearedcreator +} + +// CreatorID returns the "creator" edge ID in the mutation. +func (m *HackathonMutation) CreatorID() (id uuid.UUID, exists bool) { + if m.creator != nil { + return *m.creator, true + } + return +} + +// CreatorIDs returns the "creator" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// CreatorID instead. It exists only for internal usage by the builders. +func (m *HackathonMutation) CreatorIDs() (ids []uuid.UUID) { + if id := m.creator; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetCreator resets all changes to the "creator" edge. +func (m *HackathonMutation) ResetCreator() { + m.creator = nil + m.clearedcreator = false +} + +// SetModifierID sets the "modifier" edge to the User entity by id. +func (m *HackathonMutation) SetModifierID(id uuid.UUID) { + m.modifier = &id +} + +// ClearModifier clears the "modifier" edge to the User entity. +func (m *HackathonMutation) ClearModifier() { + m.clearedmodifier = true +} + +// ModifierCleared reports if the "modifier" edge to the User entity was cleared. +func (m *HackathonMutation) ModifierCleared() bool { + return m.clearedmodifier +} + +// ModifierID returns the "modifier" edge ID in the mutation. +func (m *HackathonMutation) ModifierID() (id uuid.UUID, exists bool) { + if m.modifier != nil { + return *m.modifier, true + } + return +} + +// ModifierIDs returns the "modifier" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModifierID instead. It exists only for internal usage by the builders. +func (m *HackathonMutation) ModifierIDs() (ids []uuid.UUID) { + if id := m.modifier; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetModifier resets all changes to the "modifier" edge. +func (m *HackathonMutation) ResetModifier() { + m.modifier = nil + m.clearedmodifier = false +} + +// Where appends a list predicates to the HackathonMutation builder. +func (m *HackathonMutation) Where(ps ...predicate.Hackathon) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the HackathonMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *HackathonMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Hackathon, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *HackathonMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *HackathonMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Hackathon). +func (m *HackathonMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *HackathonMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.name != nil { + fields = append(fields, hackathon.FieldName) + } + if m.starts_at != nil { + fields = append(fields, hackathon.FieldStartsAt) + } + if m.ends_at != nil { + fields = append(fields, hackathon.FieldEndsAt) + } + if m.created_at != nil { + fields = append(fields, hackathon.FieldCreatedAt) + } + if m.modified_at != nil { + fields = append(fields, hackathon.FieldModifiedAt) + } + if m.visibility != nil { + fields = append(fields, hackathon.FieldVisibility) + } + if m.description != nil { + fields = append(fields, hackathon.FieldDescription) + } + if m.logo != nil { + fields = append(fields, hackathon.FieldLogo) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *HackathonMutation) Field(name string) (ent.Value, bool) { + switch name { + case hackathon.FieldName: + return m.Name() + case hackathon.FieldStartsAt: + return m.StartsAt() + case hackathon.FieldEndsAt: + return m.EndsAt() + case hackathon.FieldCreatedAt: + return m.CreatedAt() + case hackathon.FieldModifiedAt: + return m.ModifiedAt() + case hackathon.FieldVisibility: + return m.Visibility() + case hackathon.FieldDescription: + return m.Description() + case hackathon.FieldLogo: + return m.Logo() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. func (m *HackathonMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case hackathon.FieldName: - return m.OldName(ctx) - case hackathon.FieldStartsAt: - return m.OldStartsAt(ctx) - case hackathon.FieldEndsAt: - return m.OldEndsAt(ctx) - case hackathon.FieldCreatedAt: + case hackathon.FieldName: + return m.OldName(ctx) + case hackathon.FieldStartsAt: + return m.OldStartsAt(ctx) + case hackathon.FieldEndsAt: + return m.OldEndsAt(ctx) + case hackathon.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case hackathon.FieldModifiedAt: + return m.OldModifiedAt(ctx) + case hackathon.FieldVisibility: + return m.OldVisibility(ctx) + case hackathon.FieldDescription: + return m.OldDescription(ctx) + case hackathon.FieldLogo: + return m.OldLogo(ctx) + } + return nil, fmt.Errorf("unknown Hackathon field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *HackathonMutation) SetField(name string, value ent.Value) error { + switch name { + case hackathon.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case hackathon.FieldStartsAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStartsAt(v) + return nil + case hackathon.FieldEndsAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEndsAt(v) + return nil + case hackathon.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case hackathon.FieldModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModifiedAt(v) + return nil + case hackathon.FieldVisibility: + v, ok := value.(hackathon.Visibility) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVisibility(v) + return nil + case hackathon.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case hackathon.FieldLogo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLogo(v) + return nil + } + return fmt.Errorf("unknown Hackathon field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *HackathonMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *HackathonMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *HackathonMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Hackathon numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *HackathonMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(hackathon.FieldStartsAt) { + fields = append(fields, hackathon.FieldStartsAt) + } + if m.FieldCleared(hackathon.FieldEndsAt) { + fields = append(fields, hackathon.FieldEndsAt) + } + if m.FieldCleared(hackathon.FieldDescription) { + fields = append(fields, hackathon.FieldDescription) + } + if m.FieldCleared(hackathon.FieldLogo) { + fields = append(fields, hackathon.FieldLogo) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *HackathonMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *HackathonMutation) ClearField(name string) error { + switch name { + case hackathon.FieldStartsAt: + m.ClearStartsAt() + return nil + case hackathon.FieldEndsAt: + m.ClearEndsAt() + return nil + case hackathon.FieldDescription: + m.ClearDescription() + return nil + case hackathon.FieldLogo: + m.ClearLogo() + return nil + } + return fmt.Errorf("unknown Hackathon nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *HackathonMutation) ResetField(name string) error { + switch name { + case hackathon.FieldName: + m.ResetName() + return nil + case hackathon.FieldStartsAt: + m.ResetStartsAt() + return nil + case hackathon.FieldEndsAt: + m.ResetEndsAt() + return nil + case hackathon.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case hackathon.FieldModifiedAt: + m.ResetModifiedAt() + return nil + case hackathon.FieldVisibility: + m.ResetVisibility() + return nil + case hackathon.FieldDescription: + m.ResetDescription() + return nil + case hackathon.FieldLogo: + m.ResetLogo() + return nil + } + return fmt.Errorf("unknown Hackathon field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *HackathonMutation) AddedEdges() []string { + edges := make([]string, 0, 11) + if m.tracks != nil { + edges = append(edges, hackathon.EdgeTracks) + } + if m.projects != nil { + edges = append(edges, hackathon.EdgeProjects) + } + if m.participating_users != nil { + edges = append(edges, hackathon.EdgeParticipatingUsers) + } + if m.pages != nil { + edges = append(edges, hackathon.EdgePages) + } + if m.phases != nil { + edges = append(edges, hackathon.EdgePhases) + } + if m.state != nil { + edges = append(edges, hackathon.EdgeState) + } + if m.vote_categories != nil { + edges = append(edges, hackathon.EdgeVoteCategories) + } + if m.questions != nil { + edges = append(edges, hackathon.EdgeQuestions) + } + if m.owners != nil { + edges = append(edges, hackathon.EdgeOwners) + } + if m.creator != nil { + edges = append(edges, hackathon.EdgeCreator) + } + if m.modifier != nil { + edges = append(edges, hackathon.EdgeModifier) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *HackathonMutation) AddedIDs(name string) []ent.Value { + switch name { + case hackathon.EdgeTracks: + ids := make([]ent.Value, 0, len(m.tracks)) + for id := range m.tracks { + ids = append(ids, id) + } + return ids + case hackathon.EdgeProjects: + ids := make([]ent.Value, 0, len(m.projects)) + for id := range m.projects { + ids = append(ids, id) + } + return ids + case hackathon.EdgeParticipatingUsers: + ids := make([]ent.Value, 0, len(m.participating_users)) + for id := range m.participating_users { + ids = append(ids, id) + } + return ids + case hackathon.EdgePages: + ids := make([]ent.Value, 0, len(m.pages)) + for id := range m.pages { + ids = append(ids, id) + } + return ids + case hackathon.EdgePhases: + ids := make([]ent.Value, 0, len(m.phases)) + for id := range m.phases { + ids = append(ids, id) + } + return ids + case hackathon.EdgeState: + if id := m.state; id != nil { + return []ent.Value{*id} + } + case hackathon.EdgeVoteCategories: + ids := make([]ent.Value, 0, len(m.vote_categories)) + for id := range m.vote_categories { + ids = append(ids, id) + } + return ids + case hackathon.EdgeQuestions: + ids := make([]ent.Value, 0, len(m.questions)) + for id := range m.questions { + ids = append(ids, id) + } + return ids + case hackathon.EdgeOwners: + ids := make([]ent.Value, 0, len(m.owners)) + for id := range m.owners { + ids = append(ids, id) + } + return ids + case hackathon.EdgeCreator: + if id := m.creator; id != nil { + return []ent.Value{*id} + } + case hackathon.EdgeModifier: + if id := m.modifier; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *HackathonMutation) RemovedEdges() []string { + edges := make([]string, 0, 11) + if m.removedtracks != nil { + edges = append(edges, hackathon.EdgeTracks) + } + if m.removedprojects != nil { + edges = append(edges, hackathon.EdgeProjects) + } + if m.removedparticipating_users != nil { + edges = append(edges, hackathon.EdgeParticipatingUsers) + } + if m.removedpages != nil { + edges = append(edges, hackathon.EdgePages) + } + if m.removedphases != nil { + edges = append(edges, hackathon.EdgePhases) + } + if m.removedvote_categories != nil { + edges = append(edges, hackathon.EdgeVoteCategories) + } + if m.removedquestions != nil { + edges = append(edges, hackathon.EdgeQuestions) + } + if m.removedowners != nil { + edges = append(edges, hackathon.EdgeOwners) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *HackathonMutation) RemovedIDs(name string) []ent.Value { + switch name { + case hackathon.EdgeTracks: + ids := make([]ent.Value, 0, len(m.removedtracks)) + for id := range m.removedtracks { + ids = append(ids, id) + } + return ids + case hackathon.EdgeProjects: + ids := make([]ent.Value, 0, len(m.removedprojects)) + for id := range m.removedprojects { + ids = append(ids, id) + } + return ids + case hackathon.EdgeParticipatingUsers: + ids := make([]ent.Value, 0, len(m.removedparticipating_users)) + for id := range m.removedparticipating_users { + ids = append(ids, id) + } + return ids + case hackathon.EdgePages: + ids := make([]ent.Value, 0, len(m.removedpages)) + for id := range m.removedpages { + ids = append(ids, id) + } + return ids + case hackathon.EdgePhases: + ids := make([]ent.Value, 0, len(m.removedphases)) + for id := range m.removedphases { + ids = append(ids, id) + } + return ids + case hackathon.EdgeVoteCategories: + ids := make([]ent.Value, 0, len(m.removedvote_categories)) + for id := range m.removedvote_categories { + ids = append(ids, id) + } + return ids + case hackathon.EdgeQuestions: + ids := make([]ent.Value, 0, len(m.removedquestions)) + for id := range m.removedquestions { + ids = append(ids, id) + } + return ids + case hackathon.EdgeOwners: + ids := make([]ent.Value, 0, len(m.removedowners)) + for id := range m.removedowners { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *HackathonMutation) ClearedEdges() []string { + edges := make([]string, 0, 11) + if m.clearedtracks { + edges = append(edges, hackathon.EdgeTracks) + } + if m.clearedprojects { + edges = append(edges, hackathon.EdgeProjects) + } + if m.clearedparticipating_users { + edges = append(edges, hackathon.EdgeParticipatingUsers) + } + if m.clearedpages { + edges = append(edges, hackathon.EdgePages) + } + if m.clearedphases { + edges = append(edges, hackathon.EdgePhases) + } + if m.clearedstate { + edges = append(edges, hackathon.EdgeState) + } + if m.clearedvote_categories { + edges = append(edges, hackathon.EdgeVoteCategories) + } + if m.clearedquestions { + edges = append(edges, hackathon.EdgeQuestions) + } + if m.clearedowners { + edges = append(edges, hackathon.EdgeOwners) + } + if m.clearedcreator { + edges = append(edges, hackathon.EdgeCreator) + } + if m.clearedmodifier { + edges = append(edges, hackathon.EdgeModifier) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *HackathonMutation) EdgeCleared(name string) bool { + switch name { + case hackathon.EdgeTracks: + return m.clearedtracks + case hackathon.EdgeProjects: + return m.clearedprojects + case hackathon.EdgeParticipatingUsers: + return m.clearedparticipating_users + case hackathon.EdgePages: + return m.clearedpages + case hackathon.EdgePhases: + return m.clearedphases + case hackathon.EdgeState: + return m.clearedstate + case hackathon.EdgeVoteCategories: + return m.clearedvote_categories + case hackathon.EdgeQuestions: + return m.clearedquestions + case hackathon.EdgeOwners: + return m.clearedowners + case hackathon.EdgeCreator: + return m.clearedcreator + case hackathon.EdgeModifier: + return m.clearedmodifier + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *HackathonMutation) ClearEdge(name string) error { + switch name { + case hackathon.EdgeState: + m.ClearState() + return nil + case hackathon.EdgeCreator: + m.ClearCreator() + return nil + case hackathon.EdgeModifier: + m.ClearModifier() + return nil + } + return fmt.Errorf("unknown Hackathon unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *HackathonMutation) ResetEdge(name string) error { + switch name { + case hackathon.EdgeTracks: + m.ResetTracks() + return nil + case hackathon.EdgeProjects: + m.ResetProjects() + return nil + case hackathon.EdgeParticipatingUsers: + m.ResetParticipatingUsers() + return nil + case hackathon.EdgePages: + m.ResetPages() + return nil + case hackathon.EdgePhases: + m.ResetPhases() + return nil + case hackathon.EdgeState: + m.ResetState() + return nil + case hackathon.EdgeVoteCategories: + m.ResetVoteCategories() + return nil + case hackathon.EdgeQuestions: + m.ResetQuestions() + return nil + case hackathon.EdgeOwners: + m.ResetOwners() + return nil + case hackathon.EdgeCreator: + m.ResetCreator() + return nil + case hackathon.EdgeModifier: + m.ResetModifier() + return nil + } + return fmt.Errorf("unknown Hackathon edge %s", name) +} + +// HackathonStateMutation represents an operation that mutates the HackathonState nodes in the graph. +type HackathonStateMutation struct { + config + op Op + typ string + id *uuid.UUID + registrations_enabled *bool + voting_enabled *bool + propose_projects_enabled *bool + set_team_preferences_enabled *bool + create_project_submissions_enabled *bool + view_results_enabled *bool + created_at *time.Time + modified_at *time.Time + clearedFields map[string]struct{} + hackathon *uuid.UUID + clearedhackathon bool + modifier *uuid.UUID + clearedmodifier bool + current_phase *uuid.UUID + clearedcurrent_phase bool + done bool + oldValue func(context.Context) (*HackathonState, error) + predicates []predicate.HackathonState +} + +var _ ent.Mutation = (*HackathonStateMutation)(nil) + +// hackathonstateOption allows management of the mutation configuration using functional options. +type hackathonstateOption func(*HackathonStateMutation) + +// newHackathonStateMutation creates new mutation for the HackathonState entity. +func newHackathonStateMutation(c config, op Op, opts ...hackathonstateOption) *HackathonStateMutation { + m := &HackathonStateMutation{ + config: c, + op: op, + typ: TypeHackathonState, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withHackathonStateID sets the ID field of the mutation. +func withHackathonStateID(id uuid.UUID) hackathonstateOption { + return func(m *HackathonStateMutation) { + var ( + err error + once sync.Once + value *HackathonState + ) + m.oldValue = func(ctx context.Context) (*HackathonState, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().HackathonState.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withHackathonState sets the old HackathonState of the mutation. +func withHackathonState(node *HackathonState) hackathonstateOption { + return func(m *HackathonStateMutation) { + m.oldValue = func(context.Context) (*HackathonState, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m HackathonStateMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m HackathonStateMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of HackathonState entities. +func (m *HackathonStateMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *HackathonStateMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *HackathonStateMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().HackathonState.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetRegistrationsEnabled sets the "registrations_enabled" field. +func (m *HackathonStateMutation) SetRegistrationsEnabled(b bool) { + m.registrations_enabled = &b +} + +// RegistrationsEnabled returns the value of the "registrations_enabled" field in the mutation. +func (m *HackathonStateMutation) RegistrationsEnabled() (r bool, exists bool) { + v := m.registrations_enabled + if v == nil { + return + } + return *v, true +} + +// OldRegistrationsEnabled returns the old "registrations_enabled" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldRegistrationsEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRegistrationsEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRegistrationsEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRegistrationsEnabled: %w", err) + } + return oldValue.RegistrationsEnabled, nil +} + +// ResetRegistrationsEnabled resets all changes to the "registrations_enabled" field. +func (m *HackathonStateMutation) ResetRegistrationsEnabled() { + m.registrations_enabled = nil +} + +// SetVotingEnabled sets the "voting_enabled" field. +func (m *HackathonStateMutation) SetVotingEnabled(b bool) { + m.voting_enabled = &b +} + +// VotingEnabled returns the value of the "voting_enabled" field in the mutation. +func (m *HackathonStateMutation) VotingEnabled() (r bool, exists bool) { + v := m.voting_enabled + if v == nil { + return + } + return *v, true +} + +// OldVotingEnabled returns the old "voting_enabled" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldVotingEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVotingEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVotingEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVotingEnabled: %w", err) + } + return oldValue.VotingEnabled, nil +} + +// ResetVotingEnabled resets all changes to the "voting_enabled" field. +func (m *HackathonStateMutation) ResetVotingEnabled() { + m.voting_enabled = nil +} + +// SetProposeProjectsEnabled sets the "propose_projects_enabled" field. +func (m *HackathonStateMutation) SetProposeProjectsEnabled(b bool) { + m.propose_projects_enabled = &b +} + +// ProposeProjectsEnabled returns the value of the "propose_projects_enabled" field in the mutation. +func (m *HackathonStateMutation) ProposeProjectsEnabled() (r bool, exists bool) { + v := m.propose_projects_enabled + if v == nil { + return + } + return *v, true +} + +// OldProposeProjectsEnabled returns the old "propose_projects_enabled" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldProposeProjectsEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProposeProjectsEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProposeProjectsEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProposeProjectsEnabled: %w", err) + } + return oldValue.ProposeProjectsEnabled, nil +} + +// ResetProposeProjectsEnabled resets all changes to the "propose_projects_enabled" field. +func (m *HackathonStateMutation) ResetProposeProjectsEnabled() { + m.propose_projects_enabled = nil +} + +// SetSetTeamPreferencesEnabled sets the "set_team_preferences_enabled" field. +func (m *HackathonStateMutation) SetSetTeamPreferencesEnabled(b bool) { + m.set_team_preferences_enabled = &b +} + +// SetTeamPreferencesEnabled returns the value of the "set_team_preferences_enabled" field in the mutation. +func (m *HackathonStateMutation) SetTeamPreferencesEnabled() (r bool, exists bool) { + v := m.set_team_preferences_enabled + if v == nil { + return + } + return *v, true +} + +// OldSetTeamPreferencesEnabled returns the old "set_team_preferences_enabled" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldSetTeamPreferencesEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSetTeamPreferencesEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSetTeamPreferencesEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSetTeamPreferencesEnabled: %w", err) + } + return oldValue.SetTeamPreferencesEnabled, nil +} + +// ResetSetTeamPreferencesEnabled resets all changes to the "set_team_preferences_enabled" field. +func (m *HackathonStateMutation) ResetSetTeamPreferencesEnabled() { + m.set_team_preferences_enabled = nil +} + +// SetCreateProjectSubmissionsEnabled sets the "create_project_submissions_enabled" field. +func (m *HackathonStateMutation) SetCreateProjectSubmissionsEnabled(b bool) { + m.create_project_submissions_enabled = &b +} + +// CreateProjectSubmissionsEnabled returns the value of the "create_project_submissions_enabled" field in the mutation. +func (m *HackathonStateMutation) CreateProjectSubmissionsEnabled() (r bool, exists bool) { + v := m.create_project_submissions_enabled + if v == nil { + return + } + return *v, true +} + +// OldCreateProjectSubmissionsEnabled returns the old "create_project_submissions_enabled" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldCreateProjectSubmissionsEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateProjectSubmissionsEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateProjectSubmissionsEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateProjectSubmissionsEnabled: %w", err) + } + return oldValue.CreateProjectSubmissionsEnabled, nil +} + +// ResetCreateProjectSubmissionsEnabled resets all changes to the "create_project_submissions_enabled" field. +func (m *HackathonStateMutation) ResetCreateProjectSubmissionsEnabled() { + m.create_project_submissions_enabled = nil +} + +// SetViewResultsEnabled sets the "view_results_enabled" field. +func (m *HackathonStateMutation) SetViewResultsEnabled(b bool) { + m.view_results_enabled = &b +} + +// ViewResultsEnabled returns the value of the "view_results_enabled" field in the mutation. +func (m *HackathonStateMutation) ViewResultsEnabled() (r bool, exists bool) { + v := m.view_results_enabled + if v == nil { + return + } + return *v, true +} + +// OldViewResultsEnabled returns the old "view_results_enabled" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldViewResultsEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldViewResultsEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldViewResultsEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldViewResultsEnabled: %w", err) + } + return oldValue.ViewResultsEnabled, nil +} + +// ResetViewResultsEnabled resets all changes to the "view_results_enabled" field. +func (m *HackathonStateMutation) ResetViewResultsEnabled() { + m.view_results_enabled = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *HackathonStateMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *HackathonStateMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *HackathonStateMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetModifiedAt sets the "modified_at" field. +func (m *HackathonStateMutation) SetModifiedAt(t time.Time) { + m.modified_at = &t +} + +// ModifiedAt returns the value of the "modified_at" field in the mutation. +func (m *HackathonStateMutation) ModifiedAt() (r time.Time, exists bool) { + v := m.modified_at + if v == nil { + return + } + return *v, true +} + +// OldModifiedAt returns the old "modified_at" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) + } + return oldValue.ModifiedAt, nil +} + +// ResetModifiedAt resets all changes to the "modified_at" field. +func (m *HackathonStateMutation) ResetModifiedAt() { + m.modified_at = nil +} + +// SetCurrentPhaseID sets the "current_phase_id" field. +func (m *HackathonStateMutation) SetCurrentPhaseID(u uuid.UUID) { + m.current_phase = &u +} + +// CurrentPhaseID returns the value of the "current_phase_id" field in the mutation. +func (m *HackathonStateMutation) CurrentPhaseID() (r uuid.UUID, exists bool) { + v := m.current_phase + if v == nil { + return + } + return *v, true +} + +// OldCurrentPhaseID returns the old "current_phase_id" field's value of the HackathonState entity. +// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HackathonStateMutation) OldCurrentPhaseID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCurrentPhaseID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCurrentPhaseID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCurrentPhaseID: %w", err) + } + return oldValue.CurrentPhaseID, nil +} + +// ClearCurrentPhaseID clears the value of the "current_phase_id" field. +func (m *HackathonStateMutation) ClearCurrentPhaseID() { + m.current_phase = nil + m.clearedFields[hackathonstate.FieldCurrentPhaseID] = struct{}{} +} + +// CurrentPhaseIDCleared returns if the "current_phase_id" field was cleared in this mutation. +func (m *HackathonStateMutation) CurrentPhaseIDCleared() bool { + _, ok := m.clearedFields[hackathonstate.FieldCurrentPhaseID] + return ok +} + +// ResetCurrentPhaseID resets all changes to the "current_phase_id" field. +func (m *HackathonStateMutation) ResetCurrentPhaseID() { + m.current_phase = nil + delete(m.clearedFields, hackathonstate.FieldCurrentPhaseID) +} + +// SetHackathonID sets the "hackathon" edge to the Hackathon entity by id. +func (m *HackathonStateMutation) SetHackathonID(id uuid.UUID) { + m.hackathon = &id +} + +// ClearHackathon clears the "hackathon" edge to the Hackathon entity. +func (m *HackathonStateMutation) ClearHackathon() { + m.clearedhackathon = true +} + +// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. +func (m *HackathonStateMutation) HackathonCleared() bool { + return m.clearedhackathon +} + +// HackathonID returns the "hackathon" edge ID in the mutation. +func (m *HackathonStateMutation) HackathonID() (id uuid.UUID, exists bool) { + if m.hackathon != nil { + return *m.hackathon, true + } + return +} + +// HackathonIDs returns the "hackathon" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// HackathonID instead. It exists only for internal usage by the builders. +func (m *HackathonStateMutation) HackathonIDs() (ids []uuid.UUID) { + if id := m.hackathon; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetHackathon resets all changes to the "hackathon" edge. +func (m *HackathonStateMutation) ResetHackathon() { + m.hackathon = nil + m.clearedhackathon = false +} + +// SetModifierID sets the "modifier" edge to the User entity by id. +func (m *HackathonStateMutation) SetModifierID(id uuid.UUID) { + m.modifier = &id +} + +// ClearModifier clears the "modifier" edge to the User entity. +func (m *HackathonStateMutation) ClearModifier() { + m.clearedmodifier = true +} + +// ModifierCleared reports if the "modifier" edge to the User entity was cleared. +func (m *HackathonStateMutation) ModifierCleared() bool { + return m.clearedmodifier +} + +// ModifierID returns the "modifier" edge ID in the mutation. +func (m *HackathonStateMutation) ModifierID() (id uuid.UUID, exists bool) { + if m.modifier != nil { + return *m.modifier, true + } + return +} + +// ModifierIDs returns the "modifier" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModifierID instead. It exists only for internal usage by the builders. +func (m *HackathonStateMutation) ModifierIDs() (ids []uuid.UUID) { + if id := m.modifier; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetModifier resets all changes to the "modifier" edge. +func (m *HackathonStateMutation) ResetModifier() { + m.modifier = nil + m.clearedmodifier = false +} + +// ClearCurrentPhase clears the "current_phase" edge to the Phase entity. +func (m *HackathonStateMutation) ClearCurrentPhase() { + m.clearedcurrent_phase = true + m.clearedFields[hackathonstate.FieldCurrentPhaseID] = struct{}{} +} + +// CurrentPhaseCleared reports if the "current_phase" edge to the Phase entity was cleared. +func (m *HackathonStateMutation) CurrentPhaseCleared() bool { + return m.CurrentPhaseIDCleared() || m.clearedcurrent_phase +} + +// CurrentPhaseIDs returns the "current_phase" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// CurrentPhaseID instead. It exists only for internal usage by the builders. +func (m *HackathonStateMutation) CurrentPhaseIDs() (ids []uuid.UUID) { + if id := m.current_phase; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetCurrentPhase resets all changes to the "current_phase" edge. +func (m *HackathonStateMutation) ResetCurrentPhase() { + m.current_phase = nil + m.clearedcurrent_phase = false +} + +// Where appends a list predicates to the HackathonStateMutation builder. +func (m *HackathonStateMutation) Where(ps ...predicate.HackathonState) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the HackathonStateMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *HackathonStateMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.HackathonState, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *HackathonStateMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *HackathonStateMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (HackathonState). +func (m *HackathonStateMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *HackathonStateMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.registrations_enabled != nil { + fields = append(fields, hackathonstate.FieldRegistrationsEnabled) + } + if m.voting_enabled != nil { + fields = append(fields, hackathonstate.FieldVotingEnabled) + } + if m.propose_projects_enabled != nil { + fields = append(fields, hackathonstate.FieldProposeProjectsEnabled) + } + if m.set_team_preferences_enabled != nil { + fields = append(fields, hackathonstate.FieldSetTeamPreferencesEnabled) + } + if m.create_project_submissions_enabled != nil { + fields = append(fields, hackathonstate.FieldCreateProjectSubmissionsEnabled) + } + if m.view_results_enabled != nil { + fields = append(fields, hackathonstate.FieldViewResultsEnabled) + } + if m.created_at != nil { + fields = append(fields, hackathonstate.FieldCreatedAt) + } + if m.modified_at != nil { + fields = append(fields, hackathonstate.FieldModifiedAt) + } + if m.current_phase != nil { + fields = append(fields, hackathonstate.FieldCurrentPhaseID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *HackathonStateMutation) Field(name string) (ent.Value, bool) { + switch name { + case hackathonstate.FieldRegistrationsEnabled: + return m.RegistrationsEnabled() + case hackathonstate.FieldVotingEnabled: + return m.VotingEnabled() + case hackathonstate.FieldProposeProjectsEnabled: + return m.ProposeProjectsEnabled() + case hackathonstate.FieldSetTeamPreferencesEnabled: + return m.SetTeamPreferencesEnabled() + case hackathonstate.FieldCreateProjectSubmissionsEnabled: + return m.CreateProjectSubmissionsEnabled() + case hackathonstate.FieldViewResultsEnabled: + return m.ViewResultsEnabled() + case hackathonstate.FieldCreatedAt: + return m.CreatedAt() + case hackathonstate.FieldModifiedAt: + return m.ModifiedAt() + case hackathonstate.FieldCurrentPhaseID: + return m.CurrentPhaseID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *HackathonStateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case hackathonstate.FieldRegistrationsEnabled: + return m.OldRegistrationsEnabled(ctx) + case hackathonstate.FieldVotingEnabled: + return m.OldVotingEnabled(ctx) + case hackathonstate.FieldProposeProjectsEnabled: + return m.OldProposeProjectsEnabled(ctx) + case hackathonstate.FieldSetTeamPreferencesEnabled: + return m.OldSetTeamPreferencesEnabled(ctx) + case hackathonstate.FieldCreateProjectSubmissionsEnabled: + return m.OldCreateProjectSubmissionsEnabled(ctx) + case hackathonstate.FieldViewResultsEnabled: + return m.OldViewResultsEnabled(ctx) + case hackathonstate.FieldCreatedAt: return m.OldCreatedAt(ctx) - case hackathon.FieldModifiedAt: + case hackathonstate.FieldModifiedAt: return m.OldModifiedAt(ctx) - case hackathon.FieldVisibility: - return m.OldVisibility(ctx) - case hackathon.FieldDescription: - return m.OldDescription(ctx) - case hackathon.FieldLogo: - return m.OldLogo(ctx) + case hackathonstate.FieldCurrentPhaseID: + return m.OldCurrentPhaseID(ctx) } - return nil, fmt.Errorf("unknown Hackathon field %s", name) + return nil, fmt.Errorf("unknown HackathonState field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *HackathonMutation) SetField(name string, value ent.Value) error { +func (m *HackathonStateMutation) SetField(name string, value ent.Value) error { switch name { - case hackathon.FieldName: - v, ok := value.(string) + case hackathonstate.FieldRegistrationsEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetName(v) + m.SetRegistrationsEnabled(v) return nil - case hackathon.FieldStartsAt: - v, ok := value.(time.Time) + case hackathonstate.FieldVotingEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetStartsAt(v) + m.SetVotingEnabled(v) return nil - case hackathon.FieldEndsAt: - v, ok := value.(time.Time) + case hackathonstate.FieldProposeProjectsEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEndsAt(v) + m.SetProposeProjectsEnabled(v) return nil - case hackathon.FieldCreatedAt: - v, ok := value.(time.Time) + case hackathonstate.FieldSetTeamPreferencesEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetSetTeamPreferencesEnabled(v) return nil - case hackathon.FieldModifiedAt: - v, ok := value.(time.Time) + case hackathonstate.FieldCreateProjectSubmissionsEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModifiedAt(v) + m.SetCreateProjectSubmissionsEnabled(v) return nil - case hackathon.FieldVisibility: - v, ok := value.(hackathon.Visibility) + case hackathonstate.FieldViewResultsEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVisibility(v) + m.SetViewResultsEnabled(v) return nil - case hackathon.FieldDescription: - v, ok := value.(string) + case hackathonstate.FieldCreatedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) + m.SetCreatedAt(v) return nil - case hackathon.FieldLogo: - v, ok := value.(string) + case hackathonstate.FieldModifiedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetLogo(v) + m.SetModifiedAt(v) + return nil + case hackathonstate.FieldCurrentPhaseID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCurrentPhaseID(v) return nil } - return fmt.Errorf("unknown Hackathon field %s", name) + return fmt.Errorf("unknown HackathonState field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *HackathonMutation) AddedFields() []string { +func (m *HackathonStateMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *HackathonMutation) AddedField(name string) (ent.Value, bool) { +func (m *HackathonStateMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *HackathonMutation) AddField(name string, value ent.Value) error { +func (m *HackathonStateMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Hackathon numeric field %s", name) + return fmt.Errorf("unknown HackathonState numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *HackathonMutation) ClearedFields() []string { +func (m *HackathonStateMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(hackathon.FieldStartsAt) { - fields = append(fields, hackathon.FieldStartsAt) - } - if m.FieldCleared(hackathon.FieldEndsAt) { - fields = append(fields, hackathon.FieldEndsAt) - } - if m.FieldCleared(hackathon.FieldDescription) { - fields = append(fields, hackathon.FieldDescription) - } - if m.FieldCleared(hackathon.FieldLogo) { - fields = append(fields, hackathon.FieldLogo) + if m.FieldCleared(hackathonstate.FieldCurrentPhaseID) { + fields = append(fields, hackathonstate.FieldCurrentPhaseID) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *HackathonMutation) FieldCleared(name string) bool { +func (m *HackathonStateMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *HackathonMutation) ClearField(name string) error { +func (m *HackathonStateMutation) ClearField(name string) error { switch name { - case hackathon.FieldStartsAt: - m.ClearStartsAt() - return nil - case hackathon.FieldEndsAt: - m.ClearEndsAt() - return nil - case hackathon.FieldDescription: - m.ClearDescription() - return nil - case hackathon.FieldLogo: - m.ClearLogo() + case hackathonstate.FieldCurrentPhaseID: + m.ClearCurrentPhaseID() return nil } - return fmt.Errorf("unknown Hackathon nullable field %s", name) + return fmt.Errorf("unknown HackathonState nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *HackathonMutation) ResetField(name string) error { +func (m *HackathonStateMutation) ResetField(name string) error { switch name { - case hackathon.FieldName: - m.ResetName() + case hackathonstate.FieldRegistrationsEnabled: + m.ResetRegistrationsEnabled() return nil - case hackathon.FieldStartsAt: - m.ResetStartsAt() + case hackathonstate.FieldVotingEnabled: + m.ResetVotingEnabled() return nil - case hackathon.FieldEndsAt: - m.ResetEndsAt() + case hackathonstate.FieldProposeProjectsEnabled: + m.ResetProposeProjectsEnabled() return nil - case hackathon.FieldCreatedAt: - m.ResetCreatedAt() + case hackathonstate.FieldSetTeamPreferencesEnabled: + m.ResetSetTeamPreferencesEnabled() return nil - case hackathon.FieldModifiedAt: - m.ResetModifiedAt() + case hackathonstate.FieldCreateProjectSubmissionsEnabled: + m.ResetCreateProjectSubmissionsEnabled() return nil - case hackathon.FieldVisibility: - m.ResetVisibility() + case hackathonstate.FieldViewResultsEnabled: + m.ResetViewResultsEnabled() return nil - case hackathon.FieldDescription: - m.ResetDescription() + case hackathonstate.FieldCreatedAt: + m.ResetCreatedAt() return nil - case hackathon.FieldLogo: - m.ResetLogo() + case hackathonstate.FieldModifiedAt: + m.ResetModifiedAt() + return nil + case hackathonstate.FieldCurrentPhaseID: + m.ResetCurrentPhaseID() return nil } - return fmt.Errorf("unknown Hackathon field %s", name) + return fmt.Errorf("unknown HackathonState field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *HackathonMutation) AddedEdges() []string { - edges := make([]string, 0, 10) - if m.tracks != nil { - edges = append(edges, hackathon.EdgeTracks) - } - if m.projects != nil { - edges = append(edges, hackathon.EdgeProjects) - } - if m.participating_users != nil { - edges = append(edges, hackathon.EdgeParticipatingUsers) - } - if m.pages != nil { - edges = append(edges, hackathon.EdgePages) - } - if m.phases != nil { - edges = append(edges, hackathon.EdgePhases) - } - if m.state != nil { - edges = append(edges, hackathon.EdgeState) - } - if m.vote_categories != nil { - edges = append(edges, hackathon.EdgeVoteCategories) - } - if m.owners != nil { - edges = append(edges, hackathon.EdgeOwners) - } - if m.creator != nil { - edges = append(edges, hackathon.EdgeCreator) +func (m *HackathonStateMutation) AddedEdges() []string { + edges := make([]string, 0, 3) + if m.hackathon != nil { + edges = append(edges, hackathonstate.EdgeHackathon) } if m.modifier != nil { - edges = append(edges, hackathon.EdgeModifier) + edges = append(edges, hackathonstate.EdgeModifier) + } + if m.current_phase != nil { + edges = append(edges, hackathonstate.EdgeCurrentPhase) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *HackathonMutation) AddedIDs(name string) []ent.Value { +func (m *HackathonStateMutation) AddedIDs(name string) []ent.Value { switch name { - case hackathon.EdgeTracks: - ids := make([]ent.Value, 0, len(m.tracks)) - for id := range m.tracks { - ids = append(ids, id) - } - return ids - case hackathon.EdgeProjects: - ids := make([]ent.Value, 0, len(m.projects)) - for id := range m.projects { - ids = append(ids, id) - } - return ids - case hackathon.EdgeParticipatingUsers: - ids := make([]ent.Value, 0, len(m.participating_users)) - for id := range m.participating_users { - ids = append(ids, id) - } - return ids - case hackathon.EdgePages: - ids := make([]ent.Value, 0, len(m.pages)) - for id := range m.pages { - ids = append(ids, id) - } - return ids - case hackathon.EdgePhases: - ids := make([]ent.Value, 0, len(m.phases)) - for id := range m.phases { - ids = append(ids, id) - } - return ids - case hackathon.EdgeState: - if id := m.state; id != nil { + case hackathonstate.EdgeHackathon: + if id := m.hackathon; id != nil { return []ent.Value{*id} } - case hackathon.EdgeVoteCategories: - ids := make([]ent.Value, 0, len(m.vote_categories)) - for id := range m.vote_categories { - ids = append(ids, id) - } - return ids - case hackathon.EdgeOwners: - ids := make([]ent.Value, 0, len(m.owners)) - for id := range m.owners { - ids = append(ids, id) - } - return ids - case hackathon.EdgeCreator: - if id := m.creator; id != nil { + case hackathonstate.EdgeModifier: + if id := m.modifier; id != nil { return []ent.Value{*id} } - case hackathon.EdgeModifier: - if id := m.modifier; id != nil { + case hackathonstate.EdgeCurrentPhase: + if id := m.current_phase; id != nil { return []ent.Value{*id} } } return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *HackathonMutation) RemovedEdges() []string { - edges := make([]string, 0, 10) - if m.removedtracks != nil { - edges = append(edges, hackathon.EdgeTracks) - } - if m.removedprojects != nil { - edges = append(edges, hackathon.EdgeProjects) - } - if m.removedparticipating_users != nil { - edges = append(edges, hackathon.EdgeParticipatingUsers) - } - if m.removedpages != nil { - edges = append(edges, hackathon.EdgePages) - } - if m.removedphases != nil { - edges = append(edges, hackathon.EdgePhases) - } - if m.removedvote_categories != nil { - edges = append(edges, hackathon.EdgeVoteCategories) - } - if m.removedowners != nil { - edges = append(edges, hackathon.EdgeOwners) - } +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *HackathonStateMutation) RemovedEdges() []string { + edges := make([]string, 0, 3) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *HackathonMutation) RemovedIDs(name string) []ent.Value { - switch name { - case hackathon.EdgeTracks: - ids := make([]ent.Value, 0, len(m.removedtracks)) - for id := range m.removedtracks { - ids = append(ids, id) - } - return ids - case hackathon.EdgeProjects: - ids := make([]ent.Value, 0, len(m.removedprojects)) - for id := range m.removedprojects { - ids = append(ids, id) - } - return ids - case hackathon.EdgeParticipatingUsers: - ids := make([]ent.Value, 0, len(m.removedparticipating_users)) - for id := range m.removedparticipating_users { - ids = append(ids, id) - } - return ids - case hackathon.EdgePages: - ids := make([]ent.Value, 0, len(m.removedpages)) - for id := range m.removedpages { - ids = append(ids, id) - } - return ids - case hackathon.EdgePhases: - ids := make([]ent.Value, 0, len(m.removedphases)) - for id := range m.removedphases { - ids = append(ids, id) - } - return ids - case hackathon.EdgeVoteCategories: - ids := make([]ent.Value, 0, len(m.removedvote_categories)) - for id := range m.removedvote_categories { - ids = append(ids, id) - } - return ids - case hackathon.EdgeOwners: - ids := make([]ent.Value, 0, len(m.removedowners)) - for id := range m.removedowners { - ids = append(ids, id) - } - return ids - } +func (m *HackathonStateMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *HackathonMutation) ClearedEdges() []string { - edges := make([]string, 0, 10) - if m.clearedtracks { - edges = append(edges, hackathon.EdgeTracks) - } - if m.clearedprojects { - edges = append(edges, hackathon.EdgeProjects) - } - if m.clearedparticipating_users { - edges = append(edges, hackathon.EdgeParticipatingUsers) - } - if m.clearedpages { - edges = append(edges, hackathon.EdgePages) - } - if m.clearedphases { - edges = append(edges, hackathon.EdgePhases) - } - if m.clearedstate { - edges = append(edges, hackathon.EdgeState) - } - if m.clearedvote_categories { - edges = append(edges, hackathon.EdgeVoteCategories) - } - if m.clearedowners { - edges = append(edges, hackathon.EdgeOwners) - } - if m.clearedcreator { - edges = append(edges, hackathon.EdgeCreator) +func (m *HackathonStateMutation) ClearedEdges() []string { + edges := make([]string, 0, 3) + if m.clearedhackathon { + edges = append(edges, hackathonstate.EdgeHackathon) } if m.clearedmodifier { - edges = append(edges, hackathon.EdgeModifier) + edges = append(edges, hackathonstate.EdgeModifier) + } + if m.clearedcurrent_phase { + edges = append(edges, hackathonstate.EdgeCurrentPhase) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *HackathonMutation) EdgeCleared(name string) bool { +func (m *HackathonStateMutation) EdgeCleared(name string) bool { switch name { - case hackathon.EdgeTracks: - return m.clearedtracks - case hackathon.EdgeProjects: - return m.clearedprojects - case hackathon.EdgeParticipatingUsers: - return m.clearedparticipating_users - case hackathon.EdgePages: - return m.clearedpages - case hackathon.EdgePhases: - return m.clearedphases - case hackathon.EdgeState: - return m.clearedstate - case hackathon.EdgeVoteCategories: - return m.clearedvote_categories - case hackathon.EdgeOwners: - return m.clearedowners - case hackathon.EdgeCreator: - return m.clearedcreator - case hackathon.EdgeModifier: + case hackathonstate.EdgeHackathon: + return m.clearedhackathon + case hackathonstate.EdgeModifier: return m.clearedmodifier + case hackathonstate.EdgeCurrentPhase: + return m.clearedcurrent_phase } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *HackathonMutation) ClearEdge(name string) error { +func (m *HackathonStateMutation) ClearEdge(name string) error { switch name { - case hackathon.EdgeState: - m.ClearState() - return nil - case hackathon.EdgeCreator: - m.ClearCreator() + case hackathonstate.EdgeHackathon: + m.ClearHackathon() return nil - case hackathon.EdgeModifier: + case hackathonstate.EdgeModifier: m.ClearModifier() return nil + case hackathonstate.EdgeCurrentPhase: + m.ClearCurrentPhase() + return nil } - return fmt.Errorf("unknown Hackathon unique edge %s", name) + return fmt.Errorf("unknown HackathonState unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *HackathonMutation) ResetEdge(name string) error { +func (m *HackathonStateMutation) ResetEdge(name string) error { switch name { - case hackathon.EdgeTracks: - m.ResetTracks() - return nil - case hackathon.EdgeProjects: - m.ResetProjects() - return nil - case hackathon.EdgeParticipatingUsers: - m.ResetParticipatingUsers() - return nil - case hackathon.EdgePages: - m.ResetPages() - return nil - case hackathon.EdgePhases: - m.ResetPhases() - return nil - case hackathon.EdgeState: - m.ResetState() - return nil - case hackathon.EdgeVoteCategories: - m.ResetVoteCategories() - return nil - case hackathon.EdgeOwners: - m.ResetOwners() - return nil - case hackathon.EdgeCreator: - m.ResetCreator() + case hackathonstate.EdgeHackathon: + m.ResetHackathon() return nil - case hackathon.EdgeModifier: + case hackathonstate.EdgeModifier: m.ResetModifier() return nil + case hackathonstate.EdgeCurrentPhase: + m.ResetCurrentPhase() + return nil } - return fmt.Errorf("unknown Hackathon edge %s", name) + return fmt.Errorf("unknown HackathonState edge %s", name) } -// HackathonStateMutation represents an operation that mutates the HackathonState nodes in the graph. -type HackathonStateMutation struct { +// PageMutation represents an operation that mutates the Page nodes in the graph. +type PageMutation struct { config - op Op - typ string - id *uuid.UUID - registrations_enabled *bool - voting_enabled *bool - propose_projects_enabled *bool - set_team_preferences_enabled *bool - create_project_submissions_enabled *bool - view_results_enabled *bool - created_at *time.Time - modified_at *time.Time - clearedFields map[string]struct{} - hackathon *uuid.UUID - clearedhackathon bool - modifier *uuid.UUID - clearedmodifier bool - current_phase *uuid.UUID - clearedcurrent_phase bool - done bool - oldValue func(context.Context) (*HackathonState, error) - predicates []predicate.HackathonState + op Op + typ string + id *uuid.UUID + title *string + content *string + visible *bool + _order *int + add_order *int + created_at *time.Time + modified_at *time.Time + clearedFields map[string]struct{} + hackathon *uuid.UUID + clearedhackathon bool + phase *uuid.UUID + clearedphase bool + creator *uuid.UUID + clearedcreator bool + modifier *uuid.UUID + clearedmodifier bool + done bool + oldValue func(context.Context) (*Page, error) + predicates []predicate.Page } -var _ ent.Mutation = (*HackathonStateMutation)(nil) +var _ ent.Mutation = (*PageMutation)(nil) -// hackathonstateOption allows management of the mutation configuration using functional options. -type hackathonstateOption func(*HackathonStateMutation) +// pageOption allows management of the mutation configuration using functional options. +type pageOption func(*PageMutation) -// newHackathonStateMutation creates new mutation for the HackathonState entity. -func newHackathonStateMutation(c config, op Op, opts ...hackathonstateOption) *HackathonStateMutation { - m := &HackathonStateMutation{ +// newPageMutation creates new mutation for the Page entity. +func newPageMutation(c config, op Op, opts ...pageOption) *PageMutation { + m := &PageMutation{ config: c, op: op, - typ: TypeHackathonState, + typ: TypePage, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -1656,20 +3404,20 @@ func newHackathonStateMutation(c config, op Op, opts ...hackathonstateOption) *H return m } -// withHackathonStateID sets the ID field of the mutation. -func withHackathonStateID(id uuid.UUID) hackathonstateOption { - return func(m *HackathonStateMutation) { +// withPageID sets the ID field of the mutation. +func withPageID(id uuid.UUID) pageOption { + return func(m *PageMutation) { var ( err error once sync.Once - value *HackathonState + value *Page ) - m.oldValue = func(ctx context.Context) (*HackathonState, error) { + m.oldValue = func(ctx context.Context) (*Page, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().HackathonState.Get(ctx, id) + value, err = m.Client().Page.Get(ctx, id) } }) return value, err @@ -1678,10 +3426,10 @@ func withHackathonStateID(id uuid.UUID) hackathonstateOption { } } -// withHackathonState sets the old HackathonState of the mutation. -func withHackathonState(node *HackathonState) hackathonstateOption { - return func(m *HackathonStateMutation) { - m.oldValue = func(context.Context) (*HackathonState, error) { +// withPage sets the old Page of the mutation. +func withPage(node *Page) pageOption { + return func(m *PageMutation) { + m.oldValue = func(context.Context) (*Page, error) { return node, nil } m.id = &node.ID @@ -1690,7 +3438,7 @@ func withHackathonState(node *HackathonState) hackathonstateOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m HackathonStateMutation) Client() *Client { +func (m PageMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -1698,7 +3446,7 @@ func (m HackathonStateMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m HackathonStateMutation) Tx() (*Tx, error) { +func (m PageMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -1708,14 +3456,14 @@ func (m HackathonStateMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of HackathonState entities. -func (m *HackathonStateMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of Page entities. +func (m *PageMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *HackathonStateMutation) ID() (id uuid.UUID, exists bool) { +func (m *PageMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -1726,7 +3474,7 @@ func (m *HackathonStateMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *HackathonStateMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *PageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -1735,235 +3483,183 @@ func (m *HackathonStateMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().HackathonState.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Page.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetRegistrationsEnabled sets the "registrations_enabled" field. -func (m *HackathonStateMutation) SetRegistrationsEnabled(b bool) { - m.registrations_enabled = &b +// SetTitle sets the "title" field. +func (m *PageMutation) SetTitle(s string) { + m.title = &s } -// RegistrationsEnabled returns the value of the "registrations_enabled" field in the mutation. -func (m *HackathonStateMutation) RegistrationsEnabled() (r bool, exists bool) { - v := m.registrations_enabled +// Title returns the value of the "title" field in the mutation. +func (m *PageMutation) Title() (r string, exists bool) { + v := m.title if v == nil { return } return *v, true } -// OldRegistrationsEnabled returns the old "registrations_enabled" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// OldTitle returns the old "title" field's value of the Page entity. +// If the Page object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldRegistrationsEnabled(ctx context.Context) (v bool, err error) { +func (m *PageMutation) OldTitle(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegistrationsEnabled is only allowed on UpdateOne operations") + return v, errors.New("OldTitle is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegistrationsEnabled requires an ID field in the mutation") + return v, errors.New("OldTitle requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRegistrationsEnabled: %w", err) + return v, fmt.Errorf("querying old value for OldTitle: %w", err) } - return oldValue.RegistrationsEnabled, nil + return oldValue.Title, nil } -// ResetRegistrationsEnabled resets all changes to the "registrations_enabled" field. -func (m *HackathonStateMutation) ResetRegistrationsEnabled() { - m.registrations_enabled = nil +// ResetTitle resets all changes to the "title" field. +func (m *PageMutation) ResetTitle() { + m.title = nil } -// SetVotingEnabled sets the "voting_enabled" field. -func (m *HackathonStateMutation) SetVotingEnabled(b bool) { - m.voting_enabled = &b +// SetContent sets the "content" field. +func (m *PageMutation) SetContent(s string) { + m.content = &s } -// VotingEnabled returns the value of the "voting_enabled" field in the mutation. -func (m *HackathonStateMutation) VotingEnabled() (r bool, exists bool) { - v := m.voting_enabled +// Content returns the value of the "content" field in the mutation. +func (m *PageMutation) Content() (r string, exists bool) { + v := m.content if v == nil { return } return *v, true } -// OldVotingEnabled returns the old "voting_enabled" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// OldContent returns the old "content" field's value of the Page entity. +// If the Page object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldVotingEnabled(ctx context.Context) (v bool, err error) { +func (m *PageMutation) OldContent(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVotingEnabled is only allowed on UpdateOne operations") + return v, errors.New("OldContent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVotingEnabled requires an ID field in the mutation") + return v, errors.New("OldContent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVotingEnabled: %w", err) + return v, fmt.Errorf("querying old value for OldContent: %w", err) } - return oldValue.VotingEnabled, nil + return oldValue.Content, nil } -// ResetVotingEnabled resets all changes to the "voting_enabled" field. -func (m *HackathonStateMutation) ResetVotingEnabled() { - m.voting_enabled = nil +// ResetContent resets all changes to the "content" field. +func (m *PageMutation) ResetContent() { + m.content = nil } -// SetProposeProjectsEnabled sets the "propose_projects_enabled" field. -func (m *HackathonStateMutation) SetProposeProjectsEnabled(b bool) { - m.propose_projects_enabled = &b +// SetVisible sets the "visible" field. +func (m *PageMutation) SetVisible(b bool) { + m.visible = &b } -// ProposeProjectsEnabled returns the value of the "propose_projects_enabled" field in the mutation. -func (m *HackathonStateMutation) ProposeProjectsEnabled() (r bool, exists bool) { - v := m.propose_projects_enabled +// Visible returns the value of the "visible" field in the mutation. +func (m *PageMutation) Visible() (r bool, exists bool) { + v := m.visible if v == nil { return } return *v, true } -// OldProposeProjectsEnabled returns the old "propose_projects_enabled" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// OldVisible returns the old "visible" field's value of the Page entity. +// If the Page object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldProposeProjectsEnabled(ctx context.Context) (v bool, err error) { +func (m *PageMutation) OldVisible(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProposeProjectsEnabled is only allowed on UpdateOne operations") + return v, errors.New("OldVisible is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProposeProjectsEnabled requires an ID field in the mutation") + return v, errors.New("OldVisible requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProposeProjectsEnabled: %w", err) + return v, fmt.Errorf("querying old value for OldVisible: %w", err) } - return oldValue.ProposeProjectsEnabled, nil + return oldValue.Visible, nil } -// ResetProposeProjectsEnabled resets all changes to the "propose_projects_enabled" field. -func (m *HackathonStateMutation) ResetProposeProjectsEnabled() { - m.propose_projects_enabled = nil +// ResetVisible resets all changes to the "visible" field. +func (m *PageMutation) ResetVisible() { + m.visible = nil } -// SetSetTeamPreferencesEnabled sets the "set_team_preferences_enabled" field. -func (m *HackathonStateMutation) SetSetTeamPreferencesEnabled(b bool) { - m.set_team_preferences_enabled = &b +// SetOrder sets the "order" field. +func (m *PageMutation) SetOrder(i int) { + m._order = &i + m.add_order = nil } -// SetTeamPreferencesEnabled returns the value of the "set_team_preferences_enabled" field in the mutation. -func (m *HackathonStateMutation) SetTeamPreferencesEnabled() (r bool, exists bool) { - v := m.set_team_preferences_enabled +// Order returns the value of the "order" field in the mutation. +func (m *PageMutation) Order() (r int, exists bool) { + v := m._order if v == nil { return } return *v, true } -// OldSetTeamPreferencesEnabled returns the old "set_team_preferences_enabled" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// OldOrder returns the old "order" field's value of the Page entity. +// If the Page object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldSetTeamPreferencesEnabled(ctx context.Context) (v bool, err error) { +func (m *PageMutation) OldOrder(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSetTeamPreferencesEnabled is only allowed on UpdateOne operations") + return v, errors.New("OldOrder is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSetTeamPreferencesEnabled requires an ID field in the mutation") + return v, errors.New("OldOrder requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSetTeamPreferencesEnabled: %w", err) - } - return oldValue.SetTeamPreferencesEnabled, nil -} - -// ResetSetTeamPreferencesEnabled resets all changes to the "set_team_preferences_enabled" field. -func (m *HackathonStateMutation) ResetSetTeamPreferencesEnabled() { - m.set_team_preferences_enabled = nil -} - -// SetCreateProjectSubmissionsEnabled sets the "create_project_submissions_enabled" field. -func (m *HackathonStateMutation) SetCreateProjectSubmissionsEnabled(b bool) { - m.create_project_submissions_enabled = &b -} - -// CreateProjectSubmissionsEnabled returns the value of the "create_project_submissions_enabled" field in the mutation. -func (m *HackathonStateMutation) CreateProjectSubmissionsEnabled() (r bool, exists bool) { - v := m.create_project_submissions_enabled - if v == nil { - return + return v, fmt.Errorf("querying old value for OldOrder: %w", err) } - return *v, true + return oldValue.Order, nil } -// OldCreateProjectSubmissionsEnabled returns the old "create_project_submissions_enabled" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldCreateProjectSubmissionsEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateProjectSubmissionsEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateProjectSubmissionsEnabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreateProjectSubmissionsEnabled: %w", err) +// AddOrder adds i to the "order" field. +func (m *PageMutation) AddOrder(i int) { + if m.add_order != nil { + *m.add_order += i + } else { + m.add_order = &i } - return oldValue.CreateProjectSubmissionsEnabled, nil -} - -// ResetCreateProjectSubmissionsEnabled resets all changes to the "create_project_submissions_enabled" field. -func (m *HackathonStateMutation) ResetCreateProjectSubmissionsEnabled() { - m.create_project_submissions_enabled = nil -} - -// SetViewResultsEnabled sets the "view_results_enabled" field. -func (m *HackathonStateMutation) SetViewResultsEnabled(b bool) { - m.view_results_enabled = &b } -// ViewResultsEnabled returns the value of the "view_results_enabled" field in the mutation. -func (m *HackathonStateMutation) ViewResultsEnabled() (r bool, exists bool) { - v := m.view_results_enabled +// AddedOrder returns the value that was added to the "order" field in this mutation. +func (m *PageMutation) AddedOrder() (r int, exists bool) { + v := m.add_order if v == nil { return } return *v, true } -// OldViewResultsEnabled returns the old "view_results_enabled" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldViewResultsEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldViewResultsEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldViewResultsEnabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldViewResultsEnabled: %w", err) - } - return oldValue.ViewResultsEnabled, nil -} - -// ResetViewResultsEnabled resets all changes to the "view_results_enabled" field. -func (m *HackathonStateMutation) ResetViewResultsEnabled() { - m.view_results_enabled = nil +// ResetOrder resets all changes to the "order" field. +func (m *PageMutation) ResetOrder() { + m._order = nil + m.add_order = nil } // SetCreatedAt sets the "created_at" field. -func (m *HackathonStateMutation) SetCreatedAt(t time.Time) { +func (m *PageMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *HackathonStateMutation) CreatedAt() (r time.Time, exists bool) { +func (m *PageMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -1971,10 +3667,10 @@ func (m *HackathonStateMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the Page entity. +// If the Page object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *PageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -1989,112 +3685,63 @@ func (m *HackathonStateMutation) OldCreatedAt(ctx context.Context) (v time.Time, } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *HackathonStateMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetModifiedAt sets the "modified_at" field. -func (m *HackathonStateMutation) SetModifiedAt(t time.Time) { - m.modified_at = &t -} - -// ModifiedAt returns the value of the "modified_at" field in the mutation. -func (m *HackathonStateMutation) ModifiedAt() (r time.Time, exists bool) { - v := m.modified_at - if v == nil { - return - } - return *v, true -} - -// OldModifiedAt returns the old "modified_at" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModifiedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) - } - return oldValue.ModifiedAt, nil -} - -// ResetModifiedAt resets all changes to the "modified_at" field. -func (m *HackathonStateMutation) ResetModifiedAt() { - m.modified_at = nil +func (m *PageMutation) ResetCreatedAt() { + m.created_at = nil } -// SetCurrentPhaseID sets the "current_phase_id" field. -func (m *HackathonStateMutation) SetCurrentPhaseID(u uuid.UUID) { - m.current_phase = &u +// SetModifiedAt sets the "modified_at" field. +func (m *PageMutation) SetModifiedAt(t time.Time) { + m.modified_at = &t } -// CurrentPhaseID returns the value of the "current_phase_id" field in the mutation. -func (m *HackathonStateMutation) CurrentPhaseID() (r uuid.UUID, exists bool) { - v := m.current_phase +// ModifiedAt returns the value of the "modified_at" field in the mutation. +func (m *PageMutation) ModifiedAt() (r time.Time, exists bool) { + v := m.modified_at if v == nil { return } return *v, true } -// OldCurrentPhaseID returns the old "current_phase_id" field's value of the HackathonState entity. -// If the HackathonState object wasn't provided to the builder, the object is fetched from the database. +// OldModifiedAt returns the old "modified_at" field's value of the Page entity. +// If the Page object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HackathonStateMutation) OldCurrentPhaseID(ctx context.Context) (v uuid.UUID, err error) { +func (m *PageMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCurrentPhaseID is only allowed on UpdateOne operations") + return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCurrentPhaseID requires an ID field in the mutation") + return v, errors.New("OldModifiedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCurrentPhaseID: %w", err) + return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) } - return oldValue.CurrentPhaseID, nil -} - -// ClearCurrentPhaseID clears the value of the "current_phase_id" field. -func (m *HackathonStateMutation) ClearCurrentPhaseID() { - m.current_phase = nil - m.clearedFields[hackathonstate.FieldCurrentPhaseID] = struct{}{} -} - -// CurrentPhaseIDCleared returns if the "current_phase_id" field was cleared in this mutation. -func (m *HackathonStateMutation) CurrentPhaseIDCleared() bool { - _, ok := m.clearedFields[hackathonstate.FieldCurrentPhaseID] - return ok + return oldValue.ModifiedAt, nil } -// ResetCurrentPhaseID resets all changes to the "current_phase_id" field. -func (m *HackathonStateMutation) ResetCurrentPhaseID() { - m.current_phase = nil - delete(m.clearedFields, hackathonstate.FieldCurrentPhaseID) +// ResetModifiedAt resets all changes to the "modified_at" field. +func (m *PageMutation) ResetModifiedAt() { + m.modified_at = nil } // SetHackathonID sets the "hackathon" edge to the Hackathon entity by id. -func (m *HackathonStateMutation) SetHackathonID(id uuid.UUID) { +func (m *PageMutation) SetHackathonID(id uuid.UUID) { m.hackathon = &id } // ClearHackathon clears the "hackathon" edge to the Hackathon entity. -func (m *HackathonStateMutation) ClearHackathon() { +func (m *PageMutation) ClearHackathon() { m.clearedhackathon = true } // HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. -func (m *HackathonStateMutation) HackathonCleared() bool { +func (m *PageMutation) HackathonCleared() bool { return m.clearedhackathon } // HackathonID returns the "hackathon" edge ID in the mutation. -func (m *HackathonStateMutation) HackathonID() (id uuid.UUID, exists bool) { +func (m *PageMutation) HackathonID() (id uuid.UUID, exists bool) { if m.hackathon != nil { return *m.hackathon, true } @@ -2104,7 +3751,7 @@ func (m *HackathonStateMutation) HackathonID() (id uuid.UUID, exists bool) { // HackathonIDs returns the "hackathon" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // HackathonID instead. It exists only for internal usage by the builders. -func (m *HackathonStateMutation) HackathonIDs() (ids []uuid.UUID) { +func (m *PageMutation) HackathonIDs() (ids []uuid.UUID) { if id := m.hackathon; id != nil { ids = append(ids, *id) } @@ -2112,28 +3759,106 @@ func (m *HackathonStateMutation) HackathonIDs() (ids []uuid.UUID) { } // ResetHackathon resets all changes to the "hackathon" edge. -func (m *HackathonStateMutation) ResetHackathon() { +func (m *PageMutation) ResetHackathon() { m.hackathon = nil m.clearedhackathon = false } +// SetPhaseID sets the "phase" edge to the Phase entity by id. +func (m *PageMutation) SetPhaseID(id uuid.UUID) { + m.phase = &id +} + +// ClearPhase clears the "phase" edge to the Phase entity. +func (m *PageMutation) ClearPhase() { + m.clearedphase = true +} + +// PhaseCleared reports if the "phase" edge to the Phase entity was cleared. +func (m *PageMutation) PhaseCleared() bool { + return m.clearedphase +} + +// PhaseID returns the "phase" edge ID in the mutation. +func (m *PageMutation) PhaseID() (id uuid.UUID, exists bool) { + if m.phase != nil { + return *m.phase, true + } + return +} + +// PhaseIDs returns the "phase" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PhaseID instead. It exists only for internal usage by the builders. +func (m *PageMutation) PhaseIDs() (ids []uuid.UUID) { + if id := m.phase; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPhase resets all changes to the "phase" edge. +func (m *PageMutation) ResetPhase() { + m.phase = nil + m.clearedphase = false +} + +// SetCreatorID sets the "creator" edge to the User entity by id. +func (m *PageMutation) SetCreatorID(id uuid.UUID) { + m.creator = &id +} + +// ClearCreator clears the "creator" edge to the User entity. +func (m *PageMutation) ClearCreator() { + m.clearedcreator = true +} + +// CreatorCleared reports if the "creator" edge to the User entity was cleared. +func (m *PageMutation) CreatorCleared() bool { + return m.clearedcreator +} + +// CreatorID returns the "creator" edge ID in the mutation. +func (m *PageMutation) CreatorID() (id uuid.UUID, exists bool) { + if m.creator != nil { + return *m.creator, true + } + return +} + +// CreatorIDs returns the "creator" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// CreatorID instead. It exists only for internal usage by the builders. +func (m *PageMutation) CreatorIDs() (ids []uuid.UUID) { + if id := m.creator; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetCreator resets all changes to the "creator" edge. +func (m *PageMutation) ResetCreator() { + m.creator = nil + m.clearedcreator = false +} + // SetModifierID sets the "modifier" edge to the User entity by id. -func (m *HackathonStateMutation) SetModifierID(id uuid.UUID) { +func (m *PageMutation) SetModifierID(id uuid.UUID) { m.modifier = &id } // ClearModifier clears the "modifier" edge to the User entity. -func (m *HackathonStateMutation) ClearModifier() { +func (m *PageMutation) ClearModifier() { m.clearedmodifier = true } // ModifierCleared reports if the "modifier" edge to the User entity was cleared. -func (m *HackathonStateMutation) ModifierCleared() bool { +func (m *PageMutation) ModifierCleared() bool { return m.clearedmodifier } // ModifierID returns the "modifier" edge ID in the mutation. -func (m *HackathonStateMutation) ModifierID() (id uuid.UUID, exists bool) { +func (m *PageMutation) ModifierID() (id uuid.UUID, exists bool) { if m.modifier != nil { return *m.modifier, true } @@ -2143,7 +3868,7 @@ func (m *HackathonStateMutation) ModifierID() (id uuid.UUID, exists bool) { // ModifierIDs returns the "modifier" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // ModifierID instead. It exists only for internal usage by the builders. -func (m *HackathonStateMutation) ModifierIDs() (ids []uuid.UUID) { +func (m *PageMutation) ModifierIDs() (ids []uuid.UUID) { if id := m.modifier; id != nil { ids = append(ids, *id) } @@ -2151,47 +3876,20 @@ func (m *HackathonStateMutation) ModifierIDs() (ids []uuid.UUID) { } // ResetModifier resets all changes to the "modifier" edge. -func (m *HackathonStateMutation) ResetModifier() { +func (m *PageMutation) ResetModifier() { m.modifier = nil m.clearedmodifier = false } -// ClearCurrentPhase clears the "current_phase" edge to the Phase entity. -func (m *HackathonStateMutation) ClearCurrentPhase() { - m.clearedcurrent_phase = true - m.clearedFields[hackathonstate.FieldCurrentPhaseID] = struct{}{} -} - -// CurrentPhaseCleared reports if the "current_phase" edge to the Phase entity was cleared. -func (m *HackathonStateMutation) CurrentPhaseCleared() bool { - return m.CurrentPhaseIDCleared() || m.clearedcurrent_phase -} - -// CurrentPhaseIDs returns the "current_phase" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// CurrentPhaseID instead. It exists only for internal usage by the builders. -func (m *HackathonStateMutation) CurrentPhaseIDs() (ids []uuid.UUID) { - if id := m.current_phase; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetCurrentPhase resets all changes to the "current_phase" edge. -func (m *HackathonStateMutation) ResetCurrentPhase() { - m.current_phase = nil - m.clearedcurrent_phase = false -} - -// Where appends a list predicates to the HackathonStateMutation builder. -func (m *HackathonStateMutation) Where(ps ...predicate.HackathonState) { +// Where appends a list predicates to the PageMutation builder. +func (m *PageMutation) Where(ps ...predicate.Page) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the HackathonStateMutation builder. Using this method, +// WhereP appends storage-level predicates to the PageMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *HackathonStateMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.HackathonState, len(ps)) +func (m *PageMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Page, len(ps)) for i := range ps { p[i] = ps[i] } @@ -2199,51 +3897,42 @@ func (m *HackathonStateMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *HackathonStateMutation) Op() Op { +func (m *PageMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *HackathonStateMutation) SetOp(op Op) { +func (m *PageMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (HackathonState). -func (m *HackathonStateMutation) Type() string { +// Type returns the node type of this mutation (Page). +func (m *PageMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *HackathonStateMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.registrations_enabled != nil { - fields = append(fields, hackathonstate.FieldRegistrationsEnabled) - } - if m.voting_enabled != nil { - fields = append(fields, hackathonstate.FieldVotingEnabled) - } - if m.propose_projects_enabled != nil { - fields = append(fields, hackathonstate.FieldProposeProjectsEnabled) +func (m *PageMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.title != nil { + fields = append(fields, page.FieldTitle) } - if m.set_team_preferences_enabled != nil { - fields = append(fields, hackathonstate.FieldSetTeamPreferencesEnabled) + if m.content != nil { + fields = append(fields, page.FieldContent) } - if m.create_project_submissions_enabled != nil { - fields = append(fields, hackathonstate.FieldCreateProjectSubmissionsEnabled) + if m.visible != nil { + fields = append(fields, page.FieldVisible) } - if m.view_results_enabled != nil { - fields = append(fields, hackathonstate.FieldViewResultsEnabled) + if m._order != nil { + fields = append(fields, page.FieldOrder) } if m.created_at != nil { - fields = append(fields, hackathonstate.FieldCreatedAt) + fields = append(fields, page.FieldCreatedAt) } if m.modified_at != nil { - fields = append(fields, hackathonstate.FieldModifiedAt) - } - if m.current_phase != nil { - fields = append(fields, hackathonstate.FieldCurrentPhaseID) + fields = append(fields, page.FieldModifiedAt) } return fields } @@ -2251,26 +3940,20 @@ func (m *HackathonStateMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *HackathonStateMutation) Field(name string) (ent.Value, bool) { +func (m *PageMutation) Field(name string) (ent.Value, bool) { switch name { - case hackathonstate.FieldRegistrationsEnabled: - return m.RegistrationsEnabled() - case hackathonstate.FieldVotingEnabled: - return m.VotingEnabled() - case hackathonstate.FieldProposeProjectsEnabled: - return m.ProposeProjectsEnabled() - case hackathonstate.FieldSetTeamPreferencesEnabled: - return m.SetTeamPreferencesEnabled() - case hackathonstate.FieldCreateProjectSubmissionsEnabled: - return m.CreateProjectSubmissionsEnabled() - case hackathonstate.FieldViewResultsEnabled: - return m.ViewResultsEnabled() - case hackathonstate.FieldCreatedAt: + case page.FieldTitle: + return m.Title() + case page.FieldContent: + return m.Content() + case page.FieldVisible: + return m.Visible() + case page.FieldOrder: + return m.Order() + case page.FieldCreatedAt: return m.CreatedAt() - case hackathonstate.FieldModifiedAt: + case page.FieldModifiedAt: return m.ModifiedAt() - case hackathonstate.FieldCurrentPhaseID: - return m.CurrentPhaseID() } return nil, false } @@ -2278,216 +3961,193 @@ func (m *HackathonStateMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *HackathonStateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *PageMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case hackathonstate.FieldRegistrationsEnabled: - return m.OldRegistrationsEnabled(ctx) - case hackathonstate.FieldVotingEnabled: - return m.OldVotingEnabled(ctx) - case hackathonstate.FieldProposeProjectsEnabled: - return m.OldProposeProjectsEnabled(ctx) - case hackathonstate.FieldSetTeamPreferencesEnabled: - return m.OldSetTeamPreferencesEnabled(ctx) - case hackathonstate.FieldCreateProjectSubmissionsEnabled: - return m.OldCreateProjectSubmissionsEnabled(ctx) - case hackathonstate.FieldViewResultsEnabled: - return m.OldViewResultsEnabled(ctx) - case hackathonstate.FieldCreatedAt: + case page.FieldTitle: + return m.OldTitle(ctx) + case page.FieldContent: + return m.OldContent(ctx) + case page.FieldVisible: + return m.OldVisible(ctx) + case page.FieldOrder: + return m.OldOrder(ctx) + case page.FieldCreatedAt: return m.OldCreatedAt(ctx) - case hackathonstate.FieldModifiedAt: + case page.FieldModifiedAt: return m.OldModifiedAt(ctx) - case hackathonstate.FieldCurrentPhaseID: - return m.OldCurrentPhaseID(ctx) } - return nil, fmt.Errorf("unknown HackathonState field %s", name) + return nil, fmt.Errorf("unknown Page field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *HackathonStateMutation) SetField(name string, value ent.Value) error { +func (m *PageMutation) SetField(name string, value ent.Value) error { switch name { - case hackathonstate.FieldRegistrationsEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegistrationsEnabled(v) - return nil - case hackathonstate.FieldVotingEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVotingEnabled(v) - return nil - case hackathonstate.FieldProposeProjectsEnabled: - v, ok := value.(bool) + case page.FieldTitle: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProposeProjectsEnabled(v) + m.SetTitle(v) return nil - case hackathonstate.FieldSetTeamPreferencesEnabled: - v, ok := value.(bool) + case page.FieldContent: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSetTeamPreferencesEnabled(v) + m.SetContent(v) return nil - case hackathonstate.FieldCreateProjectSubmissionsEnabled: + case page.FieldVisible: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreateProjectSubmissionsEnabled(v) + m.SetVisible(v) return nil - case hackathonstate.FieldViewResultsEnabled: - v, ok := value.(bool) + case page.FieldOrder: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetViewResultsEnabled(v) + m.SetOrder(v) return nil - case hackathonstate.FieldCreatedAt: + case page.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case hackathonstate.FieldModifiedAt: + case page.FieldModifiedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetModifiedAt(v) return nil - case hackathonstate.FieldCurrentPhaseID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCurrentPhaseID(v) - return nil } - return fmt.Errorf("unknown HackathonState field %s", name) + return fmt.Errorf("unknown Page field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *HackathonStateMutation) AddedFields() []string { - return nil +func (m *PageMutation) AddedFields() []string { + var fields []string + if m.add_order != nil { + fields = append(fields, page.FieldOrder) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *HackathonStateMutation) AddedField(name string) (ent.Value, bool) { +func (m *PageMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case page.FieldOrder: + return m.AddedOrder() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *HackathonStateMutation) AddField(name string, value ent.Value) error { +func (m *PageMutation) AddField(name string, value ent.Value) error { switch name { + case page.FieldOrder: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddOrder(v) + return nil } - return fmt.Errorf("unknown HackathonState numeric field %s", name) + return fmt.Errorf("unknown Page numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *HackathonStateMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(hackathonstate.FieldCurrentPhaseID) { - fields = append(fields, hackathonstate.FieldCurrentPhaseID) - } - return fields +func (m *PageMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *HackathonStateMutation) FieldCleared(name string) bool { +func (m *PageMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *HackathonStateMutation) ClearField(name string) error { - switch name { - case hackathonstate.FieldCurrentPhaseID: - m.ClearCurrentPhaseID() - return nil - } - return fmt.Errorf("unknown HackathonState nullable field %s", name) +func (m *PageMutation) ClearField(name string) error { + return fmt.Errorf("unknown Page nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *HackathonStateMutation) ResetField(name string) error { +func (m *PageMutation) ResetField(name string) error { switch name { - case hackathonstate.FieldRegistrationsEnabled: - m.ResetRegistrationsEnabled() - return nil - case hackathonstate.FieldVotingEnabled: - m.ResetVotingEnabled() - return nil - case hackathonstate.FieldProposeProjectsEnabled: - m.ResetProposeProjectsEnabled() + case page.FieldTitle: + m.ResetTitle() return nil - case hackathonstate.FieldSetTeamPreferencesEnabled: - m.ResetSetTeamPreferencesEnabled() + case page.FieldContent: + m.ResetContent() return nil - case hackathonstate.FieldCreateProjectSubmissionsEnabled: - m.ResetCreateProjectSubmissionsEnabled() + case page.FieldVisible: + m.ResetVisible() return nil - case hackathonstate.FieldViewResultsEnabled: - m.ResetViewResultsEnabled() + case page.FieldOrder: + m.ResetOrder() return nil - case hackathonstate.FieldCreatedAt: + case page.FieldCreatedAt: m.ResetCreatedAt() return nil - case hackathonstate.FieldModifiedAt: + case page.FieldModifiedAt: m.ResetModifiedAt() return nil - case hackathonstate.FieldCurrentPhaseID: - m.ResetCurrentPhaseID() - return nil } - return fmt.Errorf("unknown HackathonState field %s", name) + return fmt.Errorf("unknown Page field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *HackathonStateMutation) AddedEdges() []string { - edges := make([]string, 0, 3) +func (m *PageMutation) AddedEdges() []string { + edges := make([]string, 0, 4) if m.hackathon != nil { - edges = append(edges, hackathonstate.EdgeHackathon) + edges = append(edges, page.EdgeHackathon) } - if m.modifier != nil { - edges = append(edges, hackathonstate.EdgeModifier) + if m.phase != nil { + edges = append(edges, page.EdgePhase) } - if m.current_phase != nil { - edges = append(edges, hackathonstate.EdgeCurrentPhase) + if m.creator != nil { + edges = append(edges, page.EdgeCreator) + } + if m.modifier != nil { + edges = append(edges, page.EdgeModifier) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *HackathonStateMutation) AddedIDs(name string) []ent.Value { +func (m *PageMutation) AddedIDs(name string) []ent.Value { switch name { - case hackathonstate.EdgeHackathon: + case page.EdgeHackathon: if id := m.hackathon; id != nil { return []ent.Value{*id} } - case hackathonstate.EdgeModifier: - if id := m.modifier; id != nil { + case page.EdgePhase: + if id := m.phase; id != nil { return []ent.Value{*id} } - case hackathonstate.EdgeCurrentPhase: - if id := m.current_phase; id != nil { + case page.EdgeCreator: + if id := m.creator; id != nil { + return []ent.Value{*id} + } + case page.EdgeModifier: + if id := m.modifier; id != nil { return []ent.Value{*id} } } @@ -2495,118 +4155,119 @@ func (m *HackathonStateMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *HackathonStateMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) +func (m *PageMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *HackathonStateMutation) RemovedIDs(name string) []ent.Value { +func (m *PageMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *HackathonStateMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) +func (m *PageMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) if m.clearedhackathon { - edges = append(edges, hackathonstate.EdgeHackathon) + edges = append(edges, page.EdgeHackathon) } - if m.clearedmodifier { - edges = append(edges, hackathonstate.EdgeModifier) + if m.clearedphase { + edges = append(edges, page.EdgePhase) } - if m.clearedcurrent_phase { - edges = append(edges, hackathonstate.EdgeCurrentPhase) + if m.clearedcreator { + edges = append(edges, page.EdgeCreator) + } + if m.clearedmodifier { + edges = append(edges, page.EdgeModifier) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *HackathonStateMutation) EdgeCleared(name string) bool { +func (m *PageMutation) EdgeCleared(name string) bool { switch name { - case hackathonstate.EdgeHackathon: + case page.EdgeHackathon: return m.clearedhackathon - case hackathonstate.EdgeModifier: + case page.EdgePhase: + return m.clearedphase + case page.EdgeCreator: + return m.clearedcreator + case page.EdgeModifier: return m.clearedmodifier - case hackathonstate.EdgeCurrentPhase: - return m.clearedcurrent_phase } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *HackathonStateMutation) ClearEdge(name string) error { +func (m *PageMutation) ClearEdge(name string) error { switch name { - case hackathonstate.EdgeHackathon: + case page.EdgeHackathon: m.ClearHackathon() return nil - case hackathonstate.EdgeModifier: - m.ClearModifier() + case page.EdgePhase: + m.ClearPhase() return nil - case hackathonstate.EdgeCurrentPhase: - m.ClearCurrentPhase() + case page.EdgeCreator: + m.ClearCreator() + return nil + case page.EdgeModifier: + m.ClearModifier() return nil } - return fmt.Errorf("unknown HackathonState unique edge %s", name) + return fmt.Errorf("unknown Page unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *HackathonStateMutation) ResetEdge(name string) error { +func (m *PageMutation) ResetEdge(name string) error { switch name { - case hackathonstate.EdgeHackathon: + case page.EdgeHackathon: m.ResetHackathon() return nil - case hackathonstate.EdgeModifier: - m.ResetModifier() + case page.EdgePhase: + m.ResetPhase() return nil - case hackathonstate.EdgeCurrentPhase: - m.ResetCurrentPhase() + case page.EdgeCreator: + m.ResetCreator() + return nil + case page.EdgeModifier: + m.ResetModifier() return nil } - return fmt.Errorf("unknown HackathonState edge %s", name) + return fmt.Errorf("unknown Page edge %s", name) } -// PageMutation represents an operation that mutates the Page nodes in the graph. -type PageMutation struct { +// ParticipantMutation represents an operation that mutates the Participant nodes in the graph. +type ParticipantMutation struct { config op Op typ string - id *uuid.UUID - title *string - content *string - visible *bool - _order *int - add_order *int + is_waiting *bool created_at *time.Time - modified_at *time.Time clearedFields map[string]struct{} hackathon *uuid.UUID clearedhackathon bool - phase *uuid.UUID - clearedphase bool - creator *uuid.UUID - clearedcreator bool - modifier *uuid.UUID - clearedmodifier bool + user *uuid.UUID + cleareduser bool done bool - oldValue func(context.Context) (*Page, error) - predicates []predicate.Page + oldValue func(context.Context) (*Participant, error) + predicates []predicate.Participant } -var _ ent.Mutation = (*PageMutation)(nil) +var _ ent.Mutation = (*ParticipantMutation)(nil) -// pageOption allows management of the mutation configuration using functional options. -type pageOption func(*PageMutation) +// participantOption allows management of the mutation configuration using functional options. +type participantOption func(*ParticipantMutation) -// newPageMutation creates new mutation for the Page entity. -func newPageMutation(c config, op Op, opts ...pageOption) *PageMutation { - m := &PageMutation{ +// newParticipantMutation creates new mutation for the Participant entity. +func newParticipantMutation(c config, op Op, opts ...participantOption) *ParticipantMutation { + m := &ParticipantMutation{ config: c, op: op, - typ: TypePage, + typ: TypeParticipant, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -2615,41 +4276,9 @@ func newPageMutation(c config, op Op, opts ...pageOption) *PageMutation { return m } -// withPageID sets the ID field of the mutation. -func withPageID(id uuid.UUID) pageOption { - return func(m *PageMutation) { - var ( - err error - once sync.Once - value *Page - ) - m.oldValue = func(ctx context.Context) (*Page, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Page.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withPage sets the old Page of the mutation. -func withPage(node *Page) pageOption { - return func(m *PageMutation) { - m.oldValue = func(context.Context) (*Page, error) { - return node, nil - } - m.id = &node.ID - } -} - // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m PageMutation) Client() *Client { +func (m ParticipantMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -2657,7 +4286,7 @@ func (m PageMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m PageMutation) Tx() (*Tx, error) { +func (m ParticipantMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -2666,985 +4295,1115 @@ func (m PageMutation) Tx() (*Tx, error) { return tx, nil } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Page entities. -func (m *PageMutation) SetID(id uuid.UUID) { - m.id = &id +// SetHackathonID sets the "hackathon_id" field. +func (m *ParticipantMutation) SetHackathonID(u uuid.UUID) { + m.hackathon = &u } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *PageMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { +// HackathonID returns the value of the "hackathon_id" field in the mutation. +func (m *ParticipantMutation) HackathonID() (r uuid.UUID, exists bool) { + v := m.hackathon + if v == nil { + return + } + return *v, true +} + +// ResetHackathonID resets all changes to the "hackathon_id" field. +func (m *ParticipantMutation) ResetHackathonID() { + m.hackathon = nil +} + +// SetUserID sets the "user_id" field. +func (m *ParticipantMutation) SetUserID(u uuid.UUID) { + m.user = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *ParticipantMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *ParticipantMutation) ResetUserID() { + m.user = nil +} + +// SetIsWaiting sets the "is_waiting" field. +func (m *ParticipantMutation) SetIsWaiting(b bool) { + m.is_waiting = &b +} + +// IsWaiting returns the value of the "is_waiting" field in the mutation. +func (m *ParticipantMutation) IsWaiting() (r bool, exists bool) { + v := m.is_waiting + if v == nil { + return + } + return *v, true +} + +// ResetIsWaiting resets all changes to the "is_waiting" field. +func (m *ParticipantMutation) ResetIsWaiting() { + m.is_waiting = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *ParticipantMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ParticipantMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { return } - return *m.id, true + return *v, true +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ParticipantMutation) ResetCreatedAt() { + m.created_at = nil +} + +// ClearHackathon clears the "hackathon" edge to the Hackathon entity. +func (m *ParticipantMutation) ClearHackathon() { + m.clearedhackathon = true + m.clearedFields[participant.FieldHackathonID] = struct{}{} +} + +// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. +func (m *ParticipantMutation) HackathonCleared() bool { + return m.clearedhackathon +} + +// HackathonIDs returns the "hackathon" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// HackathonID instead. It exists only for internal usage by the builders. +func (m *ParticipantMutation) HackathonIDs() (ids []uuid.UUID) { + if id := m.hackathon; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetHackathon resets all changes to the "hackathon" edge. +func (m *ParticipantMutation) ResetHackathon() { + m.hackathon = nil + m.clearedhackathon = false +} + +// ClearUser clears the "user" edge to the User entity. +func (m *ParticipantMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[participant.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *ParticipantMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *ParticipantMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *ParticipantMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// Where appends a list predicates to the ParticipantMutation builder. +func (m *ParticipantMutation) Where(ps ...predicate.Participant) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ParticipantMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ParticipantMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Participant, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ParticipantMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ParticipantMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Participant). +func (m *ParticipantMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ParticipantMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.hackathon != nil { + fields = append(fields, participant.FieldHackathonID) + } + if m.user != nil { + fields = append(fields, participant.FieldUserID) + } + if m.is_waiting != nil { + fields = append(fields, participant.FieldIsWaiting) + } + if m.created_at != nil { + fields = append(fields, participant.FieldCreatedAt) + } + return fields } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *PageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Page.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ParticipantMutation) Field(name string) (ent.Value, bool) { + switch name { + case participant.FieldHackathonID: + return m.HackathonID() + case participant.FieldUserID: + return m.UserID() + case participant.FieldIsWaiting: + return m.IsWaiting() + case participant.FieldCreatedAt: + return m.CreatedAt() } + return nil, false } -// SetTitle sets the "title" field. -func (m *PageMutation) SetTitle(s string) { - m.title = &s -} - -// Title returns the value of the "title" field in the mutation. -func (m *PageMutation) Title() (r string, exists bool) { - v := m.title - if v == nil { - return - } - return *v, true +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ParticipantMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, errors.New("edge schema Participant does not support getting old values") } -// OldTitle returns the old "title" field's value of the Page entity. -// If the Page object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PageMutation) OldTitle(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTitle is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTitle requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTitle: %w", err) +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ParticipantMutation) SetField(name string, value ent.Value) error { + switch name { + case participant.FieldHackathonID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHackathonID(v) + return nil + case participant.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case participant.FieldIsWaiting: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsWaiting(v) + return nil + case participant.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil } - return oldValue.Title, nil + return fmt.Errorf("unknown Participant field %s", name) } -// ResetTitle resets all changes to the "title" field. -func (m *PageMutation) ResetTitle() { - m.title = nil +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ParticipantMutation) AddedFields() []string { + return nil } -// SetContent sets the "content" field. -func (m *PageMutation) SetContent(s string) { - m.content = &s +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ParticipantMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// Content returns the value of the "content" field in the mutation. -func (m *PageMutation) Content() (r string, exists bool) { - v := m.content - if v == nil { - return +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ParticipantMutation) AddField(name string, value ent.Value) error { + switch name { } - return *v, true + return fmt.Errorf("unknown Participant numeric field %s", name) } -// OldContent returns the old "content" field's value of the Page entity. -// If the Page object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PageMutation) OldContent(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldContent is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldContent requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldContent: %w", err) - } - return oldValue.Content, nil +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ParticipantMutation) ClearedFields() []string { + return nil } -// ResetContent resets all changes to the "content" field. -func (m *PageMutation) ResetContent() { - m.content = nil +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ParticipantMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok } -// SetVisible sets the "visible" field. -func (m *PageMutation) SetVisible(b bool) { - m.visible = &b +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ParticipantMutation) ClearField(name string) error { + return fmt.Errorf("unknown Participant nullable field %s", name) } -// Visible returns the value of the "visible" field in the mutation. -func (m *PageMutation) Visible() (r bool, exists bool) { - v := m.visible - if v == nil { - return +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ParticipantMutation) ResetField(name string) error { + switch name { + case participant.FieldHackathonID: + m.ResetHackathonID() + return nil + case participant.FieldUserID: + m.ResetUserID() + return nil + case participant.FieldIsWaiting: + m.ResetIsWaiting() + return nil + case participant.FieldCreatedAt: + m.ResetCreatedAt() + return nil } - return *v, true + return fmt.Errorf("unknown Participant field %s", name) } -// OldVisible returns the old "visible" field's value of the Page entity. -// If the Page object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PageMutation) OldVisible(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVisible is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVisible requires an ID field in the mutation") +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ParticipantMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.hackathon != nil { + edges = append(edges, participant.EdgeHackathon) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVisible: %w", err) + if m.user != nil { + edges = append(edges, participant.EdgeUser) } - return oldValue.Visible, nil + return edges } -// ResetVisible resets all changes to the "visible" field. -func (m *PageMutation) ResetVisible() { - m.visible = nil +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ParticipantMutation) AddedIDs(name string) []ent.Value { + switch name { + case participant.EdgeHackathon: + if id := m.hackathon; id != nil { + return []ent.Value{*id} + } + case participant.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + } + return nil } -// SetOrder sets the "order" field. -func (m *PageMutation) SetOrder(i int) { - m._order = &i - m.add_order = nil +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ParticipantMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges } -// Order returns the value of the "order" field in the mutation. -func (m *PageMutation) Order() (r int, exists bool) { - v := m._order - if v == nil { - return - } - return *v, true +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ParticipantMutation) RemovedIDs(name string) []ent.Value { + return nil } -// OldOrder returns the old "order" field's value of the Page entity. -// If the Page object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PageMutation) OldOrder(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOrder is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOrder requires an ID field in the mutation") +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ParticipantMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedhackathon { + edges = append(edges, participant.EdgeHackathon) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldOrder: %w", err) + if m.cleareduser { + edges = append(edges, participant.EdgeUser) } - return oldValue.Order, nil + return edges } -// AddOrder adds i to the "order" field. -func (m *PageMutation) AddOrder(i int) { - if m.add_order != nil { - *m.add_order += i - } else { - m.add_order = &i +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ParticipantMutation) EdgeCleared(name string) bool { + switch name { + case participant.EdgeHackathon: + return m.clearedhackathon + case participant.EdgeUser: + return m.cleareduser } + return false } -// AddedOrder returns the value that was added to the "order" field in this mutation. -func (m *PageMutation) AddedOrder() (r int, exists bool) { - v := m.add_order - if v == nil { - return +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ParticipantMutation) ClearEdge(name string) error { + switch name { + case participant.EdgeHackathon: + m.ClearHackathon() + return nil + case participant.EdgeUser: + m.ClearUser() + return nil } - return *v, true + return fmt.Errorf("unknown Participant unique edge %s", name) } -// ResetOrder resets all changes to the "order" field. -func (m *PageMutation) ResetOrder() { - m._order = nil - m.add_order = nil +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ParticipantMutation) ResetEdge(name string) error { + switch name { + case participant.EdgeHackathon: + m.ResetHackathon() + return nil + case participant.EdgeUser: + m.ResetUser() + return nil + } + return fmt.Errorf("unknown Participant edge %s", name) } -// SetCreatedAt sets the "created_at" field. -func (m *PageMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// PhaseMutation represents an operation that mutates the Phase nodes in the graph. +type PhaseMutation struct { + config + op Op + typ string + id *uuid.UUID + starts_at *time.Time + ends_at *time.Time + name *string + description *string + created_at *time.Time + modified_at *time.Time + capabilities *[]string + appendcapabilities []string + clearedFields map[string]struct{} + hackathon *uuid.UUID + clearedhackathon bool + page *uuid.UUID + clearedpage bool + current_of map[uuid.UUID]struct{} + removedcurrent_of map[uuid.UUID]struct{} + clearedcurrent_of bool + creator *uuid.UUID + clearedcreator bool + modifier *uuid.UUID + clearedmodifier bool + current_state *uuid.UUID + clearedcurrent_state bool + done bool + oldValue func(context.Context) (*Phase, error) + predicates []predicate.Phase } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *PageMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} +var _ ent.Mutation = (*PhaseMutation)(nil) -// OldCreatedAt returns the old "created_at" field's value of the Page entity. -// If the Page object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") +// phaseOption allows management of the mutation configuration using functional options. +type phaseOption func(*PhaseMutation) + +// newPhaseMutation creates new mutation for the Phase entity. +func newPhaseMutation(c config, op Op, opts ...phaseOption) *PhaseMutation { + m := &PhaseMutation{ + config: c, + op: op, + typ: TypePhase, + clearedFields: make(map[string]struct{}), } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + for _, opt := range opts { + opt(m) } - return oldValue.CreatedAt, nil + return m } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *PageMutation) ResetCreatedAt() { - m.created_at = nil +// withPhaseID sets the ID field of the mutation. +func withPhaseID(id uuid.UUID) phaseOption { + return func(m *PhaseMutation) { + var ( + err error + once sync.Once + value *Phase + ) + m.oldValue = func(ctx context.Context) (*Phase, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Phase.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } } -// SetModifiedAt sets the "modified_at" field. -func (m *PageMutation) SetModifiedAt(t time.Time) { - m.modified_at = &t +// withPhase sets the old Phase of the mutation. +func withPhase(node *Phase) phaseOption { + return func(m *PhaseMutation) { + m.oldValue = func(context.Context) (*Phase, error) { + return node, nil + } + m.id = &node.ID + } } -// ModifiedAt returns the value of the "modified_at" field in the mutation. -func (m *PageMutation) ModifiedAt() (r time.Time, exists bool) { - v := m.modified_at - if v == nil { - return - } - return *v, true +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PhaseMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// OldModifiedAt returns the old "modified_at" field's value of the Page entity. -// If the Page object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PageMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModifiedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PhaseMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") } - return oldValue.ModifiedAt, nil + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetModifiedAt resets all changes to the "modified_at" field. -func (m *PageMutation) ResetModifiedAt() { - m.modified_at = nil +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Phase entities. +func (m *PhaseMutation) SetID(id uuid.UUID) { + m.id = &id } -// SetHackathonID sets the "hackathon" edge to the Hackathon entity by id. -func (m *PageMutation) SetHackathonID(id uuid.UUID) { - m.hackathon = &id +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PhaseMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// ClearHackathon clears the "hackathon" edge to the Hackathon entity. -func (m *PageMutation) ClearHackathon() { - m.clearedhackathon = true +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PhaseMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Phase.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. -func (m *PageMutation) HackathonCleared() bool { - return m.clearedhackathon +// SetStartsAt sets the "starts_at" field. +func (m *PhaseMutation) SetStartsAt(t time.Time) { + m.starts_at = &t } -// HackathonID returns the "hackathon" edge ID in the mutation. -func (m *PageMutation) HackathonID() (id uuid.UUID, exists bool) { - if m.hackathon != nil { - return *m.hackathon, true +// StartsAt returns the value of the "starts_at" field in the mutation. +func (m *PhaseMutation) StartsAt() (r time.Time, exists bool) { + v := m.starts_at + if v == nil { + return } - return + return *v, true } -// HackathonIDs returns the "hackathon" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// HackathonID instead. It exists only for internal usage by the builders. -func (m *PageMutation) HackathonIDs() (ids []uuid.UUID) { - if id := m.hackathon; id != nil { - ids = append(ids, *id) +// OldStartsAt returns the old "starts_at" field's value of the Phase entity. +// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhaseMutation) OldStartsAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStartsAt is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStartsAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStartsAt: %w", err) + } + return oldValue.StartsAt, nil } -// ResetHackathon resets all changes to the "hackathon" edge. -func (m *PageMutation) ResetHackathon() { - m.hackathon = nil - m.clearedhackathon = false +// ClearStartsAt clears the value of the "starts_at" field. +func (m *PhaseMutation) ClearStartsAt() { + m.starts_at = nil + m.clearedFields[phase.FieldStartsAt] = struct{}{} } -// SetPhaseID sets the "phase" edge to the Phase entity by id. -func (m *PageMutation) SetPhaseID(id uuid.UUID) { - m.phase = &id +// StartsAtCleared returns if the "starts_at" field was cleared in this mutation. +func (m *PhaseMutation) StartsAtCleared() bool { + _, ok := m.clearedFields[phase.FieldStartsAt] + return ok } -// ClearPhase clears the "phase" edge to the Phase entity. -func (m *PageMutation) ClearPhase() { - m.clearedphase = true +// ResetStartsAt resets all changes to the "starts_at" field. +func (m *PhaseMutation) ResetStartsAt() { + m.starts_at = nil + delete(m.clearedFields, phase.FieldStartsAt) } -// PhaseCleared reports if the "phase" edge to the Phase entity was cleared. -func (m *PageMutation) PhaseCleared() bool { - return m.clearedphase +// SetEndsAt sets the "ends_at" field. +func (m *PhaseMutation) SetEndsAt(t time.Time) { + m.ends_at = &t } -// PhaseID returns the "phase" edge ID in the mutation. -func (m *PageMutation) PhaseID() (id uuid.UUID, exists bool) { - if m.phase != nil { - return *m.phase, true +// EndsAt returns the value of the "ends_at" field in the mutation. +func (m *PhaseMutation) EndsAt() (r time.Time, exists bool) { + v := m.ends_at + if v == nil { + return } - return + return *v, true } -// PhaseIDs returns the "phase" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PhaseID instead. It exists only for internal usage by the builders. -func (m *PageMutation) PhaseIDs() (ids []uuid.UUID) { - if id := m.phase; id != nil { - ids = append(ids, *id) +// OldEndsAt returns the old "ends_at" field's value of the Phase entity. +// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhaseMutation) OldEndsAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEndsAt is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEndsAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEndsAt: %w", err) + } + return oldValue.EndsAt, nil } -// ResetPhase resets all changes to the "phase" edge. -func (m *PageMutation) ResetPhase() { - m.phase = nil - m.clearedphase = false +// ClearEndsAt clears the value of the "ends_at" field. +func (m *PhaseMutation) ClearEndsAt() { + m.ends_at = nil + m.clearedFields[phase.FieldEndsAt] = struct{}{} } -// SetCreatorID sets the "creator" edge to the User entity by id. -func (m *PageMutation) SetCreatorID(id uuid.UUID) { - m.creator = &id +// EndsAtCleared returns if the "ends_at" field was cleared in this mutation. +func (m *PhaseMutation) EndsAtCleared() bool { + _, ok := m.clearedFields[phase.FieldEndsAt] + return ok } -// ClearCreator clears the "creator" edge to the User entity. -func (m *PageMutation) ClearCreator() { - m.clearedcreator = true +// ResetEndsAt resets all changes to the "ends_at" field. +func (m *PhaseMutation) ResetEndsAt() { + m.ends_at = nil + delete(m.clearedFields, phase.FieldEndsAt) } -// CreatorCleared reports if the "creator" edge to the User entity was cleared. -func (m *PageMutation) CreatorCleared() bool { - return m.clearedcreator +// SetName sets the "name" field. +func (m *PhaseMutation) SetName(s string) { + m.name = &s } -// CreatorID returns the "creator" edge ID in the mutation. -func (m *PageMutation) CreatorID() (id uuid.UUID, exists bool) { - if m.creator != nil { - return *m.creator, true +// Name returns the value of the "name" field in the mutation. +func (m *PhaseMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return } - return + return *v, true } -// CreatorIDs returns the "creator" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// CreatorID instead. It exists only for internal usage by the builders. -func (m *PageMutation) CreatorIDs() (ids []uuid.UUID) { - if id := m.creator; id != nil { - ids = append(ids, *id) +// OldName returns the old "name" field's value of the Phase entity. +// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhaseMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil } -// ResetCreator resets all changes to the "creator" edge. -func (m *PageMutation) ResetCreator() { - m.creator = nil - m.clearedcreator = false +// ResetName resets all changes to the "name" field. +func (m *PhaseMutation) ResetName() { + m.name = nil } -// SetModifierID sets the "modifier" edge to the User entity by id. -func (m *PageMutation) SetModifierID(id uuid.UUID) { - m.modifier = &id +// SetDescription sets the "description" field. +func (m *PhaseMutation) SetDescription(s string) { + m.description = &s } -// ClearModifier clears the "modifier" edge to the User entity. -func (m *PageMutation) ClearModifier() { - m.clearedmodifier = true +// Description returns the value of the "description" field in the mutation. +func (m *PhaseMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true } -// ModifierCleared reports if the "modifier" edge to the User entity was cleared. -func (m *PageMutation) ModifierCleared() bool { - return m.clearedmodifier +// OldDescription returns the old "description" field's value of the Phase entity. +// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhaseMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil } -// ModifierID returns the "modifier" edge ID in the mutation. -func (m *PageMutation) ModifierID() (id uuid.UUID, exists bool) { - if m.modifier != nil { - return *m.modifier, true - } - return +// ClearDescription clears the value of the "description" field. +func (m *PhaseMutation) ClearDescription() { + m.description = nil + m.clearedFields[phase.FieldDescription] = struct{}{} } -// ModifierIDs returns the "modifier" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ModifierID instead. It exists only for internal usage by the builders. -func (m *PageMutation) ModifierIDs() (ids []uuid.UUID) { - if id := m.modifier; id != nil { - ids = append(ids, *id) - } - return +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *PhaseMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[phase.FieldDescription] + return ok } -// ResetModifier resets all changes to the "modifier" edge. -func (m *PageMutation) ResetModifier() { - m.modifier = nil - m.clearedmodifier = false +// ResetDescription resets all changes to the "description" field. +func (m *PhaseMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, phase.FieldDescription) } -// Where appends a list predicates to the PageMutation builder. -func (m *PageMutation) Where(ps ...predicate.Page) { - m.predicates = append(m.predicates, ps...) +// SetCreatedAt sets the "created_at" field. +func (m *PhaseMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// WhereP appends storage-level predicates to the PageMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PageMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Page, len(ps)) - for i := range ps { - p[i] = ps[i] +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PhaseMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return } - m.Where(p...) + return *v, true } -// Op returns the operation name. -func (m *PageMutation) Op() Op { - return m.op +// OldCreatedAt returns the old "created_at" field's value of the Phase entity. +// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhaseMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil } -// SetOp allows setting the mutation operation. -func (m *PageMutation) SetOp(op Op) { - m.op = op +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PhaseMutation) ResetCreatedAt() { + m.created_at = nil } -// Type returns the node type of this mutation (Page). -func (m *PageMutation) Type() string { - return m.typ +// SetModifiedAt sets the "modified_at" field. +func (m *PhaseMutation) SetModifiedAt(t time.Time) { + m.modified_at = &t +} + +// ModifiedAt returns the value of the "modified_at" field in the mutation. +func (m *PhaseMutation) ModifiedAt() (r time.Time, exists bool) { + v := m.modified_at + if v == nil { + return + } + return *v, true } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *PageMutation) Fields() []string { - fields := make([]string, 0, 6) - if m.title != nil { - fields = append(fields, page.FieldTitle) - } - if m.content != nil { - fields = append(fields, page.FieldContent) - } - if m.visible != nil { - fields = append(fields, page.FieldVisible) - } - if m._order != nil { - fields = append(fields, page.FieldOrder) +// OldModifiedAt returns the old "modified_at" field's value of the Phase entity. +// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhaseMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") } - if m.created_at != nil { - fields = append(fields, page.FieldCreatedAt) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModifiedAt requires an ID field in the mutation") } - if m.modified_at != nil { - fields = append(fields, page.FieldModifiedAt) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) } - return fields + return oldValue.ModifiedAt, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *PageMutation) Field(name string) (ent.Value, bool) { - switch name { - case page.FieldTitle: - return m.Title() - case page.FieldContent: - return m.Content() - case page.FieldVisible: - return m.Visible() - case page.FieldOrder: - return m.Order() - case page.FieldCreatedAt: - return m.CreatedAt() - case page.FieldModifiedAt: - return m.ModifiedAt() - } - return nil, false +// ResetModifiedAt resets all changes to the "modified_at" field. +func (m *PhaseMutation) ResetModifiedAt() { + m.modified_at = nil } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *PageMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case page.FieldTitle: - return m.OldTitle(ctx) - case page.FieldContent: - return m.OldContent(ctx) - case page.FieldVisible: - return m.OldVisible(ctx) - case page.FieldOrder: - return m.OldOrder(ctx) - case page.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case page.FieldModifiedAt: - return m.OldModifiedAt(ctx) - } - return nil, fmt.Errorf("unknown Page field %s", name) +// SetCapabilities sets the "capabilities" field. +func (m *PhaseMutation) SetCapabilities(s []string) { + m.capabilities = &s + m.appendcapabilities = nil } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PageMutation) SetField(name string, value ent.Value) error { - switch name { - case page.FieldTitle: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTitle(v) - return nil - case page.FieldContent: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetContent(v) - return nil - case page.FieldVisible: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVisible(v) - return nil - case page.FieldOrder: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetOrder(v) - return nil - case page.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case page.FieldModifiedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetModifiedAt(v) - return nil +// Capabilities returns the value of the "capabilities" field in the mutation. +func (m *PhaseMutation) Capabilities() (r []string, exists bool) { + v := m.capabilities + if v == nil { + return } - return fmt.Errorf("unknown Page field %s", name) + return *v, true } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *PageMutation) AddedFields() []string { - var fields []string - if m.add_order != nil { - fields = append(fields, page.FieldOrder) +// OldCapabilities returns the old "capabilities" field's value of the Phase entity. +// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhaseMutation) OldCapabilities(ctx context.Context) (v []string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCapabilities is only allowed on UpdateOne operations") } - return fields + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCapabilities requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCapabilities: %w", err) + } + return oldValue.Capabilities, nil } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *PageMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case page.FieldOrder: - return m.AddedOrder() - } - return nil, false +// AppendCapabilities adds s to the "capabilities" field. +func (m *PhaseMutation) AppendCapabilities(s []string) { + m.appendcapabilities = append(m.appendcapabilities, s...) } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PageMutation) AddField(name string, value ent.Value) error { - switch name { - case page.FieldOrder: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddOrder(v) - return nil +// AppendedCapabilities returns the list of values that were appended to the "capabilities" field in this mutation. +func (m *PhaseMutation) AppendedCapabilities() ([]string, bool) { + if len(m.appendcapabilities) == 0 { + return nil, false } - return fmt.Errorf("unknown Page numeric field %s", name) + return m.appendcapabilities, true } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *PageMutation) ClearedFields() []string { - return nil +// ClearCapabilities clears the value of the "capabilities" field. +func (m *PhaseMutation) ClearCapabilities() { + m.capabilities = nil + m.appendcapabilities = nil + m.clearedFields[phase.FieldCapabilities] = struct{}{} } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *PageMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] +// CapabilitiesCleared returns if the "capabilities" field was cleared in this mutation. +func (m *PhaseMutation) CapabilitiesCleared() bool { + _, ok := m.clearedFields[phase.FieldCapabilities] return ok } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *PageMutation) ClearField(name string) error { - return fmt.Errorf("unknown Page nullable field %s", name) +// ResetCapabilities resets all changes to the "capabilities" field. +func (m *PhaseMutation) ResetCapabilities() { + m.capabilities = nil + m.appendcapabilities = nil + delete(m.clearedFields, phase.FieldCapabilities) } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *PageMutation) ResetField(name string) error { - switch name { - case page.FieldTitle: - m.ResetTitle() - return nil - case page.FieldContent: - m.ResetContent() - return nil - case page.FieldVisible: - m.ResetVisible() - return nil - case page.FieldOrder: - m.ResetOrder() - return nil - case page.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case page.FieldModifiedAt: - m.ResetModifiedAt() - return nil - } - return fmt.Errorf("unknown Page field %s", name) +// SetHackathonID sets the "hackathon" edge to the Hackathon entity by id. +func (m *PhaseMutation) SetHackathonID(id uuid.UUID) { + m.hackathon = &id } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *PageMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.hackathon != nil { - edges = append(edges, page.EdgeHackathon) - } - if m.phase != nil { - edges = append(edges, page.EdgePhase) - } - if m.creator != nil { - edges = append(edges, page.EdgeCreator) - } - if m.modifier != nil { - edges = append(edges, page.EdgeModifier) +// ClearHackathon clears the "hackathon" edge to the Hackathon entity. +func (m *PhaseMutation) ClearHackathon() { + m.clearedhackathon = true +} + +// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. +func (m *PhaseMutation) HackathonCleared() bool { + return m.clearedhackathon +} + +// HackathonID returns the "hackathon" edge ID in the mutation. +func (m *PhaseMutation) HackathonID() (id uuid.UUID, exists bool) { + if m.hackathon != nil { + return *m.hackathon, true } - return edges + return } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *PageMutation) AddedIDs(name string) []ent.Value { - switch name { - case page.EdgeHackathon: - if id := m.hackathon; id != nil { - return []ent.Value{*id} - } - case page.EdgePhase: - if id := m.phase; id != nil { - return []ent.Value{*id} - } - case page.EdgeCreator: - if id := m.creator; id != nil { - return []ent.Value{*id} - } - case page.EdgeModifier: - if id := m.modifier; id != nil { - return []ent.Value{*id} - } +// HackathonIDs returns the "hackathon" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// HackathonID instead. It exists only for internal usage by the builders. +func (m *PhaseMutation) HackathonIDs() (ids []uuid.UUID) { + if id := m.hackathon; id != nil { + ids = append(ids, *id) } - return nil + return } -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *PageMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - return edges +// ResetHackathon resets all changes to the "hackathon" edge. +func (m *PhaseMutation) ResetHackathon() { + m.hackathon = nil + m.clearedhackathon = false } -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *PageMutation) RemovedIDs(name string) []ent.Value { - return nil +// SetPageID sets the "page" edge to the Page entity by id. +func (m *PhaseMutation) SetPageID(id uuid.UUID) { + m.page = &id } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PageMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedhackathon { - edges = append(edges, page.EdgeHackathon) - } - if m.clearedphase { - edges = append(edges, page.EdgePhase) - } - if m.clearedcreator { - edges = append(edges, page.EdgeCreator) - } - if m.clearedmodifier { - edges = append(edges, page.EdgeModifier) - } - return edges +// ClearPage clears the "page" edge to the Page entity. +func (m *PhaseMutation) ClearPage() { + m.clearedpage = true } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *PageMutation) EdgeCleared(name string) bool { - switch name { - case page.EdgeHackathon: - return m.clearedhackathon - case page.EdgePhase: - return m.clearedphase - case page.EdgeCreator: - return m.clearedcreator - case page.EdgeModifier: - return m.clearedmodifier - } - return false +// PageCleared reports if the "page" edge to the Page entity was cleared. +func (m *PhaseMutation) PageCleared() bool { + return m.clearedpage } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *PageMutation) ClearEdge(name string) error { - switch name { - case page.EdgeHackathon: - m.ClearHackathon() - return nil - case page.EdgePhase: - m.ClearPhase() - return nil - case page.EdgeCreator: - m.ClearCreator() - return nil - case page.EdgeModifier: - m.ClearModifier() - return nil +// PageID returns the "page" edge ID in the mutation. +func (m *PhaseMutation) PageID() (id uuid.UUID, exists bool) { + if m.page != nil { + return *m.page, true } - return fmt.Errorf("unknown Page unique edge %s", name) + return } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *PageMutation) ResetEdge(name string) error { - switch name { - case page.EdgeHackathon: - m.ResetHackathon() - return nil - case page.EdgePhase: - m.ResetPhase() - return nil - case page.EdgeCreator: - m.ResetCreator() - return nil - case page.EdgeModifier: - m.ResetModifier() - return nil +// PageIDs returns the "page" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PageID instead. It exists only for internal usage by the builders. +func (m *PhaseMutation) PageIDs() (ids []uuid.UUID) { + if id := m.page; id != nil { + ids = append(ids, *id) } - return fmt.Errorf("unknown Page edge %s", name) + return } -// ParticipantMutation represents an operation that mutates the Participant nodes in the graph. -type ParticipantMutation struct { - config - op Op - typ string - is_waiting *bool - created_at *time.Time - clearedFields map[string]struct{} - hackathon *uuid.UUID - clearedhackathon bool - user *uuid.UUID - cleareduser bool - done bool - oldValue func(context.Context) (*Participant, error) - predicates []predicate.Participant +// ResetPage resets all changes to the "page" edge. +func (m *PhaseMutation) ResetPage() { + m.page = nil + m.clearedpage = false } -var _ ent.Mutation = (*ParticipantMutation)(nil) - -// participantOption allows management of the mutation configuration using functional options. -type participantOption func(*ParticipantMutation) - -// newParticipantMutation creates new mutation for the Participant entity. -func newParticipantMutation(c config, op Op, opts ...participantOption) *ParticipantMutation { - m := &ParticipantMutation{ - config: c, - op: op, - typ: TypeParticipant, - clearedFields: make(map[string]struct{}), +// AddCurrentOfIDs adds the "current_of" edge to the Hackathon entity by ids. +func (m *PhaseMutation) AddCurrentOfIDs(ids ...uuid.UUID) { + if m.current_of == nil { + m.current_of = make(map[uuid.UUID]struct{}) } - for _, opt := range opts { - opt(m) + for i := range ids { + m.current_of[ids[i]] = struct{}{} } - return m } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m ParticipantMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client +// ClearCurrentOf clears the "current_of" edge to the Hackathon entity. +func (m *PhaseMutation) ClearCurrentOf() { + m.clearedcurrent_of = true } -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m ParticipantMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil +// CurrentOfCleared reports if the "current_of" edge to the Hackathon entity was cleared. +func (m *PhaseMutation) CurrentOfCleared() bool { + return m.clearedcurrent_of } -// SetHackathonID sets the "hackathon_id" field. -func (m *ParticipantMutation) SetHackathonID(u uuid.UUID) { - m.hackathon = &u +// RemoveCurrentOfIDs removes the "current_of" edge to the Hackathon entity by IDs. +func (m *PhaseMutation) RemoveCurrentOfIDs(ids ...uuid.UUID) { + if m.removedcurrent_of == nil { + m.removedcurrent_of = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.current_of, ids[i]) + m.removedcurrent_of[ids[i]] = struct{}{} + } } -// HackathonID returns the value of the "hackathon_id" field in the mutation. -func (m *ParticipantMutation) HackathonID() (r uuid.UUID, exists bool) { - v := m.hackathon - if v == nil { - return +// RemovedCurrentOf returns the removed IDs of the "current_of" edge to the Hackathon entity. +func (m *PhaseMutation) RemovedCurrentOfIDs() (ids []uuid.UUID) { + for id := range m.removedcurrent_of { + ids = append(ids, id) } - return *v, true + return } -// ResetHackathonID resets all changes to the "hackathon_id" field. -func (m *ParticipantMutation) ResetHackathonID() { - m.hackathon = nil +// CurrentOfIDs returns the "current_of" edge IDs in the mutation. +func (m *PhaseMutation) CurrentOfIDs() (ids []uuid.UUID) { + for id := range m.current_of { + ids = append(ids, id) + } + return } -// SetUserID sets the "user_id" field. -func (m *ParticipantMutation) SetUserID(u uuid.UUID) { - m.user = &u +// ResetCurrentOf resets all changes to the "current_of" edge. +func (m *PhaseMutation) ResetCurrentOf() { + m.current_of = nil + m.clearedcurrent_of = false + m.removedcurrent_of = nil } -// UserID returns the value of the "user_id" field in the mutation. -func (m *ParticipantMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user - if v == nil { - return - } - return *v, true +// SetCreatorID sets the "creator" edge to the User entity by id. +func (m *PhaseMutation) SetCreatorID(id uuid.UUID) { + m.creator = &id } -// ResetUserID resets all changes to the "user_id" field. -func (m *ParticipantMutation) ResetUserID() { - m.user = nil +// ClearCreator clears the "creator" edge to the User entity. +func (m *PhaseMutation) ClearCreator() { + m.clearedcreator = true } -// SetIsWaiting sets the "is_waiting" field. -func (m *ParticipantMutation) SetIsWaiting(b bool) { - m.is_waiting = &b +// CreatorCleared reports if the "creator" edge to the User entity was cleared. +func (m *PhaseMutation) CreatorCleared() bool { + return m.clearedcreator } -// IsWaiting returns the value of the "is_waiting" field in the mutation. -func (m *ParticipantMutation) IsWaiting() (r bool, exists bool) { - v := m.is_waiting - if v == nil { - return +// CreatorID returns the "creator" edge ID in the mutation. +func (m *PhaseMutation) CreatorID() (id uuid.UUID, exists bool) { + if m.creator != nil { + return *m.creator, true } - return *v, true + return } -// ResetIsWaiting resets all changes to the "is_waiting" field. -func (m *ParticipantMutation) ResetIsWaiting() { - m.is_waiting = nil +// CreatorIDs returns the "creator" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// CreatorID instead. It exists only for internal usage by the builders. +func (m *PhaseMutation) CreatorIDs() (ids []uuid.UUID) { + if id := m.creator; id != nil { + ids = append(ids, *id) + } + return } -// SetCreatedAt sets the "created_at" field. -func (m *ParticipantMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// ResetCreator resets all changes to the "creator" edge. +func (m *PhaseMutation) ResetCreator() { + m.creator = nil + m.clearedcreator = false } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ParticipantMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true +// SetModifierID sets the "modifier" edge to the User entity by id. +func (m *PhaseMutation) SetModifierID(id uuid.UUID) { + m.modifier = &id } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *ParticipantMutation) ResetCreatedAt() { - m.created_at = nil +// ClearModifier clears the "modifier" edge to the User entity. +func (m *PhaseMutation) ClearModifier() { + m.clearedmodifier = true } -// ClearHackathon clears the "hackathon" edge to the Hackathon entity. -func (m *ParticipantMutation) ClearHackathon() { - m.clearedhackathon = true - m.clearedFields[participant.FieldHackathonID] = struct{}{} +// ModifierCleared reports if the "modifier" edge to the User entity was cleared. +func (m *PhaseMutation) ModifierCleared() bool { + return m.clearedmodifier } -// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. -func (m *ParticipantMutation) HackathonCleared() bool { - return m.clearedhackathon +// ModifierID returns the "modifier" edge ID in the mutation. +func (m *PhaseMutation) ModifierID() (id uuid.UUID, exists bool) { + if m.modifier != nil { + return *m.modifier, true + } + return } -// HackathonIDs returns the "hackathon" edge IDs in the mutation. +// ModifierIDs returns the "modifier" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// HackathonID instead. It exists only for internal usage by the builders. -func (m *ParticipantMutation) HackathonIDs() (ids []uuid.UUID) { - if id := m.hackathon; id != nil { +// ModifierID instead. It exists only for internal usage by the builders. +func (m *PhaseMutation) ModifierIDs() (ids []uuid.UUID) { + if id := m.modifier; id != nil { ids = append(ids, *id) } return } -// ResetHackathon resets all changes to the "hackathon" edge. -func (m *ParticipantMutation) ResetHackathon() { - m.hackathon = nil - m.clearedhackathon = false +// ResetModifier resets all changes to the "modifier" edge. +func (m *PhaseMutation) ResetModifier() { + m.modifier = nil + m.clearedmodifier = false } -// ClearUser clears the "user" edge to the User entity. -func (m *ParticipantMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[participant.FieldUserID] = struct{}{} +// SetCurrentStateID sets the "current_state" edge to the HackathonState entity by id. +func (m *PhaseMutation) SetCurrentStateID(id uuid.UUID) { + m.current_state = &id } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *ParticipantMutation) UserCleared() bool { - return m.cleareduser +// ClearCurrentState clears the "current_state" edge to the HackathonState entity. +func (m *PhaseMutation) ClearCurrentState() { + m.clearedcurrent_state = true } -// UserIDs returns the "user" edge IDs in the mutation. +// CurrentStateCleared reports if the "current_state" edge to the HackathonState entity was cleared. +func (m *PhaseMutation) CurrentStateCleared() bool { + return m.clearedcurrent_state +} + +// CurrentStateID returns the "current_state" edge ID in the mutation. +func (m *PhaseMutation) CurrentStateID() (id uuid.UUID, exists bool) { + if m.current_state != nil { + return *m.current_state, true + } + return +} + +// CurrentStateIDs returns the "current_state" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *ParticipantMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { +// CurrentStateID instead. It exists only for internal usage by the builders. +func (m *PhaseMutation) CurrentStateIDs() (ids []uuid.UUID) { + if id := m.current_state; id != nil { ids = append(ids, *id) } return } -// ResetUser resets all changes to the "user" edge. -func (m *ParticipantMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// ResetCurrentState resets all changes to the "current_state" edge. +func (m *PhaseMutation) ResetCurrentState() { + m.current_state = nil + m.clearedcurrent_state = false } -// Where appends a list predicates to the ParticipantMutation builder. -func (m *ParticipantMutation) Where(ps ...predicate.Participant) { +// Where appends a list predicates to the PhaseMutation builder. +func (m *PhaseMutation) Where(ps ...predicate.Phase) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ParticipantMutation builder. Using this method, +// WhereP appends storage-level predicates to the PhaseMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ParticipantMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Participant, len(ps)) +func (m *PhaseMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Phase, len(ps)) for i := range ps { p[i] = ps[i] } @@ -3652,36 +5411,45 @@ func (m *ParticipantMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ParticipantMutation) Op() Op { +func (m *PhaseMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ParticipantMutation) SetOp(op Op) { +func (m *PhaseMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Participant). -func (m *ParticipantMutation) Type() string { +// Type returns the node type of this mutation (Phase). +func (m *PhaseMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ParticipantMutation) Fields() []string { - fields := make([]string, 0, 4) - if m.hackathon != nil { - fields = append(fields, participant.FieldHackathonID) +func (m *PhaseMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.starts_at != nil { + fields = append(fields, phase.FieldStartsAt) } - if m.user != nil { - fields = append(fields, participant.FieldUserID) + if m.ends_at != nil { + fields = append(fields, phase.FieldEndsAt) } - if m.is_waiting != nil { - fields = append(fields, participant.FieldIsWaiting) + if m.name != nil { + fields = append(fields, phase.FieldName) + } + if m.description != nil { + fields = append(fields, phase.FieldDescription) } if m.created_at != nil { - fields = append(fields, participant.FieldCreatedAt) + fields = append(fields, phase.FieldCreatedAt) + } + if m.modified_at != nil { + fields = append(fields, phase.FieldModifiedAt) + } + if m.capabilities != nil { + fields = append(fields, phase.FieldCapabilities) } return fields } @@ -3689,16 +5457,22 @@ func (m *ParticipantMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ParticipantMutation) Field(name string) (ent.Value, bool) { +func (m *PhaseMutation) Field(name string) (ent.Value, bool) { switch name { - case participant.FieldHackathonID: - return m.HackathonID() - case participant.FieldUserID: - return m.UserID() - case participant.FieldIsWaiting: - return m.IsWaiting() - case participant.FieldCreatedAt: + case phase.FieldStartsAt: + return m.StartsAt() + case phase.FieldEndsAt: + return m.EndsAt() + case phase.FieldName: + return m.Name() + case phase.FieldDescription: + return m.Description() + case phase.FieldCreatedAt: return m.CreatedAt() + case phase.FieldModifiedAt: + return m.ModifiedAt() + case phase.FieldCapabilities: + return m.Capabilities() } return nil, false } @@ -3706,130 +5480,233 @@ func (m *ParticipantMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ParticipantMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - return nil, errors.New("edge schema Participant does not support getting old values") +func (m *PhaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case phase.FieldStartsAt: + return m.OldStartsAt(ctx) + case phase.FieldEndsAt: + return m.OldEndsAt(ctx) + case phase.FieldName: + return m.OldName(ctx) + case phase.FieldDescription: + return m.OldDescription(ctx) + case phase.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case phase.FieldModifiedAt: + return m.OldModifiedAt(ctx) + case phase.FieldCapabilities: + return m.OldCapabilities(ctx) + } + return nil, fmt.Errorf("unknown Phase field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ParticipantMutation) SetField(name string, value ent.Value) error { +func (m *PhaseMutation) SetField(name string, value ent.Value) error { switch name { - case participant.FieldHackathonID: - v, ok := value.(uuid.UUID) + case phase.FieldStartsAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetHackathonID(v) + m.SetStartsAt(v) return nil - case participant.FieldUserID: - v, ok := value.(uuid.UUID) + case phase.FieldEndsAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetEndsAt(v) return nil - case participant.FieldIsWaiting: - v, ok := value.(bool) + case phase.FieldName: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIsWaiting(v) + m.SetName(v) return nil - case participant.FieldCreatedAt: + case phase.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case phase.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil + case phase.FieldModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModifiedAt(v) + return nil + case phase.FieldCapabilities: + v, ok := value.([]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCapabilities(v) + return nil } - return fmt.Errorf("unknown Participant field %s", name) + return fmt.Errorf("unknown Phase field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ParticipantMutation) AddedFields() []string { +func (m *PhaseMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ParticipantMutation) AddedField(name string) (ent.Value, bool) { +func (m *PhaseMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ParticipantMutation) AddField(name string, value ent.Value) error { +func (m *PhaseMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Participant numeric field %s", name) + return fmt.Errorf("unknown Phase numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ParticipantMutation) ClearedFields() []string { - return nil +func (m *PhaseMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(phase.FieldStartsAt) { + fields = append(fields, phase.FieldStartsAt) + } + if m.FieldCleared(phase.FieldEndsAt) { + fields = append(fields, phase.FieldEndsAt) + } + if m.FieldCleared(phase.FieldDescription) { + fields = append(fields, phase.FieldDescription) + } + if m.FieldCleared(phase.FieldCapabilities) { + fields = append(fields, phase.FieldCapabilities) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ParticipantMutation) FieldCleared(name string) bool { +func (m *PhaseMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ParticipantMutation) ClearField(name string) error { - return fmt.Errorf("unknown Participant nullable field %s", name) +func (m *PhaseMutation) ClearField(name string) error { + switch name { + case phase.FieldStartsAt: + m.ClearStartsAt() + return nil + case phase.FieldEndsAt: + m.ClearEndsAt() + return nil + case phase.FieldDescription: + m.ClearDescription() + return nil + case phase.FieldCapabilities: + m.ClearCapabilities() + return nil + } + return fmt.Errorf("unknown Phase nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ParticipantMutation) ResetField(name string) error { +func (m *PhaseMutation) ResetField(name string) error { switch name { - case participant.FieldHackathonID: - m.ResetHackathonID() + case phase.FieldStartsAt: + m.ResetStartsAt() return nil - case participant.FieldUserID: - m.ResetUserID() + case phase.FieldEndsAt: + m.ResetEndsAt() return nil - case participant.FieldIsWaiting: - m.ResetIsWaiting() + case phase.FieldName: + m.ResetName() return nil - case participant.FieldCreatedAt: + case phase.FieldDescription: + m.ResetDescription() + return nil + case phase.FieldCreatedAt: m.ResetCreatedAt() return nil + case phase.FieldModifiedAt: + m.ResetModifiedAt() + return nil + case phase.FieldCapabilities: + m.ResetCapabilities() + return nil } - return fmt.Errorf("unknown Participant field %s", name) + return fmt.Errorf("unknown Phase field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ParticipantMutation) AddedEdges() []string { - edges := make([]string, 0, 2) +func (m *PhaseMutation) AddedEdges() []string { + edges := make([]string, 0, 6) if m.hackathon != nil { - edges = append(edges, participant.EdgeHackathon) + edges = append(edges, phase.EdgeHackathon) } - if m.user != nil { - edges = append(edges, participant.EdgeUser) + if m.page != nil { + edges = append(edges, phase.EdgePage) + } + if m.current_of != nil { + edges = append(edges, phase.EdgeCurrentOf) + } + if m.creator != nil { + edges = append(edges, phase.EdgeCreator) + } + if m.modifier != nil { + edges = append(edges, phase.EdgeModifier) + } + if m.current_state != nil { + edges = append(edges, phase.EdgeCurrentState) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ParticipantMutation) AddedIDs(name string) []ent.Value { +func (m *PhaseMutation) AddedIDs(name string) []ent.Value { switch name { - case participant.EdgeHackathon: + case phase.EdgeHackathon: if id := m.hackathon; id != nil { return []ent.Value{*id} } - case participant.EdgeUser: - if id := m.user; id != nil { + case phase.EdgePage: + if id := m.page; id != nil { + return []ent.Value{*id} + } + case phase.EdgeCurrentOf: + ids := make([]ent.Value, 0, len(m.current_of)) + for id := range m.current_of { + ids = append(ids, id) + } + return ids + case phase.EdgeCreator: + if id := m.creator; id != nil { + return []ent.Value{*id} + } + case phase.EdgeModifier: + if id := m.modifier; id != nil { + return []ent.Value{*id} + } + case phase.EdgeCurrentState: + if id := m.current_state; id != nil { return []ent.Value{*id} } } @@ -3837,113 +5714,167 @@ func (m *ParticipantMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ParticipantMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *PhaseMutation) RemovedEdges() []string { + edges := make([]string, 0, 6) + if m.removedcurrent_of != nil { + edges = append(edges, phase.EdgeCurrentOf) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ParticipantMutation) RemovedIDs(name string) []ent.Value { +func (m *PhaseMutation) RemovedIDs(name string) []ent.Value { + switch name { + case phase.EdgeCurrentOf: + ids := make([]ent.Value, 0, len(m.removedcurrent_of)) + for id := range m.removedcurrent_of { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ParticipantMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) +func (m *PhaseMutation) ClearedEdges() []string { + edges := make([]string, 0, 6) if m.clearedhackathon { - edges = append(edges, participant.EdgeHackathon) + edges = append(edges, phase.EdgeHackathon) } - if m.cleareduser { - edges = append(edges, participant.EdgeUser) + if m.clearedpage { + edges = append(edges, phase.EdgePage) + } + if m.clearedcurrent_of { + edges = append(edges, phase.EdgeCurrentOf) + } + if m.clearedcreator { + edges = append(edges, phase.EdgeCreator) + } + if m.clearedmodifier { + edges = append(edges, phase.EdgeModifier) + } + if m.clearedcurrent_state { + edges = append(edges, phase.EdgeCurrentState) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ParticipantMutation) EdgeCleared(name string) bool { +func (m *PhaseMutation) EdgeCleared(name string) bool { switch name { - case participant.EdgeHackathon: + case phase.EdgeHackathon: return m.clearedhackathon - case participant.EdgeUser: - return m.cleareduser + case phase.EdgePage: + return m.clearedpage + case phase.EdgeCurrentOf: + return m.clearedcurrent_of + case phase.EdgeCreator: + return m.clearedcreator + case phase.EdgeModifier: + return m.clearedmodifier + case phase.EdgeCurrentState: + return m.clearedcurrent_state } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ParticipantMutation) ClearEdge(name string) error { +func (m *PhaseMutation) ClearEdge(name string) error { switch name { - case participant.EdgeHackathon: + case phase.EdgeHackathon: m.ClearHackathon() return nil - case participant.EdgeUser: - m.ClearUser() + case phase.EdgePage: + m.ClearPage() + return nil + case phase.EdgeCreator: + m.ClearCreator() + return nil + case phase.EdgeModifier: + m.ClearModifier() + return nil + case phase.EdgeCurrentState: + m.ClearCurrentState() return nil } - return fmt.Errorf("unknown Participant unique edge %s", name) + return fmt.Errorf("unknown Phase unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ParticipantMutation) ResetEdge(name string) error { +func (m *PhaseMutation) ResetEdge(name string) error { switch name { - case participant.EdgeHackathon: + case phase.EdgeHackathon: m.ResetHackathon() return nil - case participant.EdgeUser: - m.ResetUser() + case phase.EdgePage: + m.ResetPage() + return nil + case phase.EdgeCurrentOf: + m.ResetCurrentOf() + return nil + case phase.EdgeCreator: + m.ResetCreator() + return nil + case phase.EdgeModifier: + m.ResetModifier() + return nil + case phase.EdgeCurrentState: + m.ResetCurrentState() return nil } - return fmt.Errorf("unknown Participant edge %s", name) + return fmt.Errorf("unknown Phase edge %s", name) } -// PhaseMutation represents an operation that mutates the Phase nodes in the graph. -type PhaseMutation struct { +// ProjectMutation represents an operation that mutates the Project nodes in the graph. +type ProjectMutation struct { config - op Op - typ string - id *uuid.UUID - starts_at *time.Time - ends_at *time.Time - name *string - description *string - created_at *time.Time - modified_at *time.Time - capabilities *[]string - appendcapabilities []string - clearedFields map[string]struct{} - hackathon *uuid.UUID - clearedhackathon bool - page *uuid.UUID - clearedpage bool - current_of map[uuid.UUID]struct{} - removedcurrent_of map[uuid.UUID]struct{} - clearedcurrent_of bool - creator *uuid.UUID - clearedcreator bool - modifier *uuid.UUID - clearedmodifier bool - current_state *uuid.UUID - clearedcurrent_state bool - done bool - oldValue func(context.Context) (*Phase, error) - predicates []predicate.Phase + op Op + typ string + id *uuid.UUID + title *string + created_at *time.Time + modified_at *time.Time + status *project.Status + image *string + description *string + clearedFields map[string]struct{} + track *uuid.UUID + clearedtrack bool + hackathon *uuid.UUID + clearedhackathon bool + creator *uuid.UUID + clearedcreator bool + modifier *uuid.UUID + clearedmodifier bool + teams map[uuid.UUID]struct{} + removedteams map[uuid.UUID]struct{} + clearedteams bool + submissions map[uuid.UUID]struct{} + removedsubmissions map[uuid.UUID]struct{} + clearedsubmissions bool + preferred_by_users map[uuid.UUID]struct{} + removedpreferred_by_users map[uuid.UUID]struct{} + clearedpreferred_by_users bool + done bool + oldValue func(context.Context) (*Project, error) + predicates []predicate.Project } -var _ ent.Mutation = (*PhaseMutation)(nil) +var _ ent.Mutation = (*ProjectMutation)(nil) -// phaseOption allows management of the mutation configuration using functional options. -type phaseOption func(*PhaseMutation) +// projectOption allows management of the mutation configuration using functional options. +type projectOption func(*ProjectMutation) -// newPhaseMutation creates new mutation for the Phase entity. -func newPhaseMutation(c config, op Op, opts ...phaseOption) *PhaseMutation { - m := &PhaseMutation{ +// newProjectMutation creates new mutation for the Project entity. +func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation { + m := &ProjectMutation{ config: c, op: op, - typ: TypePhase, + typ: TypeProject, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -3952,20 +5883,20 @@ func newPhaseMutation(c config, op Op, opts ...phaseOption) *PhaseMutation { return m } -// withPhaseID sets the ID field of the mutation. -func withPhaseID(id uuid.UUID) phaseOption { - return func(m *PhaseMutation) { +// withProjectID sets the ID field of the mutation. +func withProjectID(id uuid.UUID) projectOption { + return func(m *ProjectMutation) { var ( err error once sync.Once - value *Phase + value *Project ) - m.oldValue = func(ctx context.Context) (*Phase, error) { + m.oldValue = func(ctx context.Context) (*Project, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Phase.Get(ctx, id) + value, err = m.Client().Project.Get(ctx, id) } }) return value, err @@ -3974,10 +5905,10 @@ func withPhaseID(id uuid.UUID) phaseOption { } } -// withPhase sets the old Phase of the mutation. -func withPhase(node *Phase) phaseOption { - return func(m *PhaseMutation) { - m.oldValue = func(context.Context) (*Phase, error) { +// withProject sets the old Project of the mutation. +func withProject(node *Project) projectOption { + return func(m *ProjectMutation) { + m.oldValue = func(context.Context) (*Project, error) { return node, nil } m.id = &node.ID @@ -3986,7 +5917,7 @@ func withPhase(node *Phase) phaseOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m PhaseMutation) Client() *Client { +func (m ProjectMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -3994,7 +5925,7 @@ func (m PhaseMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m PhaseMutation) Tx() (*Tx, error) { +func (m ProjectMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -4004,14 +5935,14 @@ func (m PhaseMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Phase entities. -func (m *PhaseMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of Project entities. +func (m *ProjectMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *PhaseMutation) ID() (id uuid.UUID, exists bool) { +func (m *ProjectMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -4022,7 +5953,7 @@ func (m *PhaseMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *PhaseMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *ProjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -4031,202 +5962,55 @@ func (m *PhaseMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Phase.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Project.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetStartsAt sets the "starts_at" field. -func (m *PhaseMutation) SetStartsAt(t time.Time) { - m.starts_at = &t -} - -// StartsAt returns the value of the "starts_at" field in the mutation. -func (m *PhaseMutation) StartsAt() (r time.Time, exists bool) { - v := m.starts_at - if v == nil { - return - } - return *v, true -} - -// OldStartsAt returns the old "starts_at" field's value of the Phase entity. -// If the Phase object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhaseMutation) OldStartsAt(ctx context.Context) (v *time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStartsAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStartsAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStartsAt: %w", err) - } - return oldValue.StartsAt, nil -} - -// ClearStartsAt clears the value of the "starts_at" field. -func (m *PhaseMutation) ClearStartsAt() { - m.starts_at = nil - m.clearedFields[phase.FieldStartsAt] = struct{}{} -} - -// StartsAtCleared returns if the "starts_at" field was cleared in this mutation. -func (m *PhaseMutation) StartsAtCleared() bool { - _, ok := m.clearedFields[phase.FieldStartsAt] - return ok -} - -// ResetStartsAt resets all changes to the "starts_at" field. -func (m *PhaseMutation) ResetStartsAt() { - m.starts_at = nil - delete(m.clearedFields, phase.FieldStartsAt) -} - -// SetEndsAt sets the "ends_at" field. -func (m *PhaseMutation) SetEndsAt(t time.Time) { - m.ends_at = &t -} - -// EndsAt returns the value of the "ends_at" field in the mutation. -func (m *PhaseMutation) EndsAt() (r time.Time, exists bool) { - v := m.ends_at - if v == nil { - return - } - return *v, true -} - -// OldEndsAt returns the old "ends_at" field's value of the Phase entity. -// If the Phase object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhaseMutation) OldEndsAt(ctx context.Context) (v *time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEndsAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEndsAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEndsAt: %w", err) - } - return oldValue.EndsAt, nil -} - -// ClearEndsAt clears the value of the "ends_at" field. -func (m *PhaseMutation) ClearEndsAt() { - m.ends_at = nil - m.clearedFields[phase.FieldEndsAt] = struct{}{} -} - -// EndsAtCleared returns if the "ends_at" field was cleared in this mutation. -func (m *PhaseMutation) EndsAtCleared() bool { - _, ok := m.clearedFields[phase.FieldEndsAt] - return ok -} - -// ResetEndsAt resets all changes to the "ends_at" field. -func (m *PhaseMutation) ResetEndsAt() { - m.ends_at = nil - delete(m.clearedFields, phase.FieldEndsAt) -} - -// SetName sets the "name" field. -func (m *PhaseMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *PhaseMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Phase entity. -// If the Phase object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhaseMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *PhaseMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *PhaseMutation) SetDescription(s string) { - m.description = &s +// SetTitle sets the "title" field. +func (m *ProjectMutation) SetTitle(s string) { + m.title = &s } -// Description returns the value of the "description" field in the mutation. -func (m *PhaseMutation) Description() (r string, exists bool) { - v := m.description +// Title returns the value of the "title" field in the mutation. +func (m *ProjectMutation) Title() (r string, exists bool) { + v := m.title if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the Phase entity. -// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// OldTitle returns the old "title" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhaseMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *ProjectMutation) OldTitle(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldTitle is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldTitle requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldTitle: %w", err) } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *PhaseMutation) ClearDescription() { - m.description = nil - m.clearedFields[phase.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *PhaseMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[phase.FieldDescription] - return ok + return oldValue.Title, nil } -// ResetDescription resets all changes to the "description" field. -func (m *PhaseMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, phase.FieldDescription) +// ResetTitle resets all changes to the "title" field. +func (m *ProjectMutation) ResetTitle() { + m.title = nil } // SetCreatedAt sets the "created_at" field. -func (m *PhaseMutation) SetCreatedAt(t time.Time) { +func (m *ProjectMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *PhaseMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ProjectMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -4234,10 +6018,10 @@ func (m *PhaseMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Phase entity. -// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhaseMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -4252,17 +6036,17 @@ func (m *PhaseMutation) OldCreatedAt(ctx context.Context) (v time.Time, err erro } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *PhaseMutation) ResetCreatedAt() { +func (m *ProjectMutation) ResetCreatedAt() { m.created_at = nil } // SetModifiedAt sets the "modified_at" field. -func (m *PhaseMutation) SetModifiedAt(t time.Time) { +func (m *ProjectMutation) SetModifiedAt(t time.Time) { m.modified_at = &t } // ModifiedAt returns the value of the "modified_at" field in the mutation. -func (m *PhaseMutation) ModifiedAt() (r time.Time, exists bool) { +func (m *ProjectMutation) ModifiedAt() (r time.Time, exists bool) { v := m.modified_at if v == nil { return @@ -4270,10 +6054,10 @@ func (m *PhaseMutation) ModifiedAt() (r time.Time, exists bool) { return *v, true } -// OldModifiedAt returns the old "modified_at" field's value of the Phase entity. -// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// OldModifiedAt returns the old "modified_at" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhaseMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") } @@ -4288,224 +6072,226 @@ func (m *PhaseMutation) OldModifiedAt(ctx context.Context) (v time.Time, err err } // ResetModifiedAt resets all changes to the "modified_at" field. -func (m *PhaseMutation) ResetModifiedAt() { +func (m *ProjectMutation) ResetModifiedAt() { m.modified_at = nil } -// SetCapabilities sets the "capabilities" field. -func (m *PhaseMutation) SetCapabilities(s []string) { - m.capabilities = &s - m.appendcapabilities = nil +// SetStatus sets the "status" field. +func (m *ProjectMutation) SetStatus(pr project.Status) { + m.status = &pr } -// Capabilities returns the value of the "capabilities" field in the mutation. -func (m *PhaseMutation) Capabilities() (r []string, exists bool) { - v := m.capabilities +// Status returns the value of the "status" field in the mutation. +func (m *ProjectMutation) Status() (r project.Status, exists bool) { + v := m.status if v == nil { return } return *v, true } -// OldCapabilities returns the old "capabilities" field's value of the Phase entity. -// If the Phase object wasn't provided to the builder, the object is fetched from the database. +// OldStatus returns the old "status" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhaseMutation) OldCapabilities(ctx context.Context) (v []string, err error) { +func (m *ProjectMutation) OldStatus(ctx context.Context) (v project.Status, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCapabilities is only allowed on UpdateOne operations") + return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCapabilities requires an ID field in the mutation") + return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCapabilities: %w", err) + return v, fmt.Errorf("querying old value for OldStatus: %w", err) } - return oldValue.Capabilities, nil + return oldValue.Status, nil } -// AppendCapabilities adds s to the "capabilities" field. -func (m *PhaseMutation) AppendCapabilities(s []string) { - m.appendcapabilities = append(m.appendcapabilities, s...) +// ResetStatus resets all changes to the "status" field. +func (m *ProjectMutation) ResetStatus() { + m.status = nil } -// AppendedCapabilities returns the list of values that were appended to the "capabilities" field in this mutation. -func (m *PhaseMutation) AppendedCapabilities() ([]string, bool) { - if len(m.appendcapabilities) == 0 { - return nil, false - } - return m.appendcapabilities, true +// SetImage sets the "image" field. +func (m *ProjectMutation) SetImage(s string) { + m.image = &s } -// ClearCapabilities clears the value of the "capabilities" field. -func (m *PhaseMutation) ClearCapabilities() { - m.capabilities = nil - m.appendcapabilities = nil - m.clearedFields[phase.FieldCapabilities] = struct{}{} +// Image returns the value of the "image" field in the mutation. +func (m *ProjectMutation) Image() (r string, exists bool) { + v := m.image + if v == nil { + return + } + return *v, true } -// CapabilitiesCleared returns if the "capabilities" field was cleared in this mutation. -func (m *PhaseMutation) CapabilitiesCleared() bool { - _, ok := m.clearedFields[phase.FieldCapabilities] - return ok +// OldImage returns the old "image" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldImage(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImage: %w", err) + } + return oldValue.Image, nil } -// ResetCapabilities resets all changes to the "capabilities" field. -func (m *PhaseMutation) ResetCapabilities() { - m.capabilities = nil - m.appendcapabilities = nil - delete(m.clearedFields, phase.FieldCapabilities) +// ClearImage clears the value of the "image" field. +func (m *ProjectMutation) ClearImage() { + m.image = nil + m.clearedFields[project.FieldImage] = struct{}{} } -// SetHackathonID sets the "hackathon" edge to the Hackathon entity by id. -func (m *PhaseMutation) SetHackathonID(id uuid.UUID) { - m.hackathon = &id +// ImageCleared returns if the "image" field was cleared in this mutation. +func (m *ProjectMutation) ImageCleared() bool { + _, ok := m.clearedFields[project.FieldImage] + return ok } -// ClearHackathon clears the "hackathon" edge to the Hackathon entity. -func (m *PhaseMutation) ClearHackathon() { - m.clearedhackathon = true +// ResetImage resets all changes to the "image" field. +func (m *ProjectMutation) ResetImage() { + m.image = nil + delete(m.clearedFields, project.FieldImage) } -// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. -func (m *PhaseMutation) HackathonCleared() bool { - return m.clearedhackathon +// SetDescription sets the "description" field. +func (m *ProjectMutation) SetDescription(s string) { + m.description = &s } -// HackathonID returns the "hackathon" edge ID in the mutation. -func (m *PhaseMutation) HackathonID() (id uuid.UUID, exists bool) { - if m.hackathon != nil { - return *m.hackathon, true +// Description returns the value of the "description" field in the mutation. +func (m *ProjectMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return } - return + return *v, true } -// HackathonIDs returns the "hackathon" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// HackathonID instead. It exists only for internal usage by the builders. -func (m *PhaseMutation) HackathonIDs() (ids []uuid.UUID) { - if id := m.hackathon; id != nil { - ids = append(ids, *id) +// OldDescription returns the old "description" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil } -// ResetHackathon resets all changes to the "hackathon" edge. -func (m *PhaseMutation) ResetHackathon() { - m.hackathon = nil - m.clearedhackathon = false +// ResetDescription resets all changes to the "description" field. +func (m *ProjectMutation) ResetDescription() { + m.description = nil } -// SetPageID sets the "page" edge to the Page entity by id. -func (m *PhaseMutation) SetPageID(id uuid.UUID) { - m.page = &id +// SetTrackID sets the "track" edge to the Track entity by id. +func (m *ProjectMutation) SetTrackID(id uuid.UUID) { + m.track = &id } -// ClearPage clears the "page" edge to the Page entity. -func (m *PhaseMutation) ClearPage() { - m.clearedpage = true +// ClearTrack clears the "track" edge to the Track entity. +func (m *ProjectMutation) ClearTrack() { + m.clearedtrack = true } -// PageCleared reports if the "page" edge to the Page entity was cleared. -func (m *PhaseMutation) PageCleared() bool { - return m.clearedpage +// TrackCleared reports if the "track" edge to the Track entity was cleared. +func (m *ProjectMutation) TrackCleared() bool { + return m.clearedtrack } -// PageID returns the "page" edge ID in the mutation. -func (m *PhaseMutation) PageID() (id uuid.UUID, exists bool) { - if m.page != nil { - return *m.page, true +// TrackID returns the "track" edge ID in the mutation. +func (m *ProjectMutation) TrackID() (id uuid.UUID, exists bool) { + if m.track != nil { + return *m.track, true } return } -// PageIDs returns the "page" edge IDs in the mutation. +// TrackIDs returns the "track" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PageID instead. It exists only for internal usage by the builders. -func (m *PhaseMutation) PageIDs() (ids []uuid.UUID) { - if id := m.page; id != nil { +// TrackID instead. It exists only for internal usage by the builders. +func (m *ProjectMutation) TrackIDs() (ids []uuid.UUID) { + if id := m.track; id != nil { ids = append(ids, *id) } return } -// ResetPage resets all changes to the "page" edge. -func (m *PhaseMutation) ResetPage() { - m.page = nil - m.clearedpage = false -} - -// AddCurrentOfIDs adds the "current_of" edge to the Hackathon entity by ids. -func (m *PhaseMutation) AddCurrentOfIDs(ids ...uuid.UUID) { - if m.current_of == nil { - m.current_of = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.current_of[ids[i]] = struct{}{} - } +// ResetTrack resets all changes to the "track" edge. +func (m *ProjectMutation) ResetTrack() { + m.track = nil + m.clearedtrack = false } -// ClearCurrentOf clears the "current_of" edge to the Hackathon entity. -func (m *PhaseMutation) ClearCurrentOf() { - m.clearedcurrent_of = true +// SetHackathonID sets the "hackathon" edge to the Hackathon entity by id. +func (m *ProjectMutation) SetHackathonID(id uuid.UUID) { + m.hackathon = &id } -// CurrentOfCleared reports if the "current_of" edge to the Hackathon entity was cleared. -func (m *PhaseMutation) CurrentOfCleared() bool { - return m.clearedcurrent_of +// ClearHackathon clears the "hackathon" edge to the Hackathon entity. +func (m *ProjectMutation) ClearHackathon() { + m.clearedhackathon = true } -// RemoveCurrentOfIDs removes the "current_of" edge to the Hackathon entity by IDs. -func (m *PhaseMutation) RemoveCurrentOfIDs(ids ...uuid.UUID) { - if m.removedcurrent_of == nil { - m.removedcurrent_of = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.current_of, ids[i]) - m.removedcurrent_of[ids[i]] = struct{}{} - } +// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. +func (m *ProjectMutation) HackathonCleared() bool { + return m.clearedhackathon } -// RemovedCurrentOf returns the removed IDs of the "current_of" edge to the Hackathon entity. -func (m *PhaseMutation) RemovedCurrentOfIDs() (ids []uuid.UUID) { - for id := range m.removedcurrent_of { - ids = append(ids, id) +// HackathonID returns the "hackathon" edge ID in the mutation. +func (m *ProjectMutation) HackathonID() (id uuid.UUID, exists bool) { + if m.hackathon != nil { + return *m.hackathon, true } return } -// CurrentOfIDs returns the "current_of" edge IDs in the mutation. -func (m *PhaseMutation) CurrentOfIDs() (ids []uuid.UUID) { - for id := range m.current_of { - ids = append(ids, id) +// HackathonIDs returns the "hackathon" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// HackathonID instead. It exists only for internal usage by the builders. +func (m *ProjectMutation) HackathonIDs() (ids []uuid.UUID) { + if id := m.hackathon; id != nil { + ids = append(ids, *id) } return } -// ResetCurrentOf resets all changes to the "current_of" edge. -func (m *PhaseMutation) ResetCurrentOf() { - m.current_of = nil - m.clearedcurrent_of = false - m.removedcurrent_of = nil +// ResetHackathon resets all changes to the "hackathon" edge. +func (m *ProjectMutation) ResetHackathon() { + m.hackathon = nil + m.clearedhackathon = false } // SetCreatorID sets the "creator" edge to the User entity by id. -func (m *PhaseMutation) SetCreatorID(id uuid.UUID) { +func (m *ProjectMutation) SetCreatorID(id uuid.UUID) { m.creator = &id } // ClearCreator clears the "creator" edge to the User entity. -func (m *PhaseMutation) ClearCreator() { +func (m *ProjectMutation) ClearCreator() { m.clearedcreator = true } // CreatorCleared reports if the "creator" edge to the User entity was cleared. -func (m *PhaseMutation) CreatorCleared() bool { +func (m *ProjectMutation) CreatorCleared() bool { return m.clearedcreator } // CreatorID returns the "creator" edge ID in the mutation. -func (m *PhaseMutation) CreatorID() (id uuid.UUID, exists bool) { +func (m *ProjectMutation) CreatorID() (id uuid.UUID, exists bool) { if m.creator != nil { return *m.creator, true } @@ -4515,7 +6301,7 @@ func (m *PhaseMutation) CreatorID() (id uuid.UUID, exists bool) { // CreatorIDs returns the "creator" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // CreatorID instead. It exists only for internal usage by the builders. -func (m *PhaseMutation) CreatorIDs() (ids []uuid.UUID) { +func (m *ProjectMutation) CreatorIDs() (ids []uuid.UUID) { if id := m.creator; id != nil { ids = append(ids, *id) } @@ -4523,28 +6309,28 @@ func (m *PhaseMutation) CreatorIDs() (ids []uuid.UUID) { } // ResetCreator resets all changes to the "creator" edge. -func (m *PhaseMutation) ResetCreator() { +func (m *ProjectMutation) ResetCreator() { m.creator = nil m.clearedcreator = false } // SetModifierID sets the "modifier" edge to the User entity by id. -func (m *PhaseMutation) SetModifierID(id uuid.UUID) { +func (m *ProjectMutation) SetModifierID(id uuid.UUID) { m.modifier = &id } // ClearModifier clears the "modifier" edge to the User entity. -func (m *PhaseMutation) ClearModifier() { +func (m *ProjectMutation) ClearModifier() { m.clearedmodifier = true } // ModifierCleared reports if the "modifier" edge to the User entity was cleared. -func (m *PhaseMutation) ModifierCleared() bool { +func (m *ProjectMutation) ModifierCleared() bool { return m.clearedmodifier } // ModifierID returns the "modifier" edge ID in the mutation. -func (m *PhaseMutation) ModifierID() (id uuid.UUID, exists bool) { +func (m *ProjectMutation) ModifierID() (id uuid.UUID, exists bool) { if m.modifier != nil { return *m.modifier, true } @@ -4554,7 +6340,7 @@ func (m *PhaseMutation) ModifierID() (id uuid.UUID, exists bool) { // ModifierIDs returns the "modifier" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // ModifierID instead. It exists only for internal usage by the builders. -func (m *PhaseMutation) ModifierIDs() (ids []uuid.UUID) { +func (m *ProjectMutation) ModifierIDs() (ids []uuid.UUID) { if id := m.modifier; id != nil { ids = append(ids, *id) } @@ -4562,59 +6348,182 @@ func (m *PhaseMutation) ModifierIDs() (ids []uuid.UUID) { } // ResetModifier resets all changes to the "modifier" edge. -func (m *PhaseMutation) ResetModifier() { +func (m *ProjectMutation) ResetModifier() { m.modifier = nil m.clearedmodifier = false } -// SetCurrentStateID sets the "current_state" edge to the HackathonState entity by id. -func (m *PhaseMutation) SetCurrentStateID(id uuid.UUID) { - m.current_state = &id +// AddTeamIDs adds the "teams" edge to the Team entity by ids. +func (m *ProjectMutation) AddTeamIDs(ids ...uuid.UUID) { + if m.teams == nil { + m.teams = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.teams[ids[i]] = struct{}{} + } } -// ClearCurrentState clears the "current_state" edge to the HackathonState entity. -func (m *PhaseMutation) ClearCurrentState() { - m.clearedcurrent_state = true +// ClearTeams clears the "teams" edge to the Team entity. +func (m *ProjectMutation) ClearTeams() { + m.clearedteams = true } -// CurrentStateCleared reports if the "current_state" edge to the HackathonState entity was cleared. -func (m *PhaseMutation) CurrentStateCleared() bool { - return m.clearedcurrent_state +// TeamsCleared reports if the "teams" edge to the Team entity was cleared. +func (m *ProjectMutation) TeamsCleared() bool { + return m.clearedteams } -// CurrentStateID returns the "current_state" edge ID in the mutation. -func (m *PhaseMutation) CurrentStateID() (id uuid.UUID, exists bool) { - if m.current_state != nil { - return *m.current_state, true +// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs. +func (m *ProjectMutation) RemoveTeamIDs(ids ...uuid.UUID) { + if m.removedteams == nil { + m.removedteams = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.teams, ids[i]) + m.removedteams[ids[i]] = struct{}{} + } +} + +// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity. +func (m *ProjectMutation) RemovedTeamsIDs() (ids []uuid.UUID) { + for id := range m.removedteams { + ids = append(ids, id) } return } -// CurrentStateIDs returns the "current_state" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// CurrentStateID instead. It exists only for internal usage by the builders. -func (m *PhaseMutation) CurrentStateIDs() (ids []uuid.UUID) { - if id := m.current_state; id != nil { - ids = append(ids, *id) +// TeamsIDs returns the "teams" edge IDs in the mutation. +func (m *ProjectMutation) TeamsIDs() (ids []uuid.UUID) { + for id := range m.teams { + ids = append(ids, id) } return } -// ResetCurrentState resets all changes to the "current_state" edge. -func (m *PhaseMutation) ResetCurrentState() { - m.current_state = nil - m.clearedcurrent_state = false +// ResetTeams resets all changes to the "teams" edge. +func (m *ProjectMutation) ResetTeams() { + m.teams = nil + m.clearedteams = false + m.removedteams = nil } -// Where appends a list predicates to the PhaseMutation builder. -func (m *PhaseMutation) Where(ps ...predicate.Phase) { +// AddSubmissionIDs adds the "submissions" edge to the Submission entity by ids. +func (m *ProjectMutation) AddSubmissionIDs(ids ...uuid.UUID) { + if m.submissions == nil { + m.submissions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.submissions[ids[i]] = struct{}{} + } +} + +// ClearSubmissions clears the "submissions" edge to the Submission entity. +func (m *ProjectMutation) ClearSubmissions() { + m.clearedsubmissions = true +} + +// SubmissionsCleared reports if the "submissions" edge to the Submission entity was cleared. +func (m *ProjectMutation) SubmissionsCleared() bool { + return m.clearedsubmissions +} + +// RemoveSubmissionIDs removes the "submissions" edge to the Submission entity by IDs. +func (m *ProjectMutation) RemoveSubmissionIDs(ids ...uuid.UUID) { + if m.removedsubmissions == nil { + m.removedsubmissions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.submissions, ids[i]) + m.removedsubmissions[ids[i]] = struct{}{} + } +} + +// RemovedSubmissions returns the removed IDs of the "submissions" edge to the Submission entity. +func (m *ProjectMutation) RemovedSubmissionsIDs() (ids []uuid.UUID) { + for id := range m.removedsubmissions { + ids = append(ids, id) + } + return +} + +// SubmissionsIDs returns the "submissions" edge IDs in the mutation. +func (m *ProjectMutation) SubmissionsIDs() (ids []uuid.UUID) { + for id := range m.submissions { + ids = append(ids, id) + } + return +} + +// ResetSubmissions resets all changes to the "submissions" edge. +func (m *ProjectMutation) ResetSubmissions() { + m.submissions = nil + m.clearedsubmissions = false + m.removedsubmissions = nil +} + +// AddPreferredByUserIDs adds the "preferred_by_users" edge to the User entity by ids. +func (m *ProjectMutation) AddPreferredByUserIDs(ids ...uuid.UUID) { + if m.preferred_by_users == nil { + m.preferred_by_users = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.preferred_by_users[ids[i]] = struct{}{} + } +} + +// ClearPreferredByUsers clears the "preferred_by_users" edge to the User entity. +func (m *ProjectMutation) ClearPreferredByUsers() { + m.clearedpreferred_by_users = true +} + +// PreferredByUsersCleared reports if the "preferred_by_users" edge to the User entity was cleared. +func (m *ProjectMutation) PreferredByUsersCleared() bool { + return m.clearedpreferred_by_users +} + +// RemovePreferredByUserIDs removes the "preferred_by_users" edge to the User entity by IDs. +func (m *ProjectMutation) RemovePreferredByUserIDs(ids ...uuid.UUID) { + if m.removedpreferred_by_users == nil { + m.removedpreferred_by_users = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.preferred_by_users, ids[i]) + m.removedpreferred_by_users[ids[i]] = struct{}{} + } +} + +// RemovedPreferredByUsers returns the removed IDs of the "preferred_by_users" edge to the User entity. +func (m *ProjectMutation) RemovedPreferredByUsersIDs() (ids []uuid.UUID) { + for id := range m.removedpreferred_by_users { + ids = append(ids, id) + } + return +} + +// PreferredByUsersIDs returns the "preferred_by_users" edge IDs in the mutation. +func (m *ProjectMutation) PreferredByUsersIDs() (ids []uuid.UUID) { + for id := range m.preferred_by_users { + ids = append(ids, id) + } + return +} + +// ResetPreferredByUsers resets all changes to the "preferred_by_users" edge. +func (m *ProjectMutation) ResetPreferredByUsers() { + m.preferred_by_users = nil + m.clearedpreferred_by_users = false + m.removedpreferred_by_users = nil +} + +// Where appends a list predicates to the ProjectMutation builder. +func (m *ProjectMutation) Where(ps ...predicate.Project) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the PhaseMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProjectMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PhaseMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Phase, len(ps)) +func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Project, len(ps)) for i := range ps { p[i] = ps[i] } @@ -4622,45 +6531,42 @@ func (m *PhaseMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *PhaseMutation) Op() Op { +func (m *ProjectMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *PhaseMutation) SetOp(op Op) { +func (m *ProjectMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Phase). -func (m *PhaseMutation) Type() string { +// Type returns the node type of this mutation (Project). +func (m *ProjectMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *PhaseMutation) Fields() []string { - fields := make([]string, 0, 7) - if m.starts_at != nil { - fields = append(fields, phase.FieldStartsAt) - } - if m.ends_at != nil { - fields = append(fields, phase.FieldEndsAt) - } - if m.name != nil { - fields = append(fields, phase.FieldName) - } - if m.description != nil { - fields = append(fields, phase.FieldDescription) +func (m *ProjectMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.title != nil { + fields = append(fields, project.FieldTitle) } if m.created_at != nil { - fields = append(fields, phase.FieldCreatedAt) + fields = append(fields, project.FieldCreatedAt) } if m.modified_at != nil { - fields = append(fields, phase.FieldModifiedAt) + fields = append(fields, project.FieldModifiedAt) } - if m.capabilities != nil { - fields = append(fields, phase.FieldCapabilities) + if m.status != nil { + fields = append(fields, project.FieldStatus) + } + if m.image != nil { + fields = append(fields, project.FieldImage) + } + if m.description != nil { + fields = append(fields, project.FieldDescription) } return fields } @@ -4668,22 +6574,20 @@ func (m *PhaseMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *PhaseMutation) Field(name string) (ent.Value, bool) { +func (m *ProjectMutation) Field(name string) (ent.Value, bool) { switch name { - case phase.FieldStartsAt: - return m.StartsAt() - case phase.FieldEndsAt: - return m.EndsAt() - case phase.FieldName: - return m.Name() - case phase.FieldDescription: - return m.Description() - case phase.FieldCreatedAt: + case project.FieldTitle: + return m.Title() + case project.FieldCreatedAt: return m.CreatedAt() - case phase.FieldModifiedAt: + case project.FieldModifiedAt: return m.ModifiedAt() - case phase.FieldCapabilities: - return m.Capabilities() + case project.FieldStatus: + return m.Status() + case project.FieldImage: + return m.Image() + case project.FieldDescription: + return m.Description() } return nil, false } @@ -4691,255 +6595,254 @@ func (m *PhaseMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *PhaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProjectMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case phase.FieldStartsAt: - return m.OldStartsAt(ctx) - case phase.FieldEndsAt: - return m.OldEndsAt(ctx) - case phase.FieldName: - return m.OldName(ctx) - case phase.FieldDescription: - return m.OldDescription(ctx) - case phase.FieldCreatedAt: + case project.FieldTitle: + return m.OldTitle(ctx) + case project.FieldCreatedAt: return m.OldCreatedAt(ctx) - case phase.FieldModifiedAt: + case project.FieldModifiedAt: return m.OldModifiedAt(ctx) - case phase.FieldCapabilities: - return m.OldCapabilities(ctx) + case project.FieldStatus: + return m.OldStatus(ctx) + case project.FieldImage: + return m.OldImage(ctx) + case project.FieldDescription: + return m.OldDescription(ctx) } - return nil, fmt.Errorf("unknown Phase field %s", name) + return nil, fmt.Errorf("unknown Project field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *PhaseMutation) SetField(name string, value ent.Value) error { +func (m *ProjectMutation) SetField(name string, value ent.Value) error { switch name { - case phase.FieldStartsAt: - v, ok := value.(time.Time) + case project.FieldTitle: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetStartsAt(v) + m.SetTitle(v) return nil - case phase.FieldEndsAt: + case project.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEndsAt(v) - return nil - case phase.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) + m.SetCreatedAt(v) return nil - case phase.FieldDescription: - v, ok := value.(string) + case project.FieldModifiedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) + m.SetModifiedAt(v) return nil - case phase.FieldCreatedAt: - v, ok := value.(time.Time) + case project.FieldStatus: + v, ok := value.(project.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetStatus(v) return nil - case phase.FieldModifiedAt: - v, ok := value.(time.Time) + case project.FieldImage: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModifiedAt(v) + m.SetImage(v) return nil - case phase.FieldCapabilities: - v, ok := value.([]string) + case project.FieldDescription: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCapabilities(v) + m.SetDescription(v) return nil } - return fmt.Errorf("unknown Phase field %s", name) + return fmt.Errorf("unknown Project field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *PhaseMutation) AddedFields() []string { +func (m *ProjectMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *PhaseMutation) AddedField(name string) (ent.Value, bool) { +func (m *ProjectMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *PhaseMutation) AddField(name string, value ent.Value) error { +func (m *ProjectMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Phase numeric field %s", name) + return fmt.Errorf("unknown Project numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *PhaseMutation) ClearedFields() []string { +func (m *ProjectMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(phase.FieldStartsAt) { - fields = append(fields, phase.FieldStartsAt) - } - if m.FieldCleared(phase.FieldEndsAt) { - fields = append(fields, phase.FieldEndsAt) - } - if m.FieldCleared(phase.FieldDescription) { - fields = append(fields, phase.FieldDescription) - } - if m.FieldCleared(phase.FieldCapabilities) { - fields = append(fields, phase.FieldCapabilities) + if m.FieldCleared(project.FieldImage) { + fields = append(fields, project.FieldImage) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *PhaseMutation) FieldCleared(name string) bool { +func (m *ProjectMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *PhaseMutation) ClearField(name string) error { +func (m *ProjectMutation) ClearField(name string) error { switch name { - case phase.FieldStartsAt: - m.ClearStartsAt() - return nil - case phase.FieldEndsAt: - m.ClearEndsAt() - return nil - case phase.FieldDescription: - m.ClearDescription() - return nil - case phase.FieldCapabilities: - m.ClearCapabilities() + case project.FieldImage: + m.ClearImage() return nil } - return fmt.Errorf("unknown Phase nullable field %s", name) + return fmt.Errorf("unknown Project nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *PhaseMutation) ResetField(name string) error { +func (m *ProjectMutation) ResetField(name string) error { switch name { - case phase.FieldStartsAt: - m.ResetStartsAt() - return nil - case phase.FieldEndsAt: - m.ResetEndsAt() - return nil - case phase.FieldName: - m.ResetName() - return nil - case phase.FieldDescription: - m.ResetDescription() + case project.FieldTitle: + m.ResetTitle() return nil - case phase.FieldCreatedAt: + case project.FieldCreatedAt: m.ResetCreatedAt() return nil - case phase.FieldModifiedAt: + case project.FieldModifiedAt: m.ResetModifiedAt() return nil - case phase.FieldCapabilities: - m.ResetCapabilities() + case project.FieldStatus: + m.ResetStatus() + return nil + case project.FieldImage: + m.ResetImage() + return nil + case project.FieldDescription: + m.ResetDescription() return nil } - return fmt.Errorf("unknown Phase field %s", name) + return fmt.Errorf("unknown Project field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *PhaseMutation) AddedEdges() []string { - edges := make([]string, 0, 6) - if m.hackathon != nil { - edges = append(edges, phase.EdgeHackathon) - } - if m.page != nil { - edges = append(edges, phase.EdgePage) +func (m *ProjectMutation) AddedEdges() []string { + edges := make([]string, 0, 7) + if m.track != nil { + edges = append(edges, project.EdgeTrack) } - if m.current_of != nil { - edges = append(edges, phase.EdgeCurrentOf) + if m.hackathon != nil { + edges = append(edges, project.EdgeHackathon) } if m.creator != nil { - edges = append(edges, phase.EdgeCreator) + edges = append(edges, project.EdgeCreator) } if m.modifier != nil { - edges = append(edges, phase.EdgeModifier) + edges = append(edges, project.EdgeModifier) } - if m.current_state != nil { - edges = append(edges, phase.EdgeCurrentState) + if m.teams != nil { + edges = append(edges, project.EdgeTeams) + } + if m.submissions != nil { + edges = append(edges, project.EdgeSubmissions) + } + if m.preferred_by_users != nil { + edges = append(edges, project.EdgePreferredByUsers) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *PhaseMutation) AddedIDs(name string) []ent.Value { +func (m *ProjectMutation) AddedIDs(name string) []ent.Value { switch name { - case phase.EdgeHackathon: - if id := m.hackathon; id != nil { + case project.EdgeTrack: + if id := m.track; id != nil { return []ent.Value{*id} } - case phase.EdgePage: - if id := m.page; id != nil { + case project.EdgeHackathon: + if id := m.hackathon; id != nil { return []ent.Value{*id} } - case phase.EdgeCurrentOf: - ids := make([]ent.Value, 0, len(m.current_of)) - for id := range m.current_of { - ids = append(ids, id) - } - return ids - case phase.EdgeCreator: + case project.EdgeCreator: if id := m.creator; id != nil { return []ent.Value{*id} } - case phase.EdgeModifier: + case project.EdgeModifier: if id := m.modifier; id != nil { return []ent.Value{*id} } - case phase.EdgeCurrentState: - if id := m.current_state; id != nil { - return []ent.Value{*id} + case project.EdgeTeams: + ids := make([]ent.Value, 0, len(m.teams)) + for id := range m.teams { + ids = append(ids, id) + } + return ids + case project.EdgeSubmissions: + ids := make([]ent.Value, 0, len(m.submissions)) + for id := range m.submissions { + ids = append(ids, id) + } + return ids + case project.EdgePreferredByUsers: + ids := make([]ent.Value, 0, len(m.preferred_by_users)) + for id := range m.preferred_by_users { + ids = append(ids, id) } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *PhaseMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) - if m.removedcurrent_of != nil { - edges = append(edges, phase.EdgeCurrentOf) +func (m *ProjectMutation) RemovedEdges() []string { + edges := make([]string, 0, 7) + if m.removedteams != nil { + edges = append(edges, project.EdgeTeams) + } + if m.removedsubmissions != nil { + edges = append(edges, project.EdgeSubmissions) + } + if m.removedpreferred_by_users != nil { + edges = append(edges, project.EdgePreferredByUsers) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *PhaseMutation) RemovedIDs(name string) []ent.Value { +func (m *ProjectMutation) RemovedIDs(name string) []ent.Value { switch name { - case phase.EdgeCurrentOf: - ids := make([]ent.Value, 0, len(m.removedcurrent_of)) - for id := range m.removedcurrent_of { + case project.EdgeTeams: + ids := make([]ent.Value, 0, len(m.removedteams)) + for id := range m.removedteams { + ids = append(ids, id) + } + return ids + case project.EdgeSubmissions: + ids := make([]ent.Value, 0, len(m.removedsubmissions)) + for id := range m.removedsubmissions { + ids = append(ids, id) + } + return ids + case project.EdgePreferredByUsers: + ids := make([]ent.Value, 0, len(m.removedpreferred_by_users)) + for id := range m.removedpreferred_by_users { ids = append(ids, id) } return ids @@ -4948,144 +6851,143 @@ func (m *PhaseMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PhaseMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) - if m.clearedhackathon { - edges = append(edges, phase.EdgeHackathon) - } - if m.clearedpage { - edges = append(edges, phase.EdgePage) +func (m *ProjectMutation) ClearedEdges() []string { + edges := make([]string, 0, 7) + if m.clearedtrack { + edges = append(edges, project.EdgeTrack) } - if m.clearedcurrent_of { - edges = append(edges, phase.EdgeCurrentOf) + if m.clearedhackathon { + edges = append(edges, project.EdgeHackathon) } if m.clearedcreator { - edges = append(edges, phase.EdgeCreator) + edges = append(edges, project.EdgeCreator) } if m.clearedmodifier { - edges = append(edges, phase.EdgeModifier) + edges = append(edges, project.EdgeModifier) } - if m.clearedcurrent_state { - edges = append(edges, phase.EdgeCurrentState) + if m.clearedteams { + edges = append(edges, project.EdgeTeams) + } + if m.clearedsubmissions { + edges = append(edges, project.EdgeSubmissions) + } + if m.clearedpreferred_by_users { + edges = append(edges, project.EdgePreferredByUsers) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *PhaseMutation) EdgeCleared(name string) bool { +func (m *ProjectMutation) EdgeCleared(name string) bool { switch name { - case phase.EdgeHackathon: + case project.EdgeTrack: + return m.clearedtrack + case project.EdgeHackathon: return m.clearedhackathon - case phase.EdgePage: - return m.clearedpage - case phase.EdgeCurrentOf: - return m.clearedcurrent_of - case phase.EdgeCreator: + case project.EdgeCreator: return m.clearedcreator - case phase.EdgeModifier: + case project.EdgeModifier: return m.clearedmodifier - case phase.EdgeCurrentState: - return m.clearedcurrent_state + case project.EdgeTeams: + return m.clearedteams + case project.EdgeSubmissions: + return m.clearedsubmissions + case project.EdgePreferredByUsers: + return m.clearedpreferred_by_users } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *PhaseMutation) ClearEdge(name string) error { +func (m *ProjectMutation) ClearEdge(name string) error { switch name { - case phase.EdgeHackathon: - m.ClearHackathon() + case project.EdgeTrack: + m.ClearTrack() return nil - case phase.EdgePage: - m.ClearPage() + case project.EdgeHackathon: + m.ClearHackathon() return nil - case phase.EdgeCreator: + case project.EdgeCreator: m.ClearCreator() return nil - case phase.EdgeModifier: + case project.EdgeModifier: m.ClearModifier() return nil - case phase.EdgeCurrentState: - m.ClearCurrentState() - return nil } - return fmt.Errorf("unknown Phase unique edge %s", name) + return fmt.Errorf("unknown Project unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *PhaseMutation) ResetEdge(name string) error { +func (m *ProjectMutation) ResetEdge(name string) error { switch name { - case phase.EdgeHackathon: - m.ResetHackathon() - return nil - case phase.EdgePage: - m.ResetPage() + case project.EdgeTrack: + m.ResetTrack() return nil - case phase.EdgeCurrentOf: - m.ResetCurrentOf() + case project.EdgeHackathon: + m.ResetHackathon() return nil - case phase.EdgeCreator: + case project.EdgeCreator: m.ResetCreator() return nil - case phase.EdgeModifier: + case project.EdgeModifier: m.ResetModifier() return nil - case phase.EdgeCurrentState: - m.ResetCurrentState() + case project.EdgeTeams: + m.ResetTeams() + return nil + case project.EdgeSubmissions: + m.ResetSubmissions() + return nil + case project.EdgePreferredByUsers: + m.ResetPreferredByUsers() return nil } - return fmt.Errorf("unknown Phase edge %s", name) + return fmt.Errorf("unknown Project edge %s", name) } -// ProjectMutation represents an operation that mutates the Project nodes in the graph. -type ProjectMutation struct { +// QuestionMutation represents an operation that mutates the Question nodes in the graph. +type QuestionMutation struct { config - op Op - typ string - id *uuid.UUID - title *string - created_at *time.Time - modified_at *time.Time - status *project.Status - image *string - description *string - clearedFields map[string]struct{} - track *uuid.UUID - clearedtrack bool - hackathon *uuid.UUID - clearedhackathon bool - creator *uuid.UUID - clearedcreator bool - modifier *uuid.UUID - clearedmodifier bool - teams map[uuid.UUID]struct{} - removedteams map[uuid.UUID]struct{} - clearedteams bool - submissions map[uuid.UUID]struct{} - removedsubmissions map[uuid.UUID]struct{} - clearedsubmissions bool - preferred_by_users map[uuid.UUID]struct{} - removedpreferred_by_users map[uuid.UUID]struct{} - clearedpreferred_by_users bool - done bool - oldValue func(context.Context) (*Project, error) - predicates []predicate.Project + op Op + typ string + id *uuid.UUID + key *string + label *string + _type *question.Type + mandatory *bool + _order *int + add_order *int + created_at *time.Time + modified_at *time.Time + clearedFields map[string]struct{} + hackathon *uuid.UUID + clearedhackathon bool + creator *uuid.UUID + clearedcreator bool + modifier *uuid.UUID + clearedmodifier bool + answers map[uuid.UUID]struct{} + removedanswers map[uuid.UUID]struct{} + clearedanswers bool + done bool + oldValue func(context.Context) (*Question, error) + predicates []predicate.Question } -var _ ent.Mutation = (*ProjectMutation)(nil) +var _ ent.Mutation = (*QuestionMutation)(nil) -// projectOption allows management of the mutation configuration using functional options. -type projectOption func(*ProjectMutation) +// questionOption allows management of the mutation configuration using functional options. +type questionOption func(*QuestionMutation) -// newProjectMutation creates new mutation for the Project entity. -func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation { - m := &ProjectMutation{ +// newQuestionMutation creates new mutation for the Question entity. +func newQuestionMutation(c config, op Op, opts ...questionOption) *QuestionMutation { + m := &QuestionMutation{ config: c, op: op, - typ: TypeProject, + typ: TypeQuestion, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -5094,20 +6996,20 @@ func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation return m } -// withProjectID sets the ID field of the mutation. -func withProjectID(id uuid.UUID) projectOption { - return func(m *ProjectMutation) { +// withQuestionID sets the ID field of the mutation. +func withQuestionID(id uuid.UUID) questionOption { + return func(m *QuestionMutation) { var ( err error once sync.Once - value *Project + value *Question ) - m.oldValue = func(ctx context.Context) (*Project, error) { + m.oldValue = func(ctx context.Context) (*Question, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Project.Get(ctx, id) + value, err = m.Client().Question.Get(ctx, id) } }) return value, err @@ -5116,10 +7018,10 @@ func withProjectID(id uuid.UUID) projectOption { } } -// withProject sets the old Project of the mutation. -func withProject(node *Project) projectOption { - return func(m *ProjectMutation) { - m.oldValue = func(context.Context) (*Project, error) { +// withQuestion sets the old Question of the mutation. +func withQuestion(node *Question) questionOption { + return func(m *QuestionMutation) { + m.oldValue = func(context.Context) (*Question, error) { return node, nil } m.id = &node.ID @@ -5128,7 +7030,7 @@ func withProject(node *Project) projectOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProjectMutation) Client() *Client { +func (m QuestionMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -5136,7 +7038,7 @@ func (m ProjectMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProjectMutation) Tx() (*Tx, error) { +func (m QuestionMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -5146,14 +7048,14 @@ func (m ProjectMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Project entities. -func (m *ProjectMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of Question entities. +func (m *QuestionMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProjectMutation) ID() (id uuid.UUID, exists bool) { +func (m *QuestionMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -5164,7 +7066,7 @@ func (m *ProjectMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *QuestionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -5173,568 +7075,488 @@ func (m *ProjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Project.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Question.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetTitle sets the "title" field. -func (m *ProjectMutation) SetTitle(s string) { - m.title = &s -} - -// Title returns the value of the "title" field in the mutation. -func (m *ProjectMutation) Title() (r string, exists bool) { - v := m.title - if v == nil { - return - } - return *v, true -} - -// OldTitle returns the old "title" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldTitle(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTitle is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTitle requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTitle: %w", err) - } - return oldValue.Title, nil -} - -// ResetTitle resets all changes to the "title" field. -func (m *ProjectMutation) ResetTitle() { - m.title = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *ProjectMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetHackathonID sets the "hackathon_id" field. +func (m *QuestionMutation) SetHackathonID(u uuid.UUID) { + m.hackathon = &u } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProjectMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// HackathonID returns the value of the "hackathon_id" field in the mutation. +func (m *QuestionMutation) HackathonID() (r uuid.UUID, exists bool) { + v := m.hackathon if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldHackathonID returns the old "hackathon_id" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *QuestionMutation) OldHackathonID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldHackathonID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldHackathonID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldHackathonID: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.HackathonID, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProjectMutation) ResetCreatedAt() { - m.created_at = nil +// ResetHackathonID resets all changes to the "hackathon_id" field. +func (m *QuestionMutation) ResetHackathonID() { + m.hackathon = nil } -// SetModifiedAt sets the "modified_at" field. -func (m *ProjectMutation) SetModifiedAt(t time.Time) { - m.modified_at = &t +// SetKey sets the "key" field. +func (m *QuestionMutation) SetKey(s string) { + m.key = &s } -// ModifiedAt returns the value of the "modified_at" field in the mutation. -func (m *ProjectMutation) ModifiedAt() (r time.Time, exists bool) { - v := m.modified_at +// Key returns the value of the "key" field in the mutation. +func (m *QuestionMutation) Key() (r string, exists bool) { + v := m.key if v == nil { return } return *v, true } -// OldModifiedAt returns the old "modified_at" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldKey returns the old "key" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { +func (m *QuestionMutation) OldKey(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") + return v, errors.New("OldKey is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModifiedAt requires an ID field in the mutation") + return v, errors.New("OldKey requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) + return v, fmt.Errorf("querying old value for OldKey: %w", err) } - return oldValue.ModifiedAt, nil + return oldValue.Key, nil } -// ResetModifiedAt resets all changes to the "modified_at" field. -func (m *ProjectMutation) ResetModifiedAt() { - m.modified_at = nil +// ResetKey resets all changes to the "key" field. +func (m *QuestionMutation) ResetKey() { + m.key = nil } -// SetStatus sets the "status" field. -func (m *ProjectMutation) SetStatus(pr project.Status) { - m.status = &pr +// SetLabel sets the "label" field. +func (m *QuestionMutation) SetLabel(s string) { + m.label = &s } -// Status returns the value of the "status" field in the mutation. -func (m *ProjectMutation) Status() (r project.Status, exists bool) { - v := m.status +// Label returns the value of the "label" field in the mutation. +func (m *QuestionMutation) Label() (r string, exists bool) { + v := m.label if v == nil { return } return *v, true } -// OldStatus returns the old "status" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldLabel returns the old "label" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldStatus(ctx context.Context) (v project.Status, err error) { +func (m *QuestionMutation) OldLabel(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") + return v, errors.New("OldLabel is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") + return v, errors.New("OldLabel requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) + return v, fmt.Errorf("querying old value for OldLabel: %w", err) } - return oldValue.Status, nil + return oldValue.Label, nil } -// ResetStatus resets all changes to the "status" field. -func (m *ProjectMutation) ResetStatus() { - m.status = nil +// ResetLabel resets all changes to the "label" field. +func (m *QuestionMutation) ResetLabel() { + m.label = nil } -// SetImage sets the "image" field. -func (m *ProjectMutation) SetImage(s string) { - m.image = &s +// SetType sets the "type" field. +func (m *QuestionMutation) SetType(q question.Type) { + m._type = &q } -// Image returns the value of the "image" field in the mutation. -func (m *ProjectMutation) Image() (r string, exists bool) { - v := m.image +// GetType returns the value of the "type" field in the mutation. +func (m *QuestionMutation) GetType() (r question.Type, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldImage returns the old "image" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldType returns the old "type" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldImage(ctx context.Context) (v string, err error) { +func (m *QuestionMutation) OldType(ctx context.Context) (v question.Type, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldImage is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldImage requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldImage: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.Image, nil -} - -// ClearImage clears the value of the "image" field. -func (m *ProjectMutation) ClearImage() { - m.image = nil - m.clearedFields[project.FieldImage] = struct{}{} -} - -// ImageCleared returns if the "image" field was cleared in this mutation. -func (m *ProjectMutation) ImageCleared() bool { - _, ok := m.clearedFields[project.FieldImage] - return ok + return oldValue.Type, nil } -// ResetImage resets all changes to the "image" field. -func (m *ProjectMutation) ResetImage() { - m.image = nil - delete(m.clearedFields, project.FieldImage) +// ResetType resets all changes to the "type" field. +func (m *QuestionMutation) ResetType() { + m._type = nil } -// SetDescription sets the "description" field. -func (m *ProjectMutation) SetDescription(s string) { - m.description = &s +// SetMandatory sets the "mandatory" field. +func (m *QuestionMutation) SetMandatory(b bool) { + m.mandatory = &b } -// Description returns the value of the "description" field in the mutation. -func (m *ProjectMutation) Description() (r string, exists bool) { - v := m.description +// Mandatory returns the value of the "mandatory" field in the mutation. +func (m *QuestionMutation) Mandatory() (r bool, exists bool) { + v := m.mandatory if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldMandatory returns the old "mandatory" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *QuestionMutation) OldMandatory(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldMandatory is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldMandatory requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldMandatory: %w", err) } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *ProjectMutation) ResetDescription() { - m.description = nil -} - -// SetTrackID sets the "track" edge to the Track entity by id. -func (m *ProjectMutation) SetTrackID(id uuid.UUID) { - m.track = &id + return oldValue.Mandatory, nil } -// ClearTrack clears the "track" edge to the Track entity. -func (m *ProjectMutation) ClearTrack() { - m.clearedtrack = true +// ResetMandatory resets all changes to the "mandatory" field. +func (m *QuestionMutation) ResetMandatory() { + m.mandatory = nil } -// TrackCleared reports if the "track" edge to the Track entity was cleared. -func (m *ProjectMutation) TrackCleared() bool { - return m.clearedtrack +// SetOrder sets the "order" field. +func (m *QuestionMutation) SetOrder(i int) { + m._order = &i + m.add_order = nil } -// TrackID returns the "track" edge ID in the mutation. -func (m *ProjectMutation) TrackID() (id uuid.UUID, exists bool) { - if m.track != nil { - return *m.track, true +// Order returns the value of the "order" field in the mutation. +func (m *QuestionMutation) Order() (r int, exists bool) { + v := m._order + if v == nil { + return } - return + return *v, true } -// TrackIDs returns the "track" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TrackID instead. It exists only for internal usage by the builders. -func (m *ProjectMutation) TrackIDs() (ids []uuid.UUID) { - if id := m.track; id != nil { - ids = append(ids, *id) +// OldOrder returns the old "order" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *QuestionMutation) OldOrder(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrder is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrder requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrder: %w", err) + } + return oldValue.Order, nil } -// ResetTrack resets all changes to the "track" edge. -func (m *ProjectMutation) ResetTrack() { - m.track = nil - m.clearedtrack = false +// AddOrder adds i to the "order" field. +func (m *QuestionMutation) AddOrder(i int) { + if m.add_order != nil { + *m.add_order += i + } else { + m.add_order = &i + } } -// SetHackathonID sets the "hackathon" edge to the Hackathon entity by id. -func (m *ProjectMutation) SetHackathonID(id uuid.UUID) { - m.hackathon = &id +// AddedOrder returns the value that was added to the "order" field in this mutation. +func (m *QuestionMutation) AddedOrder() (r int, exists bool) { + v := m.add_order + if v == nil { + return + } + return *v, true } -// ClearHackathon clears the "hackathon" edge to the Hackathon entity. -func (m *ProjectMutation) ClearHackathon() { - m.clearedhackathon = true +// ResetOrder resets all changes to the "order" field. +func (m *QuestionMutation) ResetOrder() { + m._order = nil + m.add_order = nil } -// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. -func (m *ProjectMutation) HackathonCleared() bool { - return m.clearedhackathon +// SetCreatedAt sets the "created_at" field. +func (m *QuestionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// HackathonID returns the "hackathon" edge ID in the mutation. -func (m *ProjectMutation) HackathonID() (id uuid.UUID, exists bool) { - if m.hackathon != nil { - return *m.hackathon, true +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *QuestionMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return } - return + return *v, true } -// HackathonIDs returns the "hackathon" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// HackathonID instead. It exists only for internal usage by the builders. -func (m *ProjectMutation) HackathonIDs() (ids []uuid.UUID) { - if id := m.hackathon; id != nil { - ids = append(ids, *id) +// OldCreatedAt returns the old "created_at" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *QuestionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } - return -} - -// ResetHackathon resets all changes to the "hackathon" edge. -func (m *ProjectMutation) ResetHackathon() { - m.hackathon = nil - m.clearedhackathon = false -} - -// SetCreatorID sets the "creator" edge to the User entity by id. -func (m *ProjectMutation) SetCreatorID(id uuid.UUID) { - m.creator = &id + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil } -// ClearCreator clears the "creator" edge to the User entity. -func (m *ProjectMutation) ClearCreator() { - m.clearedcreator = true +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *QuestionMutation) ResetCreatedAt() { + m.created_at = nil } -// CreatorCleared reports if the "creator" edge to the User entity was cleared. -func (m *ProjectMutation) CreatorCleared() bool { - return m.clearedcreator +// SetModifiedAt sets the "modified_at" field. +func (m *QuestionMutation) SetModifiedAt(t time.Time) { + m.modified_at = &t } -// CreatorID returns the "creator" edge ID in the mutation. -func (m *ProjectMutation) CreatorID() (id uuid.UUID, exists bool) { - if m.creator != nil { - return *m.creator, true +// ModifiedAt returns the value of the "modified_at" field in the mutation. +func (m *QuestionMutation) ModifiedAt() (r time.Time, exists bool) { + v := m.modified_at + if v == nil { + return } - return + return *v, true } -// CreatorIDs returns the "creator" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// CreatorID instead. It exists only for internal usage by the builders. -func (m *ProjectMutation) CreatorIDs() (ids []uuid.UUID) { - if id := m.creator; id != nil { - ids = append(ids, *id) +// OldModifiedAt returns the old "modified_at" field's value of the Question entity. +// If the Question object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *QuestionMutation) OldModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModifiedAt is only allowed on UpdateOne operations") } - return -} - -// ResetCreator resets all changes to the "creator" edge. -func (m *ProjectMutation) ResetCreator() { - m.creator = nil - m.clearedcreator = false -} - -// SetModifierID sets the "modifier" edge to the User entity by id. -func (m *ProjectMutation) SetModifierID(id uuid.UUID) { - m.modifier = &id + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModifiedAt: %w", err) + } + return oldValue.ModifiedAt, nil } -// ClearModifier clears the "modifier" edge to the User entity. -func (m *ProjectMutation) ClearModifier() { - m.clearedmodifier = true +// ResetModifiedAt resets all changes to the "modified_at" field. +func (m *QuestionMutation) ResetModifiedAt() { + m.modified_at = nil } -// ModifierCleared reports if the "modifier" edge to the User entity was cleared. -func (m *ProjectMutation) ModifierCleared() bool { - return m.clearedmodifier +// ClearHackathon clears the "hackathon" edge to the Hackathon entity. +func (m *QuestionMutation) ClearHackathon() { + m.clearedhackathon = true + m.clearedFields[question.FieldHackathonID] = struct{}{} } -// ModifierID returns the "modifier" edge ID in the mutation. -func (m *ProjectMutation) ModifierID() (id uuid.UUID, exists bool) { - if m.modifier != nil { - return *m.modifier, true - } - return +// HackathonCleared reports if the "hackathon" edge to the Hackathon entity was cleared. +func (m *QuestionMutation) HackathonCleared() bool { + return m.clearedhackathon } -// ModifierIDs returns the "modifier" edge IDs in the mutation. +// HackathonIDs returns the "hackathon" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ModifierID instead. It exists only for internal usage by the builders. -func (m *ProjectMutation) ModifierIDs() (ids []uuid.UUID) { - if id := m.modifier; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetModifier resets all changes to the "modifier" edge. -func (m *ProjectMutation) ResetModifier() { - m.modifier = nil - m.clearedmodifier = false -} - -// AddTeamIDs adds the "teams" edge to the Team entity by ids. -func (m *ProjectMutation) AddTeamIDs(ids ...uuid.UUID) { - if m.teams == nil { - m.teams = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.teams[ids[i]] = struct{}{} +// HackathonID instead. It exists only for internal usage by the builders. +func (m *QuestionMutation) HackathonIDs() (ids []uuid.UUID) { + if id := m.hackathon; id != nil { + ids = append(ids, *id) } + return } -// ClearTeams clears the "teams" edge to the Team entity. -func (m *ProjectMutation) ClearTeams() { - m.clearedteams = true +// ResetHackathon resets all changes to the "hackathon" edge. +func (m *QuestionMutation) ResetHackathon() { + m.hackathon = nil + m.clearedhackathon = false } -// TeamsCleared reports if the "teams" edge to the Team entity was cleared. -func (m *ProjectMutation) TeamsCleared() bool { - return m.clearedteams +// SetCreatorID sets the "creator" edge to the User entity by id. +func (m *QuestionMutation) SetCreatorID(id uuid.UUID) { + m.creator = &id } -// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs. -func (m *ProjectMutation) RemoveTeamIDs(ids ...uuid.UUID) { - if m.removedteams == nil { - m.removedteams = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.teams, ids[i]) - m.removedteams[ids[i]] = struct{}{} - } +// ClearCreator clears the "creator" edge to the User entity. +func (m *QuestionMutation) ClearCreator() { + m.clearedcreator = true } -// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity. -func (m *ProjectMutation) RemovedTeamsIDs() (ids []uuid.UUID) { - for id := range m.removedteams { - ids = append(ids, id) - } - return +// CreatorCleared reports if the "creator" edge to the User entity was cleared. +func (m *QuestionMutation) CreatorCleared() bool { + return m.clearedcreator } -// TeamsIDs returns the "teams" edge IDs in the mutation. -func (m *ProjectMutation) TeamsIDs() (ids []uuid.UUID) { - for id := range m.teams { - ids = append(ids, id) +// CreatorID returns the "creator" edge ID in the mutation. +func (m *QuestionMutation) CreatorID() (id uuid.UUID, exists bool) { + if m.creator != nil { + return *m.creator, true } return } -// ResetTeams resets all changes to the "teams" edge. -func (m *ProjectMutation) ResetTeams() { - m.teams = nil - m.clearedteams = false - m.removedteams = nil +// CreatorIDs returns the "creator" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// CreatorID instead. It exists only for internal usage by the builders. +func (m *QuestionMutation) CreatorIDs() (ids []uuid.UUID) { + if id := m.creator; id != nil { + ids = append(ids, *id) + } + return } -// AddSubmissionIDs adds the "submissions" edge to the Submission entity by ids. -func (m *ProjectMutation) AddSubmissionIDs(ids ...uuid.UUID) { - if m.submissions == nil { - m.submissions = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.submissions[ids[i]] = struct{}{} - } +// ResetCreator resets all changes to the "creator" edge. +func (m *QuestionMutation) ResetCreator() { + m.creator = nil + m.clearedcreator = false } -// ClearSubmissions clears the "submissions" edge to the Submission entity. -func (m *ProjectMutation) ClearSubmissions() { - m.clearedsubmissions = true +// SetModifierID sets the "modifier" edge to the User entity by id. +func (m *QuestionMutation) SetModifierID(id uuid.UUID) { + m.modifier = &id } -// SubmissionsCleared reports if the "submissions" edge to the Submission entity was cleared. -func (m *ProjectMutation) SubmissionsCleared() bool { - return m.clearedsubmissions +// ClearModifier clears the "modifier" edge to the User entity. +func (m *QuestionMutation) ClearModifier() { + m.clearedmodifier = true } -// RemoveSubmissionIDs removes the "submissions" edge to the Submission entity by IDs. -func (m *ProjectMutation) RemoveSubmissionIDs(ids ...uuid.UUID) { - if m.removedsubmissions == nil { - m.removedsubmissions = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.submissions, ids[i]) - m.removedsubmissions[ids[i]] = struct{}{} - } +// ModifierCleared reports if the "modifier" edge to the User entity was cleared. +func (m *QuestionMutation) ModifierCleared() bool { + return m.clearedmodifier } -// RemovedSubmissions returns the removed IDs of the "submissions" edge to the Submission entity. -func (m *ProjectMutation) RemovedSubmissionsIDs() (ids []uuid.UUID) { - for id := range m.removedsubmissions { - ids = append(ids, id) +// ModifierID returns the "modifier" edge ID in the mutation. +func (m *QuestionMutation) ModifierID() (id uuid.UUID, exists bool) { + if m.modifier != nil { + return *m.modifier, true } return } -// SubmissionsIDs returns the "submissions" edge IDs in the mutation. -func (m *ProjectMutation) SubmissionsIDs() (ids []uuid.UUID) { - for id := range m.submissions { - ids = append(ids, id) +// ModifierIDs returns the "modifier" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModifierID instead. It exists only for internal usage by the builders. +func (m *QuestionMutation) ModifierIDs() (ids []uuid.UUID) { + if id := m.modifier; id != nil { + ids = append(ids, *id) } return } -// ResetSubmissions resets all changes to the "submissions" edge. -func (m *ProjectMutation) ResetSubmissions() { - m.submissions = nil - m.clearedsubmissions = false - m.removedsubmissions = nil +// ResetModifier resets all changes to the "modifier" edge. +func (m *QuestionMutation) ResetModifier() { + m.modifier = nil + m.clearedmodifier = false } -// AddPreferredByUserIDs adds the "preferred_by_users" edge to the User entity by ids. -func (m *ProjectMutation) AddPreferredByUserIDs(ids ...uuid.UUID) { - if m.preferred_by_users == nil { - m.preferred_by_users = make(map[uuid.UUID]struct{}) +// AddAnswerIDs adds the "answers" edge to the Answer entity by ids. +func (m *QuestionMutation) AddAnswerIDs(ids ...uuid.UUID) { + if m.answers == nil { + m.answers = make(map[uuid.UUID]struct{}) } for i := range ids { - m.preferred_by_users[ids[i]] = struct{}{} + m.answers[ids[i]] = struct{}{} } } -// ClearPreferredByUsers clears the "preferred_by_users" edge to the User entity. -func (m *ProjectMutation) ClearPreferredByUsers() { - m.clearedpreferred_by_users = true +// ClearAnswers clears the "answers" edge to the Answer entity. +func (m *QuestionMutation) ClearAnswers() { + m.clearedanswers = true } -// PreferredByUsersCleared reports if the "preferred_by_users" edge to the User entity was cleared. -func (m *ProjectMutation) PreferredByUsersCleared() bool { - return m.clearedpreferred_by_users +// AnswersCleared reports if the "answers" edge to the Answer entity was cleared. +func (m *QuestionMutation) AnswersCleared() bool { + return m.clearedanswers } -// RemovePreferredByUserIDs removes the "preferred_by_users" edge to the User entity by IDs. -func (m *ProjectMutation) RemovePreferredByUserIDs(ids ...uuid.UUID) { - if m.removedpreferred_by_users == nil { - m.removedpreferred_by_users = make(map[uuid.UUID]struct{}) +// RemoveAnswerIDs removes the "answers" edge to the Answer entity by IDs. +func (m *QuestionMutation) RemoveAnswerIDs(ids ...uuid.UUID) { + if m.removedanswers == nil { + m.removedanswers = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.preferred_by_users, ids[i]) - m.removedpreferred_by_users[ids[i]] = struct{}{} + delete(m.answers, ids[i]) + m.removedanswers[ids[i]] = struct{}{} } } -// RemovedPreferredByUsers returns the removed IDs of the "preferred_by_users" edge to the User entity. -func (m *ProjectMutation) RemovedPreferredByUsersIDs() (ids []uuid.UUID) { - for id := range m.removedpreferred_by_users { +// RemovedAnswers returns the removed IDs of the "answers" edge to the Answer entity. +func (m *QuestionMutation) RemovedAnswersIDs() (ids []uuid.UUID) { + for id := range m.removedanswers { ids = append(ids, id) } return } -// PreferredByUsersIDs returns the "preferred_by_users" edge IDs in the mutation. -func (m *ProjectMutation) PreferredByUsersIDs() (ids []uuid.UUID) { - for id := range m.preferred_by_users { +// AnswersIDs returns the "answers" edge IDs in the mutation. +func (m *QuestionMutation) AnswersIDs() (ids []uuid.UUID) { + for id := range m.answers { ids = append(ids, id) } return } -// ResetPreferredByUsers resets all changes to the "preferred_by_users" edge. -func (m *ProjectMutation) ResetPreferredByUsers() { - m.preferred_by_users = nil - m.clearedpreferred_by_users = false - m.removedpreferred_by_users = nil +// ResetAnswers resets all changes to the "answers" edge. +func (m *QuestionMutation) ResetAnswers() { + m.answers = nil + m.clearedanswers = false + m.removedanswers = nil } -// Where appends a list predicates to the ProjectMutation builder. -func (m *ProjectMutation) Where(ps ...predicate.Project) { +// Where appends a list predicates to the QuestionMutation builder. +func (m *QuestionMutation) Where(ps ...predicate.Question) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProjectMutation builder. Using this method, +// WhereP appends storage-level predicates to the QuestionMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Project, len(ps)) +func (m *QuestionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Question, len(ps)) for i := range ps { p[i] = ps[i] } @@ -5742,42 +7564,48 @@ func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProjectMutation) Op() Op { +func (m *QuestionMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProjectMutation) SetOp(op Op) { +func (m *QuestionMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Project). -func (m *ProjectMutation) Type() string { +// Type returns the node type of this mutation (Question). +func (m *QuestionMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProjectMutation) Fields() []string { - fields := make([]string, 0, 6) - if m.title != nil { - fields = append(fields, project.FieldTitle) +func (m *QuestionMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.hackathon != nil { + fields = append(fields, question.FieldHackathonID) } - if m.created_at != nil { - fields = append(fields, project.FieldCreatedAt) + if m.key != nil { + fields = append(fields, question.FieldKey) } - if m.modified_at != nil { - fields = append(fields, project.FieldModifiedAt) + if m.label != nil { + fields = append(fields, question.FieldLabel) } - if m.status != nil { - fields = append(fields, project.FieldStatus) + if m._type != nil { + fields = append(fields, question.FieldType) } - if m.image != nil { - fields = append(fields, project.FieldImage) + if m.mandatory != nil { + fields = append(fields, question.FieldMandatory) } - if m.description != nil { - fields = append(fields, project.FieldDescription) + if m._order != nil { + fields = append(fields, question.FieldOrder) + } + if m.created_at != nil { + fields = append(fields, question.FieldCreatedAt) + } + if m.modified_at != nil { + fields = append(fields, question.FieldModifiedAt) } return fields } @@ -5785,20 +7613,24 @@ func (m *ProjectMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProjectMutation) Field(name string) (ent.Value, bool) { +func (m *QuestionMutation) Field(name string) (ent.Value, bool) { switch name { - case project.FieldTitle: - return m.Title() - case project.FieldCreatedAt: + case question.FieldHackathonID: + return m.HackathonID() + case question.FieldKey: + return m.Key() + case question.FieldLabel: + return m.Label() + case question.FieldType: + return m.GetType() + case question.FieldMandatory: + return m.Mandatory() + case question.FieldOrder: + return m.Order() + case question.FieldCreatedAt: return m.CreatedAt() - case project.FieldModifiedAt: + case question.FieldModifiedAt: return m.ModifiedAt() - case project.FieldStatus: - return m.Status() - case project.FieldImage: - return m.Image() - case project.FieldDescription: - return m.Description() } return nil, false } @@ -5806,213 +7638,218 @@ func (m *ProjectMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProjectMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case project.FieldTitle: - return m.OldTitle(ctx) - case project.FieldCreatedAt: +func (m *QuestionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case question.FieldHackathonID: + return m.OldHackathonID(ctx) + case question.FieldKey: + return m.OldKey(ctx) + case question.FieldLabel: + return m.OldLabel(ctx) + case question.FieldType: + return m.OldType(ctx) + case question.FieldMandatory: + return m.OldMandatory(ctx) + case question.FieldOrder: + return m.OldOrder(ctx) + case question.FieldCreatedAt: return m.OldCreatedAt(ctx) - case project.FieldModifiedAt: + case question.FieldModifiedAt: return m.OldModifiedAt(ctx) - case project.FieldStatus: - return m.OldStatus(ctx) - case project.FieldImage: - return m.OldImage(ctx) - case project.FieldDescription: - return m.OldDescription(ctx) } - return nil, fmt.Errorf("unknown Project field %s", name) + return nil, fmt.Errorf("unknown Question field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectMutation) SetField(name string, value ent.Value) error { +func (m *QuestionMutation) SetField(name string, value ent.Value) error { switch name { - case project.FieldTitle: + case question.FieldHackathonID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHackathonID(v) + return nil + case question.FieldKey: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTitle(v) + m.SetKey(v) return nil - case project.FieldCreatedAt: - v, ok := value.(time.Time) + case question.FieldLabel: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetLabel(v) return nil - case project.FieldModifiedAt: - v, ok := value.(time.Time) + case question.FieldType: + v, ok := value.(question.Type) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModifiedAt(v) + m.SetType(v) return nil - case project.FieldStatus: - v, ok := value.(project.Status) + case question.FieldMandatory: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetStatus(v) + m.SetMandatory(v) return nil - case project.FieldImage: - v, ok := value.(string) + case question.FieldOrder: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetImage(v) + m.SetOrder(v) return nil - case project.FieldDescription: - v, ok := value.(string) + case question.FieldCreatedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) + m.SetCreatedAt(v) + return nil + case question.FieldModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModifiedAt(v) return nil } - return fmt.Errorf("unknown Project field %s", name) + return fmt.Errorf("unknown Question field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProjectMutation) AddedFields() []string { - return nil +func (m *QuestionMutation) AddedFields() []string { + var fields []string + if m.add_order != nil { + fields = append(fields, question.FieldOrder) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProjectMutation) AddedField(name string) (ent.Value, bool) { +func (m *QuestionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case question.FieldOrder: + return m.AddedOrder() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectMutation) AddField(name string, value ent.Value) error { +func (m *QuestionMutation) AddField(name string, value ent.Value) error { switch name { + case question.FieldOrder: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddOrder(v) + return nil } - return fmt.Errorf("unknown Project numeric field %s", name) + return fmt.Errorf("unknown Question numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProjectMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(project.FieldImage) { - fields = append(fields, project.FieldImage) - } - return fields +func (m *QuestionMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProjectMutation) FieldCleared(name string) bool { +func (m *QuestionMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProjectMutation) ClearField(name string) error { - switch name { - case project.FieldImage: - m.ClearImage() - return nil - } - return fmt.Errorf("unknown Project nullable field %s", name) +func (m *QuestionMutation) ClearField(name string) error { + return fmt.Errorf("unknown Question nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProjectMutation) ResetField(name string) error { +func (m *QuestionMutation) ResetField(name string) error { switch name { - case project.FieldTitle: - m.ResetTitle() + case question.FieldHackathonID: + m.ResetHackathonID() return nil - case project.FieldCreatedAt: - m.ResetCreatedAt() + case question.FieldKey: + m.ResetKey() return nil - case project.FieldModifiedAt: - m.ResetModifiedAt() + case question.FieldLabel: + m.ResetLabel() return nil - case project.FieldStatus: - m.ResetStatus() + case question.FieldType: + m.ResetType() return nil - case project.FieldImage: - m.ResetImage() + case question.FieldMandatory: + m.ResetMandatory() return nil - case project.FieldDescription: - m.ResetDescription() + case question.FieldOrder: + m.ResetOrder() + return nil + case question.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case question.FieldModifiedAt: + m.ResetModifiedAt() return nil } - return fmt.Errorf("unknown Project field %s", name) + return fmt.Errorf("unknown Question field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProjectMutation) AddedEdges() []string { - edges := make([]string, 0, 7) - if m.track != nil { - edges = append(edges, project.EdgeTrack) - } +func (m *QuestionMutation) AddedEdges() []string { + edges := make([]string, 0, 4) if m.hackathon != nil { - edges = append(edges, project.EdgeHackathon) + edges = append(edges, question.EdgeHackathon) } if m.creator != nil { - edges = append(edges, project.EdgeCreator) + edges = append(edges, question.EdgeCreator) } if m.modifier != nil { - edges = append(edges, project.EdgeModifier) - } - if m.teams != nil { - edges = append(edges, project.EdgeTeams) + edges = append(edges, question.EdgeModifier) } - if m.submissions != nil { - edges = append(edges, project.EdgeSubmissions) - } - if m.preferred_by_users != nil { - edges = append(edges, project.EdgePreferredByUsers) + if m.answers != nil { + edges = append(edges, question.EdgeAnswers) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProjectMutation) AddedIDs(name string) []ent.Value { +func (m *QuestionMutation) AddedIDs(name string) []ent.Value { switch name { - case project.EdgeTrack: - if id := m.track; id != nil { - return []ent.Value{*id} - } - case project.EdgeHackathon: + case question.EdgeHackathon: if id := m.hackathon; id != nil { return []ent.Value{*id} } - case project.EdgeCreator: + case question.EdgeCreator: if id := m.creator; id != nil { return []ent.Value{*id} } - case project.EdgeModifier: + case question.EdgeModifier: if id := m.modifier; id != nil { return []ent.Value{*id} } - case project.EdgeTeams: - ids := make([]ent.Value, 0, len(m.teams)) - for id := range m.teams { - ids = append(ids, id) - } - return ids - case project.EdgeSubmissions: - ids := make([]ent.Value, 0, len(m.submissions)) - for id := range m.submissions { - ids = append(ids, id) - } - return ids - case project.EdgePreferredByUsers: - ids := make([]ent.Value, 0, len(m.preferred_by_users)) - for id := range m.preferred_by_users { + case question.EdgeAnswers: + ids := make([]ent.Value, 0, len(m.answers)) + for id := range m.answers { ids = append(ids, id) } return ids @@ -6021,39 +7858,21 @@ func (m *ProjectMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProjectMutation) RemovedEdges() []string { - edges := make([]string, 0, 7) - if m.removedteams != nil { - edges = append(edges, project.EdgeTeams) - } - if m.removedsubmissions != nil { - edges = append(edges, project.EdgeSubmissions) - } - if m.removedpreferred_by_users != nil { - edges = append(edges, project.EdgePreferredByUsers) +func (m *QuestionMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedanswers != nil { + edges = append(edges, question.EdgeAnswers) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProjectMutation) RemovedIDs(name string) []ent.Value { +func (m *QuestionMutation) RemovedIDs(name string) []ent.Value { switch name { - case project.EdgeTeams: - ids := make([]ent.Value, 0, len(m.removedteams)) - for id := range m.removedteams { - ids = append(ids, id) - } - return ids - case project.EdgeSubmissions: - ids := make([]ent.Value, 0, len(m.removedsubmissions)) - for id := range m.removedsubmissions { - ids = append(ids, id) - } - return ids - case project.EdgePreferredByUsers: - ids := make([]ent.Value, 0, len(m.removedpreferred_by_users)) - for id := range m.removedpreferred_by_users { + case question.EdgeAnswers: + ids := make([]ent.Value, 0, len(m.removedanswers)) + for id := range m.removedanswers { ids = append(ids, id) } return ids @@ -6062,101 +7881,74 @@ func (m *ProjectMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProjectMutation) ClearedEdges() []string { - edges := make([]string, 0, 7) - if m.clearedtrack { - edges = append(edges, project.EdgeTrack) - } +func (m *QuestionMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) if m.clearedhackathon { - edges = append(edges, project.EdgeHackathon) + edges = append(edges, question.EdgeHackathon) } if m.clearedcreator { - edges = append(edges, project.EdgeCreator) + edges = append(edges, question.EdgeCreator) } if m.clearedmodifier { - edges = append(edges, project.EdgeModifier) + edges = append(edges, question.EdgeModifier) } - if m.clearedteams { - edges = append(edges, project.EdgeTeams) - } - if m.clearedsubmissions { - edges = append(edges, project.EdgeSubmissions) - } - if m.clearedpreferred_by_users { - edges = append(edges, project.EdgePreferredByUsers) + if m.clearedanswers { + edges = append(edges, question.EdgeAnswers) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProjectMutation) EdgeCleared(name string) bool { +func (m *QuestionMutation) EdgeCleared(name string) bool { switch name { - case project.EdgeTrack: - return m.clearedtrack - case project.EdgeHackathon: + case question.EdgeHackathon: return m.clearedhackathon - case project.EdgeCreator: + case question.EdgeCreator: return m.clearedcreator - case project.EdgeModifier: + case question.EdgeModifier: return m.clearedmodifier - case project.EdgeTeams: - return m.clearedteams - case project.EdgeSubmissions: - return m.clearedsubmissions - case project.EdgePreferredByUsers: - return m.clearedpreferred_by_users + case question.EdgeAnswers: + return m.clearedanswers } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProjectMutation) ClearEdge(name string) error { +func (m *QuestionMutation) ClearEdge(name string) error { switch name { - case project.EdgeTrack: - m.ClearTrack() - return nil - case project.EdgeHackathon: + case question.EdgeHackathon: m.ClearHackathon() return nil - case project.EdgeCreator: + case question.EdgeCreator: m.ClearCreator() return nil - case project.EdgeModifier: + case question.EdgeModifier: m.ClearModifier() return nil } - return fmt.Errorf("unknown Project unique edge %s", name) + return fmt.Errorf("unknown Question unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProjectMutation) ResetEdge(name string) error { +func (m *QuestionMutation) ResetEdge(name string) error { switch name { - case project.EdgeTrack: - m.ResetTrack() - return nil - case project.EdgeHackathon: + case question.EdgeHackathon: m.ResetHackathon() return nil - case project.EdgeCreator: + case question.EdgeCreator: m.ResetCreator() return nil - case project.EdgeModifier: + case question.EdgeModifier: m.ResetModifier() return nil - case project.EdgeTeams: - m.ResetTeams() - return nil - case project.EdgeSubmissions: - m.ResetSubmissions() - return nil - case project.EdgePreferredByUsers: - m.ResetPreferredByUsers() + case question.EdgeAnswers: + m.ResetAnswers() return nil } - return fmt.Errorf("unknown Project edge %s", name) + return fmt.Errorf("unknown Question edge %s", name) } // SubmissionMutation represents an operation that mutates the Submission nodes in the graph. @@ -9285,6 +11077,15 @@ type UserMutation struct { modified_tracks map[uuid.UUID]struct{} removedmodified_tracks map[uuid.UUID]struct{} clearedmodified_tracks bool + created_questions map[uuid.UUID]struct{} + removedcreated_questions map[uuid.UUID]struct{} + clearedcreated_questions bool + modified_questions map[uuid.UUID]struct{} + removedmodified_questions map[uuid.UUID]struct{} + clearedmodified_questions bool + created_answers map[uuid.UUID]struct{} + removedcreated_answers map[uuid.UUID]struct{} + clearedcreated_answers bool modified_states map[uuid.UUID]struct{} removedmodified_states map[uuid.UUID]struct{} clearedmodified_states bool @@ -10515,6 +12316,168 @@ func (m *UserMutation) ResetModifiedTracks() { m.removedmodified_tracks = nil } +// AddCreatedQuestionIDs adds the "created_questions" edge to the Question entity by ids. +func (m *UserMutation) AddCreatedQuestionIDs(ids ...uuid.UUID) { + if m.created_questions == nil { + m.created_questions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.created_questions[ids[i]] = struct{}{} + } +} + +// ClearCreatedQuestions clears the "created_questions" edge to the Question entity. +func (m *UserMutation) ClearCreatedQuestions() { + m.clearedcreated_questions = true +} + +// CreatedQuestionsCleared reports if the "created_questions" edge to the Question entity was cleared. +func (m *UserMutation) CreatedQuestionsCleared() bool { + return m.clearedcreated_questions +} + +// RemoveCreatedQuestionIDs removes the "created_questions" edge to the Question entity by IDs. +func (m *UserMutation) RemoveCreatedQuestionIDs(ids ...uuid.UUID) { + if m.removedcreated_questions == nil { + m.removedcreated_questions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.created_questions, ids[i]) + m.removedcreated_questions[ids[i]] = struct{}{} + } +} + +// RemovedCreatedQuestions returns the removed IDs of the "created_questions" edge to the Question entity. +func (m *UserMutation) RemovedCreatedQuestionsIDs() (ids []uuid.UUID) { + for id := range m.removedcreated_questions { + ids = append(ids, id) + } + return +} + +// CreatedQuestionsIDs returns the "created_questions" edge IDs in the mutation. +func (m *UserMutation) CreatedQuestionsIDs() (ids []uuid.UUID) { + for id := range m.created_questions { + ids = append(ids, id) + } + return +} + +// ResetCreatedQuestions resets all changes to the "created_questions" edge. +func (m *UserMutation) ResetCreatedQuestions() { + m.created_questions = nil + m.clearedcreated_questions = false + m.removedcreated_questions = nil +} + +// AddModifiedQuestionIDs adds the "modified_questions" edge to the Question entity by ids. +func (m *UserMutation) AddModifiedQuestionIDs(ids ...uuid.UUID) { + if m.modified_questions == nil { + m.modified_questions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.modified_questions[ids[i]] = struct{}{} + } +} + +// ClearModifiedQuestions clears the "modified_questions" edge to the Question entity. +func (m *UserMutation) ClearModifiedQuestions() { + m.clearedmodified_questions = true +} + +// ModifiedQuestionsCleared reports if the "modified_questions" edge to the Question entity was cleared. +func (m *UserMutation) ModifiedQuestionsCleared() bool { + return m.clearedmodified_questions +} + +// RemoveModifiedQuestionIDs removes the "modified_questions" edge to the Question entity by IDs. +func (m *UserMutation) RemoveModifiedQuestionIDs(ids ...uuid.UUID) { + if m.removedmodified_questions == nil { + m.removedmodified_questions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.modified_questions, ids[i]) + m.removedmodified_questions[ids[i]] = struct{}{} + } +} + +// RemovedModifiedQuestions returns the removed IDs of the "modified_questions" edge to the Question entity. +func (m *UserMutation) RemovedModifiedQuestionsIDs() (ids []uuid.UUID) { + for id := range m.removedmodified_questions { + ids = append(ids, id) + } + return +} + +// ModifiedQuestionsIDs returns the "modified_questions" edge IDs in the mutation. +func (m *UserMutation) ModifiedQuestionsIDs() (ids []uuid.UUID) { + for id := range m.modified_questions { + ids = append(ids, id) + } + return +} + +// ResetModifiedQuestions resets all changes to the "modified_questions" edge. +func (m *UserMutation) ResetModifiedQuestions() { + m.modified_questions = nil + m.clearedmodified_questions = false + m.removedmodified_questions = nil +} + +// AddCreatedAnswerIDs adds the "created_answers" edge to the Answer entity by ids. +func (m *UserMutation) AddCreatedAnswerIDs(ids ...uuid.UUID) { + if m.created_answers == nil { + m.created_answers = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.created_answers[ids[i]] = struct{}{} + } +} + +// ClearCreatedAnswers clears the "created_answers" edge to the Answer entity. +func (m *UserMutation) ClearCreatedAnswers() { + m.clearedcreated_answers = true +} + +// CreatedAnswersCleared reports if the "created_answers" edge to the Answer entity was cleared. +func (m *UserMutation) CreatedAnswersCleared() bool { + return m.clearedcreated_answers +} + +// RemoveCreatedAnswerIDs removes the "created_answers" edge to the Answer entity by IDs. +func (m *UserMutation) RemoveCreatedAnswerIDs(ids ...uuid.UUID) { + if m.removedcreated_answers == nil { + m.removedcreated_answers = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.created_answers, ids[i]) + m.removedcreated_answers[ids[i]] = struct{}{} + } +} + +// RemovedCreatedAnswers returns the removed IDs of the "created_answers" edge to the Answer entity. +func (m *UserMutation) RemovedCreatedAnswersIDs() (ids []uuid.UUID) { + for id := range m.removedcreated_answers { + ids = append(ids, id) + } + return +} + +// CreatedAnswersIDs returns the "created_answers" edge IDs in the mutation. +func (m *UserMutation) CreatedAnswersIDs() (ids []uuid.UUID) { + for id := range m.created_answers { + ids = append(ids, id) + } + return +} + +// ResetCreatedAnswers resets all changes to the "created_answers" edge. +func (m *UserMutation) ResetCreatedAnswers() { + m.created_answers = nil + m.clearedcreated_answers = false + m.removedcreated_answers = nil +} + // AddModifiedStateIDs adds the "modified_states" edge to the HackathonState entity by ids. func (m *UserMutation) AddModifiedStateIDs(ids ...uuid.UUID) { if m.modified_states == nil { @@ -11018,7 +12981,7 @@ func (m *UserMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *UserMutation) AddedEdges() []string { - edges := make([]string, 0, 21) + edges := make([]string, 0, 24) if m.created_hackathons != nil { edges = append(edges, user.EdgeCreatedHackathons) } @@ -11067,6 +13030,15 @@ func (m *UserMutation) AddedEdges() []string { if m.modified_tracks != nil { edges = append(edges, user.EdgeModifiedTracks) } + if m.created_questions != nil { + edges = append(edges, user.EdgeCreatedQuestions) + } + if m.modified_questions != nil { + edges = append(edges, user.EdgeModifiedQuestions) + } + if m.created_answers != nil { + edges = append(edges, user.EdgeCreatedAnswers) + } if m.modified_states != nil { edges = append(edges, user.EdgeModifiedStates) } @@ -11185,6 +13157,24 @@ func (m *UserMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case user.EdgeCreatedQuestions: + ids := make([]ent.Value, 0, len(m.created_questions)) + for id := range m.created_questions { + ids = append(ids, id) + } + return ids + case user.EdgeModifiedQuestions: + ids := make([]ent.Value, 0, len(m.modified_questions)) + for id := range m.modified_questions { + ids = append(ids, id) + } + return ids + case user.EdgeCreatedAnswers: + ids := make([]ent.Value, 0, len(m.created_answers)) + for id := range m.created_answers { + ids = append(ids, id) + } + return ids case user.EdgeModifiedStates: ids := make([]ent.Value, 0, len(m.modified_states)) for id := range m.modified_states { @@ -11221,7 +13211,7 @@ func (m *UserMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *UserMutation) RemovedEdges() []string { - edges := make([]string, 0, 21) + edges := make([]string, 0, 24) if m.removedcreated_hackathons != nil { edges = append(edges, user.EdgeCreatedHackathons) } @@ -11270,6 +13260,15 @@ func (m *UserMutation) RemovedEdges() []string { if m.removedmodified_tracks != nil { edges = append(edges, user.EdgeModifiedTracks) } + if m.removedcreated_questions != nil { + edges = append(edges, user.EdgeCreatedQuestions) + } + if m.removedmodified_questions != nil { + edges = append(edges, user.EdgeModifiedQuestions) + } + if m.removedcreated_answers != nil { + edges = append(edges, user.EdgeCreatedAnswers) + } if m.removedmodified_states != nil { edges = append(edges, user.EdgeModifiedStates) } @@ -11388,6 +13387,24 @@ func (m *UserMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case user.EdgeCreatedQuestions: + ids := make([]ent.Value, 0, len(m.removedcreated_questions)) + for id := range m.removedcreated_questions { + ids = append(ids, id) + } + return ids + case user.EdgeModifiedQuestions: + ids := make([]ent.Value, 0, len(m.removedmodified_questions)) + for id := range m.removedmodified_questions { + ids = append(ids, id) + } + return ids + case user.EdgeCreatedAnswers: + ids := make([]ent.Value, 0, len(m.removedcreated_answers)) + for id := range m.removedcreated_answers { + ids = append(ids, id) + } + return ids case user.EdgeModifiedStates: ids := make([]ent.Value, 0, len(m.removedmodified_states)) for id := range m.removedmodified_states { @@ -11424,7 +13441,7 @@ func (m *UserMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UserMutation) ClearedEdges() []string { - edges := make([]string, 0, 21) + edges := make([]string, 0, 24) if m.clearedcreated_hackathons { edges = append(edges, user.EdgeCreatedHackathons) } @@ -11473,6 +13490,15 @@ func (m *UserMutation) ClearedEdges() []string { if m.clearedmodified_tracks { edges = append(edges, user.EdgeModifiedTracks) } + if m.clearedcreated_questions { + edges = append(edges, user.EdgeCreatedQuestions) + } + if m.clearedmodified_questions { + edges = append(edges, user.EdgeModifiedQuestions) + } + if m.clearedcreated_answers { + edges = append(edges, user.EdgeCreatedAnswers) + } if m.clearedmodified_states { edges = append(edges, user.EdgeModifiedStates) } @@ -11527,6 +13553,12 @@ func (m *UserMutation) EdgeCleared(name string) bool { return m.clearedcreated_tracks case user.EdgeModifiedTracks: return m.clearedmodified_tracks + case user.EdgeCreatedQuestions: + return m.clearedcreated_questions + case user.EdgeModifiedQuestions: + return m.clearedmodified_questions + case user.EdgeCreatedAnswers: + return m.clearedcreated_answers case user.EdgeModifiedStates: return m.clearedmodified_states case user.EdgePreferredProjects: @@ -11601,6 +13633,15 @@ func (m *UserMutation) ResetEdge(name string) error { case user.EdgeModifiedTracks: m.ResetModifiedTracks() return nil + case user.EdgeCreatedQuestions: + m.ResetCreatedQuestions() + return nil + case user.EdgeModifiedQuestions: + m.ResetModifiedQuestions() + return nil + case user.EdgeCreatedAnswers: + m.ResetCreatedAnswers() + return nil case user.EdgeModifiedStates: m.ResetModifiedStates() return nil diff --git a/components/backend/ent/predicate/predicate.go b/components/backend/ent/predicate/predicate.go index c4c22c7c..bfcb0033 100644 --- a/components/backend/ent/predicate/predicate.go +++ b/components/backend/ent/predicate/predicate.go @@ -6,6 +6,9 @@ import ( "entgo.io/ent/dialect/sql" ) +// Answer is the predicate function for answer builders. +type Answer func(*sql.Selector) + // Hackathon is the predicate function for hackathon builders. type Hackathon func(*sql.Selector) @@ -24,6 +27,9 @@ type Phase func(*sql.Selector) // Project is the predicate function for project builders. type Project func(*sql.Selector) +// Question is the predicate function for question builders. +type Question func(*sql.Selector) + // Submission is the predicate function for submission builders. type Submission func(*sql.Selector) diff --git a/components/backend/ent/question.go b/components/backend/ent/question.go new file mode 100644 index 00000000..1ee415f0 --- /dev/null +++ b/components/backend/ent/question.go @@ -0,0 +1,290 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// A registration question configured by a hackathon owner. +type Question struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // The hackathon this question belongs to. + HackathonID uuid.UUID `json:"hackathon_id,omitempty"` + // Unique identifier for the question within the hackathon. + Key string `json:"key,omitempty"` + // Display label for the question. + Label string `json:"label,omitempty"` + // The type of answer expected from participants. + Type question.Type `json:"type,omitempty"` + // Whether the participant must answer this question to join. + Mandatory bool `json:"mandatory,omitempty"` + // Display order; lower values appear first. + Order int `json:"order,omitempty"` + // Timestamp when the question was created. + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of the last modification. + ModifiedAt time.Time `json:"modified_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the QuestionQuery when eager-loading is set. + Edges QuestionEdges `json:"edges"` + user_created_questions *uuid.UUID + user_modified_questions *uuid.UUID + selectValues sql.SelectValues +} + +// QuestionEdges holds the relations/edges for other nodes in the graph. +type QuestionEdges struct { + // The hackathon this question belongs to. + Hackathon *Hackathon `json:"hackathon,omitempty"` + // The user who created the question. + Creator *User `json:"creator,omitempty"` + // The user who last modified the question. + Modifier *User `json:"modifier,omitempty"` + // Answers submitted by participants for this question. + Answers []*Answer `json:"answers,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// HackathonOrErr returns the Hackathon value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e QuestionEdges) HackathonOrErr() (*Hackathon, error) { + if e.Hackathon != nil { + return e.Hackathon, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: hackathon.Label} + } + return nil, &NotLoadedError{edge: "hackathon"} +} + +// CreatorOrErr returns the Creator value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e QuestionEdges) CreatorOrErr() (*User, error) { + if e.Creator != nil { + return e.Creator, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: user.Label} + } + return nil, &NotLoadedError{edge: "creator"} +} + +// ModifierOrErr returns the Modifier value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e QuestionEdges) ModifierOrErr() (*User, error) { + if e.Modifier != nil { + return e.Modifier, nil + } else if e.loadedTypes[2] { + return nil, &NotFoundError{label: user.Label} + } + return nil, &NotLoadedError{edge: "modifier"} +} + +// AnswersOrErr returns the Answers value or an error if the edge +// was not loaded in eager-loading. +func (e QuestionEdges) AnswersOrErr() ([]*Answer, error) { + if e.loadedTypes[3] { + return e.Answers, nil + } + return nil, &NotLoadedError{edge: "answers"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Question) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case question.FieldMandatory: + values[i] = new(sql.NullBool) + case question.FieldOrder: + values[i] = new(sql.NullInt64) + case question.FieldKey, question.FieldLabel, question.FieldType: + values[i] = new(sql.NullString) + case question.FieldCreatedAt, question.FieldModifiedAt: + values[i] = new(sql.NullTime) + case question.FieldID, question.FieldHackathonID: + values[i] = new(uuid.UUID) + case question.ForeignKeys[0]: // user_created_questions + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case question.ForeignKeys[1]: // user_modified_questions + values[i] = &sql.NullScanner{S: 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 Question fields. +func (_m *Question) 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 question.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 question.FieldHackathonID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field hackathon_id", values[i]) + } else if value != nil { + _m.HackathonID = *value + } + case question.FieldKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field key", values[i]) + } else if value.Valid { + _m.Key = value.String + } + case question.FieldLabel: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field label", values[i]) + } else if value.Valid { + _m.Label = value.String + } + case question.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = question.Type(value.String) + } + case question.FieldMandatory: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field mandatory", values[i]) + } else if value.Valid { + _m.Mandatory = value.Bool + } + case question.FieldOrder: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field order", values[i]) + } else if value.Valid { + _m.Order = int(value.Int64) + } + case question.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 + } + case question.FieldModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field modified_at", values[i]) + } else if value.Valid { + _m.ModifiedAt = value.Time + } + case question.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field user_created_questions", values[i]) + } else if value.Valid { + _m.user_created_questions = new(uuid.UUID) + *_m.user_created_questions = *value.S.(*uuid.UUID) + } + case question.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field user_modified_questions", values[i]) + } else if value.Valid { + _m.user_modified_questions = new(uuid.UUID) + *_m.user_modified_questions = *value.S.(*uuid.UUID) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Question. +// This includes values selected through modifiers, order, etc. +func (_m *Question) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryHackathon queries the "hackathon" edge of the Question entity. +func (_m *Question) QueryHackathon() *HackathonQuery { + return NewQuestionClient(_m.config).QueryHackathon(_m) +} + +// QueryCreator queries the "creator" edge of the Question entity. +func (_m *Question) QueryCreator() *UserQuery { + return NewQuestionClient(_m.config).QueryCreator(_m) +} + +// QueryModifier queries the "modifier" edge of the Question entity. +func (_m *Question) QueryModifier() *UserQuery { + return NewQuestionClient(_m.config).QueryModifier(_m) +} + +// QueryAnswers queries the "answers" edge of the Question entity. +func (_m *Question) QueryAnswers() *AnswerQuery { + return NewQuestionClient(_m.config).QueryAnswers(_m) +} + +// Update returns a builder for updating this Question. +// Note that you need to call Question.Unwrap() before calling this method if this Question +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *Question) Update() *QuestionUpdateOne { + return NewQuestionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the Question 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 *Question) Unwrap() *Question { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: Question is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *Question) String() string { + var builder strings.Builder + builder.WriteString("Question(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("hackathon_id=") + builder.WriteString(fmt.Sprintf("%v", _m.HackathonID)) + builder.WriteString(", ") + builder.WriteString("key=") + builder.WriteString(_m.Key) + builder.WriteString(", ") + builder.WriteString("label=") + builder.WriteString(_m.Label) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", _m.Type)) + builder.WriteString(", ") + builder.WriteString("mandatory=") + builder.WriteString(fmt.Sprintf("%v", _m.Mandatory)) + builder.WriteString(", ") + builder.WriteString("order=") + builder.WriteString(fmt.Sprintf("%v", _m.Order)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("modified_at=") + builder.WriteString(_m.ModifiedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// Questions is a parsable slice of Question. +type Questions []*Question diff --git a/components/backend/ent/question/question.go b/components/backend/ent/question/question.go new file mode 100644 index 00000000..c207fa27 --- /dev/null +++ b/components/backend/ent/question/question.go @@ -0,0 +1,259 @@ +// Code generated by ent, DO NOT EDIT. + +package question + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the question type in the database. + Label = "question" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldHackathonID holds the string denoting the hackathon_id field in the database. + FieldHackathonID = "hackathon_id" + // FieldKey holds the string denoting the key field in the database. + FieldKey = "key" + // FieldLabel holds the string denoting the label field in the database. + FieldLabel = "label" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldMandatory holds the string denoting the mandatory field in the database. + FieldMandatory = "mandatory" + // FieldOrder holds the string denoting the order field in the database. + FieldOrder = "order" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldModifiedAt holds the string denoting the modified_at field in the database. + FieldModifiedAt = "modified_at" + // EdgeHackathon holds the string denoting the hackathon edge name in mutations. + EdgeHackathon = "hackathon" + // EdgeCreator holds the string denoting the creator edge name in mutations. + EdgeCreator = "creator" + // EdgeModifier holds the string denoting the modifier edge name in mutations. + EdgeModifier = "modifier" + // EdgeAnswers holds the string denoting the answers edge name in mutations. + EdgeAnswers = "answers" + // Table holds the table name of the question in the database. + Table = "questions" + // HackathonTable is the table that holds the hackathon relation/edge. + HackathonTable = "questions" + // HackathonInverseTable is the table name for the Hackathon entity. + // It exists in this package in order to avoid circular dependency with the "hackathon" package. + HackathonInverseTable = "hackathons" + // HackathonColumn is the table column denoting the hackathon relation/edge. + HackathonColumn = "hackathon_id" + // CreatorTable is the table that holds the creator relation/edge. + CreatorTable = "questions" + // CreatorInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + CreatorInverseTable = "users" + // CreatorColumn is the table column denoting the creator relation/edge. + CreatorColumn = "user_created_questions" + // ModifierTable is the table that holds the modifier relation/edge. + ModifierTable = "questions" + // ModifierInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + ModifierInverseTable = "users" + // ModifierColumn is the table column denoting the modifier relation/edge. + ModifierColumn = "user_modified_questions" + // AnswersTable is the table that holds the answers relation/edge. + AnswersTable = "answers" + // AnswersInverseTable is the table name for the Answer entity. + // It exists in this package in order to avoid circular dependency with the "answer" package. + AnswersInverseTable = "answers" + // AnswersColumn is the table column denoting the answers relation/edge. + AnswersColumn = "question_id" +) + +// Columns holds all SQL columns for question fields. +var Columns = []string{ + FieldID, + FieldHackathonID, + FieldKey, + FieldLabel, + FieldType, + FieldMandatory, + FieldOrder, + FieldCreatedAt, + FieldModifiedAt, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "questions" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "user_created_questions", + "user_modified_questions", +} + +// 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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // KeyValidator is a validator for the "key" field. It is called by the builders before save. + KeyValidator func(string) error + // DefaultMandatory holds the default value on creation for the "mandatory" field. + DefaultMandatory bool + // DefaultOrder holds the default value on creation for the "order" field. + DefaultOrder int + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultModifiedAt holds the default value on creation for the "modified_at" field. + DefaultModifiedAt func() time.Time + // UpdateDefaultModifiedAt holds the default value on update for the "modified_at" field. + UpdateDefaultModifiedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// Type defines the type for the "type" enum field. +type Type string + +// Type values. +const ( + TypeText Type = "text" + TypeBool Type = "bool" +) + +func (_type Type) String() string { + return string(_type) +} + +// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save. +func TypeValidator(_type Type) error { + switch _type { + case TypeText, TypeBool: + return nil + default: + return fmt.Errorf("question: invalid enum value for type field: %q", _type) + } +} + +// OrderOption defines the ordering options for the Question 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() +} + +// ByHackathonID orders the results by the hackathon_id field. +func ByHackathonID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHackathonID, opts...).ToFunc() +} + +// ByKey orders the results by the key field. +func ByKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKey, opts...).ToFunc() +} + +// ByLabel orders the results by the label field. +func ByLabel(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLabel, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByMandatory orders the results by the mandatory field. +func ByMandatory(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMandatory, opts...).ToFunc() +} + +// ByOrder orders the results by the order field. +func ByOrder(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrder, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByModifiedAt orders the results by the modified_at field. +func ByModifiedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModifiedAt, opts...).ToFunc() +} + +// ByHackathonField orders the results by hackathon field. +func ByHackathonField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newHackathonStep(), sql.OrderByField(field, opts...)) + } +} + +// ByCreatorField orders the results by creator field. +func ByCreatorField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newCreatorStep(), sql.OrderByField(field, opts...)) + } +} + +// ByModifierField orders the results by modifier field. +func ByModifierField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModifierStep(), sql.OrderByField(field, opts...)) + } +} + +// ByAnswersCount orders the results by answers count. +func ByAnswersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newAnswersStep(), opts...) + } +} + +// ByAnswers orders the results by answers terms. +func ByAnswers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newAnswersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newHackathonStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(HackathonInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, HackathonTable, HackathonColumn), + ) +} +func newCreatorStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(CreatorInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, CreatorTable, CreatorColumn), + ) +} +func newModifierStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModifierInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ModifierTable, ModifierColumn), + ) +} +func newAnswersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AnswersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, AnswersTable, AnswersColumn), + ) +} diff --git a/components/backend/ent/question/where.go b/components/backend/ent/question/where.go new file mode 100644 index 00000000..a757f218 --- /dev/null +++ b/components/backend/ent/question/where.go @@ -0,0 +1,494 @@ +// Code generated by ent, DO NOT EDIT. + +package question + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldLTE(FieldID, id)) +} + +// HackathonID applies equality check predicate on the "hackathon_id" field. It's identical to HackathonIDEQ. +func HackathonID(v uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldHackathonID, v)) +} + +// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. +func Key(v string) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldKey, v)) +} + +// Mandatory applies equality check predicate on the "mandatory" field. It's identical to MandatoryEQ. +func Mandatory(v bool) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldMandatory, v)) +} + +// Order applies equality check predicate on the "order" field. It's identical to OrderEQ. +func Order(v int) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldOrder, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldCreatedAt, v)) +} + +// ModifiedAt applies equality check predicate on the "modified_at" field. It's identical to ModifiedAtEQ. +func ModifiedAt(v time.Time) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldModifiedAt, v)) +} + +// HackathonIDEQ applies the EQ predicate on the "hackathon_id" field. +func HackathonIDEQ(v uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldHackathonID, v)) +} + +// HackathonIDNEQ applies the NEQ predicate on the "hackathon_id" field. +func HackathonIDNEQ(v uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldHackathonID, v)) +} + +// HackathonIDIn applies the In predicate on the "hackathon_id" field. +func HackathonIDIn(vs ...uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldIn(FieldHackathonID, vs...)) +} + +// HackathonIDNotIn applies the NotIn predicate on the "hackathon_id" field. +func HackathonIDNotIn(vs ...uuid.UUID) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldHackathonID, vs...)) +} + +// KeyEQ applies the EQ predicate on the "key" field. +func KeyEQ(v string) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldKey, v)) +} + +// KeyNEQ applies the NEQ predicate on the "key" field. +func KeyNEQ(v string) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldKey, v)) +} + +// KeyIn applies the In predicate on the "key" field. +func KeyIn(vs ...string) predicate.Question { + return predicate.Question(sql.FieldIn(FieldKey, vs...)) +} + +// KeyNotIn applies the NotIn predicate on the "key" field. +func KeyNotIn(vs ...string) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldKey, vs...)) +} + +// KeyGT applies the GT predicate on the "key" field. +func KeyGT(v string) predicate.Question { + return predicate.Question(sql.FieldGT(FieldKey, v)) +} + +// KeyGTE applies the GTE predicate on the "key" field. +func KeyGTE(v string) predicate.Question { + return predicate.Question(sql.FieldGTE(FieldKey, v)) +} + +// KeyLT applies the LT predicate on the "key" field. +func KeyLT(v string) predicate.Question { + return predicate.Question(sql.FieldLT(FieldKey, v)) +} + +// KeyLTE applies the LTE predicate on the "key" field. +func KeyLTE(v string) predicate.Question { + return predicate.Question(sql.FieldLTE(FieldKey, v)) +} + +// KeyContains applies the Contains predicate on the "key" field. +func KeyContains(v string) predicate.Question { + return predicate.Question(sql.FieldContains(FieldKey, v)) +} + +// KeyHasPrefix applies the HasPrefix predicate on the "key" field. +func KeyHasPrefix(v string) predicate.Question { + return predicate.Question(sql.FieldHasPrefix(FieldKey, v)) +} + +// KeyHasSuffix applies the HasSuffix predicate on the "key" field. +func KeyHasSuffix(v string) predicate.Question { + return predicate.Question(sql.FieldHasSuffix(FieldKey, v)) +} + +// KeyEqualFold applies the EqualFold predicate on the "key" field. +func KeyEqualFold(v string) predicate.Question { + return predicate.Question(sql.FieldEqualFold(FieldKey, v)) +} + +// KeyContainsFold applies the ContainsFold predicate on the "key" field. +func KeyContainsFold(v string) predicate.Question { + return predicate.Question(sql.FieldContainsFold(FieldKey, v)) +} + +// LabelEQ applies the EQ predicate on the "label" field. +func LabelEQ(v string) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldLabel, v)) +} + +// LabelNEQ applies the NEQ predicate on the "label" field. +func LabelNEQ(v string) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldLabel, v)) +} + +// LabelIn applies the In predicate on the "label" field. +func LabelIn(vs ...string) predicate.Question { + return predicate.Question(sql.FieldIn(FieldLabel, vs...)) +} + +// LabelNotIn applies the NotIn predicate on the "label" field. +func LabelNotIn(vs ...string) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldLabel, vs...)) +} + +// LabelGT applies the GT predicate on the "label" field. +func LabelGT(v string) predicate.Question { + return predicate.Question(sql.FieldGT(FieldLabel, v)) +} + +// LabelGTE applies the GTE predicate on the "label" field. +func LabelGTE(v string) predicate.Question { + return predicate.Question(sql.FieldGTE(FieldLabel, v)) +} + +// LabelLT applies the LT predicate on the "label" field. +func LabelLT(v string) predicate.Question { + return predicate.Question(sql.FieldLT(FieldLabel, v)) +} + +// LabelLTE applies the LTE predicate on the "label" field. +func LabelLTE(v string) predicate.Question { + return predicate.Question(sql.FieldLTE(FieldLabel, v)) +} + +// LabelContains applies the Contains predicate on the "label" field. +func LabelContains(v string) predicate.Question { + return predicate.Question(sql.FieldContains(FieldLabel, v)) +} + +// LabelHasPrefix applies the HasPrefix predicate on the "label" field. +func LabelHasPrefix(v string) predicate.Question { + return predicate.Question(sql.FieldHasPrefix(FieldLabel, v)) +} + +// LabelHasSuffix applies the HasSuffix predicate on the "label" field. +func LabelHasSuffix(v string) predicate.Question { + return predicate.Question(sql.FieldHasSuffix(FieldLabel, v)) +} + +// LabelEqualFold applies the EqualFold predicate on the "label" field. +func LabelEqualFold(v string) predicate.Question { + return predicate.Question(sql.FieldEqualFold(FieldLabel, v)) +} + +// LabelContainsFold applies the ContainsFold predicate on the "label" field. +func LabelContainsFold(v string) predicate.Question { + return predicate.Question(sql.FieldContainsFold(FieldLabel, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v Type) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v Type) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...Type) predicate.Question { + return predicate.Question(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...Type) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldType, vs...)) +} + +// MandatoryEQ applies the EQ predicate on the "mandatory" field. +func MandatoryEQ(v bool) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldMandatory, v)) +} + +// MandatoryNEQ applies the NEQ predicate on the "mandatory" field. +func MandatoryNEQ(v bool) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldMandatory, v)) +} + +// OrderEQ applies the EQ predicate on the "order" field. +func OrderEQ(v int) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldOrder, v)) +} + +// OrderNEQ applies the NEQ predicate on the "order" field. +func OrderNEQ(v int) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldOrder, v)) +} + +// OrderIn applies the In predicate on the "order" field. +func OrderIn(vs ...int) predicate.Question { + return predicate.Question(sql.FieldIn(FieldOrder, vs...)) +} + +// OrderNotIn applies the NotIn predicate on the "order" field. +func OrderNotIn(vs ...int) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldOrder, vs...)) +} + +// OrderGT applies the GT predicate on the "order" field. +func OrderGT(v int) predicate.Question { + return predicate.Question(sql.FieldGT(FieldOrder, v)) +} + +// OrderGTE applies the GTE predicate on the "order" field. +func OrderGTE(v int) predicate.Question { + return predicate.Question(sql.FieldGTE(FieldOrder, v)) +} + +// OrderLT applies the LT predicate on the "order" field. +func OrderLT(v int) predicate.Question { + return predicate.Question(sql.FieldLT(FieldOrder, v)) +} + +// OrderLTE applies the LTE predicate on the "order" field. +func OrderLTE(v int) predicate.Question { + return predicate.Question(sql.FieldLTE(FieldOrder, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Question { + return predicate.Question(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Question { + return predicate.Question(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Question { + return predicate.Question(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Question { + return predicate.Question(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Question { + return predicate.Question(sql.FieldLTE(FieldCreatedAt, v)) +} + +// ModifiedAtEQ applies the EQ predicate on the "modified_at" field. +func ModifiedAtEQ(v time.Time) predicate.Question { + return predicate.Question(sql.FieldEQ(FieldModifiedAt, v)) +} + +// ModifiedAtNEQ applies the NEQ predicate on the "modified_at" field. +func ModifiedAtNEQ(v time.Time) predicate.Question { + return predicate.Question(sql.FieldNEQ(FieldModifiedAt, v)) +} + +// ModifiedAtIn applies the In predicate on the "modified_at" field. +func ModifiedAtIn(vs ...time.Time) predicate.Question { + return predicate.Question(sql.FieldIn(FieldModifiedAt, vs...)) +} + +// ModifiedAtNotIn applies the NotIn predicate on the "modified_at" field. +func ModifiedAtNotIn(vs ...time.Time) predicate.Question { + return predicate.Question(sql.FieldNotIn(FieldModifiedAt, vs...)) +} + +// ModifiedAtGT applies the GT predicate on the "modified_at" field. +func ModifiedAtGT(v time.Time) predicate.Question { + return predicate.Question(sql.FieldGT(FieldModifiedAt, v)) +} + +// ModifiedAtGTE applies the GTE predicate on the "modified_at" field. +func ModifiedAtGTE(v time.Time) predicate.Question { + return predicate.Question(sql.FieldGTE(FieldModifiedAt, v)) +} + +// ModifiedAtLT applies the LT predicate on the "modified_at" field. +func ModifiedAtLT(v time.Time) predicate.Question { + return predicate.Question(sql.FieldLT(FieldModifiedAt, v)) +} + +// ModifiedAtLTE applies the LTE predicate on the "modified_at" field. +func ModifiedAtLTE(v time.Time) predicate.Question { + return predicate.Question(sql.FieldLTE(FieldModifiedAt, v)) +} + +// HasHackathon applies the HasEdge predicate on the "hackathon" edge. +func HasHackathon() predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, HackathonTable, HackathonColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasHackathonWith applies the HasEdge predicate on the "hackathon" edge with a given conditions (other predicates). +func HasHackathonWith(preds ...predicate.Hackathon) predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := newHackathonStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasCreator applies the HasEdge predicate on the "creator" edge. +func HasCreator() predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, CreatorTable, CreatorColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasCreatorWith applies the HasEdge predicate on the "creator" edge with a given conditions (other predicates). +func HasCreatorWith(preds ...predicate.User) predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := newCreatorStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasModifier applies the HasEdge predicate on the "modifier" edge. +func HasModifier() predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ModifierTable, ModifierColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModifierWith applies the HasEdge predicate on the "modifier" edge with a given conditions (other predicates). +func HasModifierWith(preds ...predicate.User) predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := newModifierStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasAnswers applies the HasEdge predicate on the "answers" edge. +func HasAnswers() predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, AnswersTable, AnswersColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAnswersWith applies the HasEdge predicate on the "answers" edge with a given conditions (other predicates). +func HasAnswersWith(preds ...predicate.Answer) predicate.Question { + return predicate.Question(func(s *sql.Selector) { + step := newAnswersStep() + 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.Question) predicate.Question { + return predicate.Question(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Question) predicate.Question { + return predicate.Question(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Question) predicate.Question { + return predicate.Question(sql.NotPredicates(p)) +} diff --git a/components/backend/ent/question_create.go b/components/backend/ent/question_create.go new file mode 100644 index 00000000..9fd432f5 --- /dev/null +++ b/components/backend/ent/question_create.go @@ -0,0 +1,480 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// QuestionCreate is the builder for creating a Question entity. +type QuestionCreate struct { + config + mutation *QuestionMutation + hooks []Hook +} + +// SetHackathonID sets the "hackathon_id" field. +func (_c *QuestionCreate) SetHackathonID(v uuid.UUID) *QuestionCreate { + _c.mutation.SetHackathonID(v) + return _c +} + +// SetKey sets the "key" field. +func (_c *QuestionCreate) SetKey(v string) *QuestionCreate { + _c.mutation.SetKey(v) + return _c +} + +// SetLabel sets the "label" field. +func (_c *QuestionCreate) SetLabel(v string) *QuestionCreate { + _c.mutation.SetLabel(v) + return _c +} + +// SetType sets the "type" field. +func (_c *QuestionCreate) SetType(v question.Type) *QuestionCreate { + _c.mutation.SetType(v) + return _c +} + +// SetMandatory sets the "mandatory" field. +func (_c *QuestionCreate) SetMandatory(v bool) *QuestionCreate { + _c.mutation.SetMandatory(v) + return _c +} + +// SetNillableMandatory sets the "mandatory" field if the given value is not nil. +func (_c *QuestionCreate) SetNillableMandatory(v *bool) *QuestionCreate { + if v != nil { + _c.SetMandatory(*v) + } + return _c +} + +// SetOrder sets the "order" field. +func (_c *QuestionCreate) SetOrder(v int) *QuestionCreate { + _c.mutation.SetOrder(v) + return _c +} + +// SetNillableOrder sets the "order" field if the given value is not nil. +func (_c *QuestionCreate) SetNillableOrder(v *int) *QuestionCreate { + if v != nil { + _c.SetOrder(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *QuestionCreate) SetCreatedAt(v time.Time) *QuestionCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *QuestionCreate) SetNillableCreatedAt(v *time.Time) *QuestionCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetModifiedAt sets the "modified_at" field. +func (_c *QuestionCreate) SetModifiedAt(v time.Time) *QuestionCreate { + _c.mutation.SetModifiedAt(v) + return _c +} + +// SetNillableModifiedAt sets the "modified_at" field if the given value is not nil. +func (_c *QuestionCreate) SetNillableModifiedAt(v *time.Time) *QuestionCreate { + if v != nil { + _c.SetModifiedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *QuestionCreate) SetID(v uuid.UUID) *QuestionCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *QuestionCreate) SetNillableID(v *uuid.UUID) *QuestionCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetHackathon sets the "hackathon" edge to the Hackathon entity. +func (_c *QuestionCreate) SetHackathon(v *Hackathon) *QuestionCreate { + return _c.SetHackathonID(v.ID) +} + +// SetCreatorID sets the "creator" edge to the User entity by ID. +func (_c *QuestionCreate) SetCreatorID(id uuid.UUID) *QuestionCreate { + _c.mutation.SetCreatorID(id) + return _c +} + +// SetCreator sets the "creator" edge to the User entity. +func (_c *QuestionCreate) SetCreator(v *User) *QuestionCreate { + return _c.SetCreatorID(v.ID) +} + +// SetModifierID sets the "modifier" edge to the User entity by ID. +func (_c *QuestionCreate) SetModifierID(id uuid.UUID) *QuestionCreate { + _c.mutation.SetModifierID(id) + return _c +} + +// SetModifier sets the "modifier" edge to the User entity. +func (_c *QuestionCreate) SetModifier(v *User) *QuestionCreate { + return _c.SetModifierID(v.ID) +} + +// AddAnswerIDs adds the "answers" edge to the Answer entity by IDs. +func (_c *QuestionCreate) AddAnswerIDs(ids ...uuid.UUID) *QuestionCreate { + _c.mutation.AddAnswerIDs(ids...) + return _c +} + +// AddAnswers adds the "answers" edges to the Answer entity. +func (_c *QuestionCreate) AddAnswers(v ...*Answer) *QuestionCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddAnswerIDs(ids...) +} + +// Mutation returns the QuestionMutation object of the builder. +func (_c *QuestionCreate) Mutation() *QuestionMutation { + return _c.mutation +} + +// Save creates the Question in the database. +func (_c *QuestionCreate) Save(ctx context.Context) (*Question, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *QuestionCreate) SaveX(ctx context.Context) *Question { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *QuestionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *QuestionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *QuestionCreate) defaults() { + if _, ok := _c.mutation.Mandatory(); !ok { + v := question.DefaultMandatory + _c.mutation.SetMandatory(v) + } + if _, ok := _c.mutation.Order(); !ok { + v := question.DefaultOrder + _c.mutation.SetOrder(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := question.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.ModifiedAt(); !ok { + v := question.DefaultModifiedAt() + _c.mutation.SetModifiedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := question.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *QuestionCreate) check() error { + if _, ok := _c.mutation.HackathonID(); !ok { + return &ValidationError{Name: "hackathon_id", err: errors.New(`ent: missing required field "Question.hackathon_id"`)} + } + if _, ok := _c.mutation.Key(); !ok { + return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Question.key"`)} + } + if v, ok := _c.mutation.Key(); ok { + if err := question.KeyValidator(v); err != nil { + return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Question.key": %w`, err)} + } + } + if _, ok := _c.mutation.Label(); !ok { + return &ValidationError{Name: "label", err: errors.New(`ent: missing required field "Question.label"`)} + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Question.type"`)} + } + if v, ok := _c.mutation.GetType(); ok { + if err := question.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Question.type": %w`, err)} + } + } + if _, ok := _c.mutation.Mandatory(); !ok { + return &ValidationError{Name: "mandatory", err: errors.New(`ent: missing required field "Question.mandatory"`)} + } + if _, ok := _c.mutation.Order(); !ok { + return &ValidationError{Name: "order", err: errors.New(`ent: missing required field "Question.order"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Question.created_at"`)} + } + if _, ok := _c.mutation.ModifiedAt(); !ok { + return &ValidationError{Name: "modified_at", err: errors.New(`ent: missing required field "Question.modified_at"`)} + } + if len(_c.mutation.HackathonIDs()) == 0 { + return &ValidationError{Name: "hackathon", err: errors.New(`ent: missing required edge "Question.hackathon"`)} + } + if len(_c.mutation.CreatorIDs()) == 0 { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required edge "Question.creator"`)} + } + if len(_c.mutation.ModifierIDs()) == 0 { + return &ValidationError{Name: "modifier", err: errors.New(`ent: missing required edge "Question.modifier"`)} + } + return nil +} + +func (_c *QuestionCreate) sqlSave(ctx context.Context) (*Question, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *QuestionCreate) createSpec() (*Question, *sqlgraph.CreateSpec) { + var ( + _node = &Question{config: _c.config} + _spec = sqlgraph.NewCreateSpec(question.Table, sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Key(); ok { + _spec.SetField(question.FieldKey, field.TypeString, value) + _node.Key = value + } + if value, ok := _c.mutation.Label(); ok { + _spec.SetField(question.FieldLabel, field.TypeString, value) + _node.Label = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(question.FieldType, field.TypeEnum, value) + _node.Type = value + } + if value, ok := _c.mutation.Mandatory(); ok { + _spec.SetField(question.FieldMandatory, field.TypeBool, value) + _node.Mandatory = value + } + if value, ok := _c.mutation.Order(); ok { + _spec.SetField(question.FieldOrder, field.TypeInt, value) + _node.Order = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(question.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.ModifiedAt(); ok { + _spec.SetField(question.FieldModifiedAt, field.TypeTime, value) + _node.ModifiedAt = value + } + if nodes := _c.mutation.HackathonIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.HackathonTable, + Columns: []string{question.HackathonColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hackathon.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.HackathonID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.CreatorIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.CreatorTable, + Columns: []string{question.CreatorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.user_created_questions = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ModifierIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.ModifierTable, + Columns: []string{question.ModifierColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.user_modified_questions = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.AnswersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: question.AnswersTable, + Columns: []string{question.AnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// QuestionCreateBulk is the builder for creating many Question entities in bulk. +type QuestionCreateBulk struct { + config + err error + builders []*QuestionCreate +} + +// Save creates the Question entities in the database. +func (_c *QuestionCreateBulk) Save(ctx context.Context) ([]*Question, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Question, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*QuestionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *QuestionCreateBulk) SaveX(ctx context.Context) []*Question { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *QuestionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *QuestionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/components/backend/ent/question_delete.go b/components/backend/ent/question_delete.go new file mode 100644 index 00000000..416d16aa --- /dev/null +++ b/components/backend/ent/question_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" +) + +// QuestionDelete is the builder for deleting a Question entity. +type QuestionDelete struct { + config + hooks []Hook + mutation *QuestionMutation +} + +// Where appends a list predicates to the QuestionDelete builder. +func (_d *QuestionDelete) Where(ps ...predicate.Question) *QuestionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *QuestionDelete) 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 *QuestionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *QuestionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(question.Table, sqlgraph.NewFieldSpec(question.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 +} + +// QuestionDeleteOne is the builder for deleting a single Question entity. +type QuestionDeleteOne struct { + _d *QuestionDelete +} + +// Where appends a list predicates to the QuestionDelete builder. +func (_d *QuestionDeleteOne) Where(ps ...predicate.Question) *QuestionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *QuestionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{question.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *QuestionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/components/backend/ent/question_query.go b/components/backend/ent/question_query.go new file mode 100644 index 00000000..ddd648cc --- /dev/null +++ b/components/backend/ent/question_query.go @@ -0,0 +1,839 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// QuestionQuery is the builder for querying Question entities. +type QuestionQuery struct { + config + ctx *QueryContext + order []question.OrderOption + inters []Interceptor + predicates []predicate.Question + withHackathon *HackathonQuery + withCreator *UserQuery + withModifier *UserQuery + withAnswers *AnswerQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the QuestionQuery builder. +func (_q *QuestionQuery) Where(ps ...predicate.Question) *QuestionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *QuestionQuery) Limit(limit int) *QuestionQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *QuestionQuery) Offset(offset int) *QuestionQuery { + _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 *QuestionQuery) Unique(unique bool) *QuestionQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *QuestionQuery) Order(o ...question.OrderOption) *QuestionQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryHackathon chains the current query on the "hackathon" edge. +func (_q *QuestionQuery) QueryHackathon() *HackathonQuery { + query := (&HackathonClient{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(question.Table, question.FieldID, selector), + sqlgraph.To(hackathon.Table, hackathon.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, question.HackathonTable, question.HackathonColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryCreator chains the current query on the "creator" edge. +func (_q *QuestionQuery) QueryCreator() *UserQuery { + query := (&UserClient{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(question.Table, question.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, question.CreatorTable, question.CreatorColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryModifier chains the current query on the "modifier" edge. +func (_q *QuestionQuery) QueryModifier() *UserQuery { + query := (&UserClient{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(question.Table, question.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, question.ModifierTable, question.ModifierColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryAnswers chains the current query on the "answers" edge. +func (_q *QuestionQuery) QueryAnswers() *AnswerQuery { + query := (&AnswerClient{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(question.Table, question.FieldID, selector), + sqlgraph.To(answer.Table, answer.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, question.AnswersTable, question.AnswersColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Question entity from the query. +// Returns a *NotFoundError when no Question was found. +func (_q *QuestionQuery) First(ctx context.Context) (*Question, 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{question.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *QuestionQuery) FirstX(ctx context.Context) *Question { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Question ID from the query. +// Returns a *NotFoundError when no Question ID was found. +func (_q *QuestionQuery) 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{question.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *QuestionQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Question entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Question entity is found. +// Returns a *NotFoundError when no Question entities are found. +func (_q *QuestionQuery) Only(ctx context.Context) (*Question, 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{question.Label} + default: + return nil, &NotSingularError{question.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *QuestionQuery) OnlyX(ctx context.Context) *Question { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Question ID in the query. +// Returns a *NotSingularError when more than one Question ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *QuestionQuery) 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{question.Label} + default: + err = &NotSingularError{question.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *QuestionQuery) 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 Questions. +func (_q *QuestionQuery) All(ctx context.Context) ([]*Question, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Question, *QuestionQuery]() + return withInterceptors[[]*Question](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *QuestionQuery) AllX(ctx context.Context) []*Question { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Question IDs. +func (_q *QuestionQuery) 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(question.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *QuestionQuery) 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 *QuestionQuery) 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[*QuestionQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *QuestionQuery) 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 *QuestionQuery) 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("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *QuestionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the QuestionQuery 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 *QuestionQuery) Clone() *QuestionQuery { + if _q == nil { + return nil + } + return &QuestionQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]question.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Question{}, _q.predicates...), + withHackathon: _q.withHackathon.Clone(), + withCreator: _q.withCreator.Clone(), + withModifier: _q.withModifier.Clone(), + withAnswers: _q.withAnswers.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithHackathon tells the query-builder to eager-load the nodes that are connected to +// the "hackathon" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *QuestionQuery) WithHackathon(opts ...func(*HackathonQuery)) *QuestionQuery { + query := (&HackathonClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withHackathon = query + return _q +} + +// WithCreator tells the query-builder to eager-load the nodes that are connected to +// the "creator" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *QuestionQuery) WithCreator(opts ...func(*UserQuery)) *QuestionQuery { + query := (&UserClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withCreator = query + return _q +} + +// WithModifier tells the query-builder to eager-load the nodes that are connected to +// the "modifier" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *QuestionQuery) WithModifier(opts ...func(*UserQuery)) *QuestionQuery { + query := (&UserClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withModifier = query + return _q +} + +// WithAnswers tells the query-builder to eager-load the nodes that are connected to +// the "answers" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *QuestionQuery) WithAnswers(opts ...func(*AnswerQuery)) *QuestionQuery { + query := (&AnswerClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withAnswers = 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 { +// HackathonID uuid.UUID `json:"hackathon_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Question.Query(). +// GroupBy(question.FieldHackathonID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *QuestionQuery) GroupBy(field string, fields ...string) *QuestionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &QuestionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = question.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 { +// HackathonID uuid.UUID `json:"hackathon_id,omitempty"` +// } +// +// client.Question.Query(). +// Select(question.FieldHackathonID). +// Scan(ctx, &v) +func (_q *QuestionQuery) Select(fields ...string) *QuestionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &QuestionSelect{QuestionQuery: _q} + sbuild.label = question.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a QuestionSelect configured with the given aggregations. +func (_q *QuestionQuery) Aggregate(fns ...AggregateFunc) *QuestionSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *QuestionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !question.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: 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 *QuestionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Question, error) { + var ( + nodes = []*Question{} + withFKs = _q.withFKs + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withHackathon != nil, + _q.withCreator != nil, + _q.withModifier != nil, + _q.withAnswers != nil, + } + ) + if _q.withCreator != nil || _q.withModifier != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, question.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Question).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Question{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + 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.withHackathon; query != nil { + if err := _q.loadHackathon(ctx, query, nodes, nil, + func(n *Question, e *Hackathon) { n.Edges.Hackathon = e }); err != nil { + return nil, err + } + } + if query := _q.withCreator; query != nil { + if err := _q.loadCreator(ctx, query, nodes, nil, + func(n *Question, e *User) { n.Edges.Creator = e }); err != nil { + return nil, err + } + } + if query := _q.withModifier; query != nil { + if err := _q.loadModifier(ctx, query, nodes, nil, + func(n *Question, e *User) { n.Edges.Modifier = e }); err != nil { + return nil, err + } + } + if query := _q.withAnswers; query != nil { + if err := _q.loadAnswers(ctx, query, nodes, + func(n *Question) { n.Edges.Answers = []*Answer{} }, + func(n *Question, e *Answer) { n.Edges.Answers = append(n.Edges.Answers, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *QuestionQuery) loadHackathon(ctx context.Context, query *HackathonQuery, nodes []*Question, init func(*Question), assign func(*Question, *Hackathon)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Question) + for i := range nodes { + fk := nodes[i].HackathonID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(hackathon.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 "hackathon_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *QuestionQuery) loadCreator(ctx context.Context, query *UserQuery, nodes []*Question, init func(*Question), assign func(*Question, *User)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Question) + for i := range nodes { + if nodes[i].user_created_questions == nil { + continue + } + fk := *nodes[i].user_created_questions + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "user_created_questions" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *QuestionQuery) loadModifier(ctx context.Context, query *UserQuery, nodes []*Question, init func(*Question), assign func(*Question, *User)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Question) + for i := range nodes { + if nodes[i].user_modified_questions == nil { + continue + } + fk := *nodes[i].user_modified_questions + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "user_modified_questions" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *QuestionQuery) loadAnswers(ctx context.Context, query *AnswerQuery, nodes []*Question, init func(*Question), assign func(*Question, *Answer)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Question) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(answer.FieldQuestionID) + } + query.Where(predicate.Answer(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(question.AnswersColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.QuestionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "question_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *QuestionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _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 *QuestionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(question.Table, question.Columns, sqlgraph.NewFieldSpec(question.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, question.FieldID) + for i := range fields { + if fields[i] != question.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withHackathon != nil { + _spec.Node.AddColumnOnce(question.FieldHackathonID) + } + } + 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 *QuestionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(question.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = question.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 _, 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 +} + +// QuestionGroupBy is the group-by builder for Question entities. +type QuestionGroupBy struct { + selector + build *QuestionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *QuestionGroupBy) Aggregate(fns ...AggregateFunc) *QuestionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *QuestionGroupBy) 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[*QuestionQuery, *QuestionGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *QuestionGroupBy) sqlScan(ctx context.Context, root *QuestionQuery, 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) +} + +// QuestionSelect is the builder for selecting fields of Question entities. +type QuestionSelect struct { + *QuestionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *QuestionSelect) Aggregate(fns ...AggregateFunc) *QuestionSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *QuestionSelect) 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[*QuestionQuery, *QuestionSelect](ctx, _s.QuestionQuery, _s, _s.inters, v) +} + +func (_s *QuestionSelect) sqlScan(ctx context.Context, root *QuestionQuery, 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) +} diff --git a/components/backend/ent/question_update.go b/components/backend/ent/question_update.go new file mode 100644 index 00000000..f66fb89b --- /dev/null +++ b/components/backend/ent/question_update.go @@ -0,0 +1,822 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/user" +) + +// QuestionUpdate is the builder for updating Question entities. +type QuestionUpdate struct { + config + hooks []Hook + mutation *QuestionMutation +} + +// Where appends a list predicates to the QuestionUpdate builder. +func (_u *QuestionUpdate) Where(ps ...predicate.Question) *QuestionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetHackathonID sets the "hackathon_id" field. +func (_u *QuestionUpdate) SetHackathonID(v uuid.UUID) *QuestionUpdate { + _u.mutation.SetHackathonID(v) + return _u +} + +// SetNillableHackathonID sets the "hackathon_id" field if the given value is not nil. +func (_u *QuestionUpdate) SetNillableHackathonID(v *uuid.UUID) *QuestionUpdate { + if v != nil { + _u.SetHackathonID(*v) + } + return _u +} + +// SetKey sets the "key" field. +func (_u *QuestionUpdate) SetKey(v string) *QuestionUpdate { + _u.mutation.SetKey(v) + return _u +} + +// SetNillableKey sets the "key" field if the given value is not nil. +func (_u *QuestionUpdate) SetNillableKey(v *string) *QuestionUpdate { + if v != nil { + _u.SetKey(*v) + } + return _u +} + +// SetLabel sets the "label" field. +func (_u *QuestionUpdate) SetLabel(v string) *QuestionUpdate { + _u.mutation.SetLabel(v) + return _u +} + +// SetNillableLabel sets the "label" field if the given value is not nil. +func (_u *QuestionUpdate) SetNillableLabel(v *string) *QuestionUpdate { + if v != nil { + _u.SetLabel(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *QuestionUpdate) SetType(v question.Type) *QuestionUpdate { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *QuestionUpdate) SetNillableType(v *question.Type) *QuestionUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetMandatory sets the "mandatory" field. +func (_u *QuestionUpdate) SetMandatory(v bool) *QuestionUpdate { + _u.mutation.SetMandatory(v) + return _u +} + +// SetNillableMandatory sets the "mandatory" field if the given value is not nil. +func (_u *QuestionUpdate) SetNillableMandatory(v *bool) *QuestionUpdate { + if v != nil { + _u.SetMandatory(*v) + } + return _u +} + +// SetOrder sets the "order" field. +func (_u *QuestionUpdate) SetOrder(v int) *QuestionUpdate { + _u.mutation.ResetOrder() + _u.mutation.SetOrder(v) + return _u +} + +// SetNillableOrder sets the "order" field if the given value is not nil. +func (_u *QuestionUpdate) SetNillableOrder(v *int) *QuestionUpdate { + if v != nil { + _u.SetOrder(*v) + } + return _u +} + +// AddOrder adds value to the "order" field. +func (_u *QuestionUpdate) AddOrder(v int) *QuestionUpdate { + _u.mutation.AddOrder(v) + return _u +} + +// SetModifiedAt sets the "modified_at" field. +func (_u *QuestionUpdate) SetModifiedAt(v time.Time) *QuestionUpdate { + _u.mutation.SetModifiedAt(v) + return _u +} + +// SetHackathon sets the "hackathon" edge to the Hackathon entity. +func (_u *QuestionUpdate) SetHackathon(v *Hackathon) *QuestionUpdate { + return _u.SetHackathonID(v.ID) +} + +// SetModifierID sets the "modifier" edge to the User entity by ID. +func (_u *QuestionUpdate) SetModifierID(id uuid.UUID) *QuestionUpdate { + _u.mutation.SetModifierID(id) + return _u +} + +// SetModifier sets the "modifier" edge to the User entity. +func (_u *QuestionUpdate) SetModifier(v *User) *QuestionUpdate { + return _u.SetModifierID(v.ID) +} + +// AddAnswerIDs adds the "answers" edge to the Answer entity by IDs. +func (_u *QuestionUpdate) AddAnswerIDs(ids ...uuid.UUID) *QuestionUpdate { + _u.mutation.AddAnswerIDs(ids...) + return _u +} + +// AddAnswers adds the "answers" edges to the Answer entity. +func (_u *QuestionUpdate) AddAnswers(v ...*Answer) *QuestionUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddAnswerIDs(ids...) +} + +// Mutation returns the QuestionMutation object of the builder. +func (_u *QuestionUpdate) Mutation() *QuestionMutation { + return _u.mutation +} + +// ClearHackathon clears the "hackathon" edge to the Hackathon entity. +func (_u *QuestionUpdate) ClearHackathon() *QuestionUpdate { + _u.mutation.ClearHackathon() + return _u +} + +// ClearModifier clears the "modifier" edge to the User entity. +func (_u *QuestionUpdate) ClearModifier() *QuestionUpdate { + _u.mutation.ClearModifier() + return _u +} + +// ClearAnswers clears all "answers" edges to the Answer entity. +func (_u *QuestionUpdate) ClearAnswers() *QuestionUpdate { + _u.mutation.ClearAnswers() + return _u +} + +// RemoveAnswerIDs removes the "answers" edge to Answer entities by IDs. +func (_u *QuestionUpdate) RemoveAnswerIDs(ids ...uuid.UUID) *QuestionUpdate { + _u.mutation.RemoveAnswerIDs(ids...) + return _u +} + +// RemoveAnswers removes "answers" edges to Answer entities. +func (_u *QuestionUpdate) RemoveAnswers(v ...*Answer) *QuestionUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveAnswerIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *QuestionUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *QuestionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *QuestionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *QuestionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *QuestionUpdate) defaults() { + if _, ok := _u.mutation.ModifiedAt(); !ok { + v := question.UpdateDefaultModifiedAt() + _u.mutation.SetModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *QuestionUpdate) check() error { + if v, ok := _u.mutation.Key(); ok { + if err := question.KeyValidator(v); err != nil { + return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Question.key": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := question.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Question.type": %w`, err)} + } + } + if _u.mutation.HackathonCleared() && len(_u.mutation.HackathonIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Question.hackathon"`) + } + if _u.mutation.CreatorCleared() && len(_u.mutation.CreatorIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Question.creator"`) + } + if _u.mutation.ModifierCleared() && len(_u.mutation.ModifierIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Question.modifier"`) + } + return nil +} + +func (_u *QuestionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(question.Table, question.Columns, sqlgraph.NewFieldSpec(question.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.Key(); ok { + _spec.SetField(question.FieldKey, field.TypeString, value) + } + if value, ok := _u.mutation.Label(); ok { + _spec.SetField(question.FieldLabel, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(question.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.Mandatory(); ok { + _spec.SetField(question.FieldMandatory, field.TypeBool, value) + } + if value, ok := _u.mutation.Order(); ok { + _spec.SetField(question.FieldOrder, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedOrder(); ok { + _spec.AddField(question.FieldOrder, field.TypeInt, value) + } + if value, ok := _u.mutation.ModifiedAt(); ok { + _spec.SetField(question.FieldModifiedAt, field.TypeTime, value) + } + if _u.mutation.HackathonCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.HackathonTable, + Columns: []string{question.HackathonColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hackathon.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.HackathonIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.HackathonTable, + Columns: []string{question.HackathonColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hackathon.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.ModifierCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.ModifierTable, + Columns: []string{question.ModifierColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ModifierIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.ModifierTable, + Columns: []string{question.ModifierColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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.AnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: question.AnswersTable, + Columns: []string{question.AnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedAnswersIDs(); len(nodes) > 0 && !_u.mutation.AnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: question.AnswersTable, + Columns: []string{question.AnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AnswersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: question.AnswersTable, + Columns: []string{question.AnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{question.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// QuestionUpdateOne is the builder for updating a single Question entity. +type QuestionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *QuestionMutation +} + +// SetHackathonID sets the "hackathon_id" field. +func (_u *QuestionUpdateOne) SetHackathonID(v uuid.UUID) *QuestionUpdateOne { + _u.mutation.SetHackathonID(v) + return _u +} + +// SetNillableHackathonID sets the "hackathon_id" field if the given value is not nil. +func (_u *QuestionUpdateOne) SetNillableHackathonID(v *uuid.UUID) *QuestionUpdateOne { + if v != nil { + _u.SetHackathonID(*v) + } + return _u +} + +// SetKey sets the "key" field. +func (_u *QuestionUpdateOne) SetKey(v string) *QuestionUpdateOne { + _u.mutation.SetKey(v) + return _u +} + +// SetNillableKey sets the "key" field if the given value is not nil. +func (_u *QuestionUpdateOne) SetNillableKey(v *string) *QuestionUpdateOne { + if v != nil { + _u.SetKey(*v) + } + return _u +} + +// SetLabel sets the "label" field. +func (_u *QuestionUpdateOne) SetLabel(v string) *QuestionUpdateOne { + _u.mutation.SetLabel(v) + return _u +} + +// SetNillableLabel sets the "label" field if the given value is not nil. +func (_u *QuestionUpdateOne) SetNillableLabel(v *string) *QuestionUpdateOne { + if v != nil { + _u.SetLabel(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *QuestionUpdateOne) SetType(v question.Type) *QuestionUpdateOne { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *QuestionUpdateOne) SetNillableType(v *question.Type) *QuestionUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetMandatory sets the "mandatory" field. +func (_u *QuestionUpdateOne) SetMandatory(v bool) *QuestionUpdateOne { + _u.mutation.SetMandatory(v) + return _u +} + +// SetNillableMandatory sets the "mandatory" field if the given value is not nil. +func (_u *QuestionUpdateOne) SetNillableMandatory(v *bool) *QuestionUpdateOne { + if v != nil { + _u.SetMandatory(*v) + } + return _u +} + +// SetOrder sets the "order" field. +func (_u *QuestionUpdateOne) SetOrder(v int) *QuestionUpdateOne { + _u.mutation.ResetOrder() + _u.mutation.SetOrder(v) + return _u +} + +// SetNillableOrder sets the "order" field if the given value is not nil. +func (_u *QuestionUpdateOne) SetNillableOrder(v *int) *QuestionUpdateOne { + if v != nil { + _u.SetOrder(*v) + } + return _u +} + +// AddOrder adds value to the "order" field. +func (_u *QuestionUpdateOne) AddOrder(v int) *QuestionUpdateOne { + _u.mutation.AddOrder(v) + return _u +} + +// SetModifiedAt sets the "modified_at" field. +func (_u *QuestionUpdateOne) SetModifiedAt(v time.Time) *QuestionUpdateOne { + _u.mutation.SetModifiedAt(v) + return _u +} + +// SetHackathon sets the "hackathon" edge to the Hackathon entity. +func (_u *QuestionUpdateOne) SetHackathon(v *Hackathon) *QuestionUpdateOne { + return _u.SetHackathonID(v.ID) +} + +// SetModifierID sets the "modifier" edge to the User entity by ID. +func (_u *QuestionUpdateOne) SetModifierID(id uuid.UUID) *QuestionUpdateOne { + _u.mutation.SetModifierID(id) + return _u +} + +// SetModifier sets the "modifier" edge to the User entity. +func (_u *QuestionUpdateOne) SetModifier(v *User) *QuestionUpdateOne { + return _u.SetModifierID(v.ID) +} + +// AddAnswerIDs adds the "answers" edge to the Answer entity by IDs. +func (_u *QuestionUpdateOne) AddAnswerIDs(ids ...uuid.UUID) *QuestionUpdateOne { + _u.mutation.AddAnswerIDs(ids...) + return _u +} + +// AddAnswers adds the "answers" edges to the Answer entity. +func (_u *QuestionUpdateOne) AddAnswers(v ...*Answer) *QuestionUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddAnswerIDs(ids...) +} + +// Mutation returns the QuestionMutation object of the builder. +func (_u *QuestionUpdateOne) Mutation() *QuestionMutation { + return _u.mutation +} + +// ClearHackathon clears the "hackathon" edge to the Hackathon entity. +func (_u *QuestionUpdateOne) ClearHackathon() *QuestionUpdateOne { + _u.mutation.ClearHackathon() + return _u +} + +// ClearModifier clears the "modifier" edge to the User entity. +func (_u *QuestionUpdateOne) ClearModifier() *QuestionUpdateOne { + _u.mutation.ClearModifier() + return _u +} + +// ClearAnswers clears all "answers" edges to the Answer entity. +func (_u *QuestionUpdateOne) ClearAnswers() *QuestionUpdateOne { + _u.mutation.ClearAnswers() + return _u +} + +// RemoveAnswerIDs removes the "answers" edge to Answer entities by IDs. +func (_u *QuestionUpdateOne) RemoveAnswerIDs(ids ...uuid.UUID) *QuestionUpdateOne { + _u.mutation.RemoveAnswerIDs(ids...) + return _u +} + +// RemoveAnswers removes "answers" edges to Answer entities. +func (_u *QuestionUpdateOne) RemoveAnswers(v ...*Answer) *QuestionUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveAnswerIDs(ids...) +} + +// Where appends a list predicates to the QuestionUpdate builder. +func (_u *QuestionUpdateOne) Where(ps ...predicate.Question) *QuestionUpdateOne { + _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 *QuestionUpdateOne) Select(field string, fields ...string) *QuestionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated Question entity. +func (_u *QuestionUpdateOne) Save(ctx context.Context) (*Question, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *QuestionUpdateOne) SaveX(ctx context.Context) *Question { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *QuestionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *QuestionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *QuestionUpdateOne) defaults() { + if _, ok := _u.mutation.ModifiedAt(); !ok { + v := question.UpdateDefaultModifiedAt() + _u.mutation.SetModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *QuestionUpdateOne) check() error { + if v, ok := _u.mutation.Key(); ok { + if err := question.KeyValidator(v); err != nil { + return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Question.key": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := question.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Question.type": %w`, err)} + } + } + if _u.mutation.HackathonCleared() && len(_u.mutation.HackathonIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Question.hackathon"`) + } + if _u.mutation.CreatorCleared() && len(_u.mutation.CreatorIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Question.creator"`) + } + if _u.mutation.ModifierCleared() && len(_u.mutation.ModifierIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Question.modifier"`) + } + return nil +} + +func (_u *QuestionUpdateOne) sqlSave(ctx context.Context) (_node *Question, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(question.Table, question.Columns, sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Question.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, question.FieldID) + for _, f := range fields { + if !question.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != question.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.Key(); ok { + _spec.SetField(question.FieldKey, field.TypeString, value) + } + if value, ok := _u.mutation.Label(); ok { + _spec.SetField(question.FieldLabel, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(question.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.Mandatory(); ok { + _spec.SetField(question.FieldMandatory, field.TypeBool, value) + } + if value, ok := _u.mutation.Order(); ok { + _spec.SetField(question.FieldOrder, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedOrder(); ok { + _spec.AddField(question.FieldOrder, field.TypeInt, value) + } + if value, ok := _u.mutation.ModifiedAt(); ok { + _spec.SetField(question.FieldModifiedAt, field.TypeTime, value) + } + if _u.mutation.HackathonCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.HackathonTable, + Columns: []string{question.HackathonColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hackathon.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.HackathonIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.HackathonTable, + Columns: []string{question.HackathonColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hackathon.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.ModifierCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.ModifierTable, + Columns: []string{question.ModifierColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ModifierIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: question.ModifierTable, + Columns: []string{question.ModifierColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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.AnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: question.AnswersTable, + Columns: []string{question.AnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedAnswersIDs(); len(nodes) > 0 && !_u.mutation.AnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: question.AnswersTable, + Columns: []string{question.AnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AnswersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: question.AnswersTable, + Columns: []string{question.AnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Question{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{question.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/components/backend/ent/runtime/runtime.go b/components/backend/ent/runtime/runtime.go index 6f344175..596680ac 100644 --- a/components/backend/ent/runtime/runtime.go +++ b/components/backend/ent/runtime/runtime.go @@ -7,12 +7,14 @@ import ( "github.com/google/uuid" "github.com/swissdatasciencecenter/hackagon/components/backend/db/schema" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathonstate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/participant" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/submission" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/team" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/teamparticipant" @@ -27,6 +29,25 @@ import ( // (default values, validators, hooks and policies) and stitches it // to their package variables. func init() { + answerMixin := schema.Answer{}.Mixin() + answerMixinFields0 := answerMixin[0].Fields() + _ = answerMixinFields0 + answerFields := schema.Answer{}.Fields() + _ = answerFields + // answerDescCreatedAt is the schema descriptor for created_at field. + answerDescCreatedAt := answerFields[4].Descriptor() + // answer.DefaultCreatedAt holds the default value on creation for the created_at field. + answer.DefaultCreatedAt = answerDescCreatedAt.Default.(func() time.Time) + // answerDescUpdatedAt is the schema descriptor for updated_at field. + answerDescUpdatedAt := answerFields[5].Descriptor() + // answer.DefaultUpdatedAt holds the default value on creation for the updated_at field. + answer.DefaultUpdatedAt = answerDescUpdatedAt.Default.(func() time.Time) + // answer.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + answer.UpdateDefaultUpdatedAt = answerDescUpdatedAt.UpdateDefault.(func() time.Time) + // answerDescID is the schema descriptor for id field. + answerDescID := answerMixinFields0[0].Descriptor() + // answer.DefaultID holds the default value on creation for the id field. + answer.DefaultID = answerDescID.Default.(func() uuid.UUID) hackathonMixin := schema.Hackathon{}.Mixin() hackathonMixinFields0 := hackathonMixin[0].Fields() _ = hackathonMixinFields0 @@ -176,6 +197,37 @@ func init() { projectDescID := projectMixinFields0[0].Descriptor() // project.DefaultID holds the default value on creation for the id field. project.DefaultID = projectDescID.Default.(func() uuid.UUID) + questionMixin := schema.Question{}.Mixin() + questionMixinFields0 := questionMixin[0].Fields() + _ = questionMixinFields0 + questionFields := schema.Question{}.Fields() + _ = questionFields + // questionDescKey is the schema descriptor for key field. + questionDescKey := questionFields[1].Descriptor() + // question.KeyValidator is a validator for the "key" field. It is called by the builders before save. + question.KeyValidator = questionDescKey.Validators[0].(func(string) error) + // questionDescMandatory is the schema descriptor for mandatory field. + questionDescMandatory := questionFields[4].Descriptor() + // question.DefaultMandatory holds the default value on creation for the mandatory field. + question.DefaultMandatory = questionDescMandatory.Default.(bool) + // questionDescOrder is the schema descriptor for order field. + questionDescOrder := questionFields[5].Descriptor() + // question.DefaultOrder holds the default value on creation for the order field. + question.DefaultOrder = questionDescOrder.Default.(int) + // questionDescCreatedAt is the schema descriptor for created_at field. + questionDescCreatedAt := questionFields[6].Descriptor() + // question.DefaultCreatedAt holds the default value on creation for the created_at field. + question.DefaultCreatedAt = questionDescCreatedAt.Default.(func() time.Time) + // questionDescModifiedAt is the schema descriptor for modified_at field. + questionDescModifiedAt := questionFields[7].Descriptor() + // question.DefaultModifiedAt holds the default value on creation for the modified_at field. + question.DefaultModifiedAt = questionDescModifiedAt.Default.(func() time.Time) + // question.UpdateDefaultModifiedAt holds the default value on update for the modified_at field. + question.UpdateDefaultModifiedAt = questionDescModifiedAt.UpdateDefault.(func() time.Time) + // questionDescID is the schema descriptor for id field. + questionDescID := questionMixinFields0[0].Descriptor() + // question.DefaultID holds the default value on creation for the id field. + question.DefaultID = questionDescID.Default.(func() uuid.UUID) submissionMixin := schema.Submission{}.Mixin() submissionMixinFields0 := submissionMixin[0].Fields() _ = submissionMixinFields0 diff --git a/components/backend/ent/tx.go b/components/backend/ent/tx.go index fea0706b..5be9666c 100644 --- a/components/backend/ent/tx.go +++ b/components/backend/ent/tx.go @@ -12,6 +12,8 @@ import ( // Tx is a transactional client that is created by calling Client.Tx(). type Tx struct { config + // Answer is the client for interacting with the Answer builders. + Answer *AnswerClient // Hackathon is the client for interacting with the Hackathon builders. Hackathon *HackathonClient // HackathonState is the client for interacting with the HackathonState builders. @@ -24,6 +26,8 @@ type Tx struct { Phase *PhaseClient // Project is the client for interacting with the Project builders. Project *ProjectClient + // Question is the client for interacting with the Question builders. + Question *QuestionClient // Submission is the client for interacting with the Submission builders. Submission *SubmissionClient // Team is the client for interacting with the Team builders. @@ -171,12 +175,14 @@ func (tx *Tx) Client() *Client { } func (tx *Tx) init() { + tx.Answer = NewAnswerClient(tx.config) tx.Hackathon = NewHackathonClient(tx.config) tx.HackathonState = NewHackathonStateClient(tx.config) tx.Page = NewPageClient(tx.config) tx.Participant = NewParticipantClient(tx.config) tx.Phase = NewPhaseClient(tx.config) tx.Project = NewProjectClient(tx.config) + tx.Question = NewQuestionClient(tx.config) tx.Submission = NewSubmissionClient(tx.config) tx.Team = NewTeamClient(tx.config) tx.TeamParticipant = NewTeamParticipantClient(tx.config) @@ -194,7 +200,7 @@ func (tx *Tx) init() { // of them in order to commit or rollback the transaction. // // If a closed transaction is embedded in one of the generated entities, and the entity -// applies a query, for example: Hackathon.QueryXXX(), the query will be executed +// applies a query, for example: Answer.QueryXXX(), the query will be executed // through the driver which created this transaction. // // Note that txDriver is not goroutine safe. diff --git a/components/backend/ent/user.go b/components/backend/ent/user.go index 7f32109f..63a1270d 100644 --- a/components/backend/ent/user.go +++ b/components/backend/ent/user.go @@ -70,6 +70,12 @@ type UserEdges struct { CreatedTracks []*Track `json:"created_tracks,omitempty"` // Tracks this user last modified. ModifiedTracks []*Track `json:"modified_tracks,omitempty"` + // Registration questions this user created. + CreatedQuestions []*Question `json:"created_questions,omitempty"` + // Registration questions this user last modified. + ModifiedQuestions []*Question `json:"modified_questions,omitempty"` + // Registration answers this user submitted. + CreatedAnswers []*Answer `json:"created_answers,omitempty"` // Hackathon settings this user last modified. ModifiedStates []*HackathonState `json:"modified_states,omitempty"` // Projects this user has marked as preferred. @@ -86,7 +92,7 @@ type UserEdges struct { TeamParticipations []*TeamParticipant `json:"team_participations,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [23]bool + loadedTypes [26]bool } // CreatedHackathonsOrErr returns the CreatedHackathons value or an error if the edge @@ -233,10 +239,37 @@ func (e UserEdges) ModifiedTracksOrErr() ([]*Track, error) { return nil, &NotLoadedError{edge: "modified_tracks"} } +// CreatedQuestionsOrErr returns the CreatedQuestions value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) CreatedQuestionsOrErr() ([]*Question, error) { + if e.loadedTypes[16] { + return e.CreatedQuestions, nil + } + return nil, &NotLoadedError{edge: "created_questions"} +} + +// ModifiedQuestionsOrErr returns the ModifiedQuestions value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) ModifiedQuestionsOrErr() ([]*Question, error) { + if e.loadedTypes[17] { + return e.ModifiedQuestions, nil + } + return nil, &NotLoadedError{edge: "modified_questions"} +} + +// CreatedAnswersOrErr returns the CreatedAnswers value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) CreatedAnswersOrErr() ([]*Answer, error) { + if e.loadedTypes[18] { + return e.CreatedAnswers, nil + } + return nil, &NotLoadedError{edge: "created_answers"} +} + // ModifiedStatesOrErr returns the ModifiedStates value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) ModifiedStatesOrErr() ([]*HackathonState, error) { - if e.loadedTypes[16] { + if e.loadedTypes[19] { return e.ModifiedStates, nil } return nil, &NotLoadedError{edge: "modified_states"} @@ -245,7 +278,7 @@ func (e UserEdges) ModifiedStatesOrErr() ([]*HackathonState, error) { // PreferredProjectsOrErr returns the PreferredProjects value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) PreferredProjectsOrErr() ([]*Project, error) { - if e.loadedTypes[17] { + if e.loadedTypes[20] { return e.PreferredProjects, nil } return nil, &NotLoadedError{edge: "preferred_projects"} @@ -254,7 +287,7 @@ func (e UserEdges) PreferredProjectsOrErr() ([]*Project, error) { // VotesOrErr returns the Votes value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) VotesOrErr() ([]*Vote, error) { - if e.loadedTypes[18] { + if e.loadedTypes[21] { return e.Votes, nil } return nil, &NotLoadedError{edge: "votes"} @@ -263,7 +296,7 @@ func (e UserEdges) VotesOrErr() ([]*Vote, error) { // JuryCategoriesOrErr returns the JuryCategories value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) JuryCategoriesOrErr() ([]*VoteCategory, error) { - if e.loadedTypes[19] { + if e.loadedTypes[22] { return e.JuryCategories, nil } return nil, &NotLoadedError{edge: "jury_categories"} @@ -272,7 +305,7 @@ func (e UserEdges) JuryCategoriesOrErr() ([]*VoteCategory, error) { // OwnsOrErr returns the Owns value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) OwnsOrErr() ([]*Hackathon, error) { - if e.loadedTypes[20] { + if e.loadedTypes[23] { return e.Owns, nil } return nil, &NotLoadedError{edge: "owns"} @@ -281,7 +314,7 @@ func (e UserEdges) OwnsOrErr() ([]*Hackathon, error) { // ParticipationsOrErr returns the Participations value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) ParticipationsOrErr() ([]*Participant, error) { - if e.loadedTypes[21] { + if e.loadedTypes[24] { return e.Participations, nil } return nil, &NotLoadedError{edge: "participations"} @@ -290,7 +323,7 @@ func (e UserEdges) ParticipationsOrErr() ([]*Participant, error) { // TeamParticipationsOrErr returns the TeamParticipations value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) TeamParticipationsOrErr() ([]*TeamParticipant, error) { - if e.loadedTypes[22] { + if e.loadedTypes[25] { return e.TeamParticipations, nil } return nil, &NotLoadedError{edge: "team_participations"} @@ -457,6 +490,21 @@ func (_m *User) QueryModifiedTracks() *TrackQuery { return NewUserClient(_m.config).QueryModifiedTracks(_m) } +// QueryCreatedQuestions queries the "created_questions" edge of the User entity. +func (_m *User) QueryCreatedQuestions() *QuestionQuery { + return NewUserClient(_m.config).QueryCreatedQuestions(_m) +} + +// QueryModifiedQuestions queries the "modified_questions" edge of the User entity. +func (_m *User) QueryModifiedQuestions() *QuestionQuery { + return NewUserClient(_m.config).QueryModifiedQuestions(_m) +} + +// QueryCreatedAnswers queries the "created_answers" edge of the User entity. +func (_m *User) QueryCreatedAnswers() *AnswerQuery { + return NewUserClient(_m.config).QueryCreatedAnswers(_m) +} + // QueryModifiedStates queries the "modified_states" edge of the User entity. func (_m *User) QueryModifiedStates() *HackathonStateQuery { return NewUserClient(_m.config).QueryModifiedStates(_m) diff --git a/components/backend/ent/user/user.go b/components/backend/ent/user/user.go index 696f84ba..a1b8770b 100644 --- a/components/backend/ent/user/user.go +++ b/components/backend/ent/user/user.go @@ -59,6 +59,12 @@ const ( EdgeCreatedTracks = "created_tracks" // EdgeModifiedTracks holds the string denoting the modified_tracks edge name in mutations. EdgeModifiedTracks = "modified_tracks" + // EdgeCreatedQuestions holds the string denoting the created_questions edge name in mutations. + EdgeCreatedQuestions = "created_questions" + // EdgeModifiedQuestions holds the string denoting the modified_questions edge name in mutations. + EdgeModifiedQuestions = "modified_questions" + // EdgeCreatedAnswers holds the string denoting the created_answers edge name in mutations. + EdgeCreatedAnswers = "created_answers" // EdgeModifiedStates holds the string denoting the modified_states edge name in mutations. EdgeModifiedStates = "modified_states" // EdgePreferredProjects holds the string denoting the preferred_projects edge name in mutations. @@ -183,6 +189,27 @@ const ( ModifiedTracksInverseTable = "tracks" // ModifiedTracksColumn is the table column denoting the modified_tracks relation/edge. ModifiedTracksColumn = "user_modified_tracks" + // CreatedQuestionsTable is the table that holds the created_questions relation/edge. + CreatedQuestionsTable = "questions" + // CreatedQuestionsInverseTable is the table name for the Question entity. + // It exists in this package in order to avoid circular dependency with the "question" package. + CreatedQuestionsInverseTable = "questions" + // CreatedQuestionsColumn is the table column denoting the created_questions relation/edge. + CreatedQuestionsColumn = "user_created_questions" + // ModifiedQuestionsTable is the table that holds the modified_questions relation/edge. + ModifiedQuestionsTable = "questions" + // ModifiedQuestionsInverseTable is the table name for the Question entity. + // It exists in this package in order to avoid circular dependency with the "question" package. + ModifiedQuestionsInverseTable = "questions" + // ModifiedQuestionsColumn is the table column denoting the modified_questions relation/edge. + ModifiedQuestionsColumn = "user_modified_questions" + // CreatedAnswersTable is the table that holds the created_answers relation/edge. + CreatedAnswersTable = "answers" + // CreatedAnswersInverseTable is the table name for the Answer entity. + // It exists in this package in order to avoid circular dependency with the "answer" package. + CreatedAnswersInverseTable = "answers" + // CreatedAnswersColumn is the table column denoting the created_answers relation/edge. + CreatedAnswersColumn = "user_id" // ModifiedStatesTable is the table that holds the modified_states relation/edge. ModifiedStatesTable = "hackathon_states" // ModifiedStatesInverseTable is the table name for the HackathonState entity. @@ -546,6 +573,48 @@ func ByModifiedTracks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// ByCreatedQuestionsCount orders the results by created_questions count. +func ByCreatedQuestionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newCreatedQuestionsStep(), opts...) + } +} + +// ByCreatedQuestions orders the results by created_questions terms. +func ByCreatedQuestions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newCreatedQuestionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByModifiedQuestionsCount orders the results by modified_questions count. +func ByModifiedQuestionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModifiedQuestionsStep(), opts...) + } +} + +// ByModifiedQuestions orders the results by modified_questions terms. +func ByModifiedQuestions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModifiedQuestionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByCreatedAnswersCount orders the results by created_answers count. +func ByCreatedAnswersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newCreatedAnswersStep(), opts...) + } +} + +// ByCreatedAnswers orders the results by created_answers terms. +func ByCreatedAnswers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newCreatedAnswersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByModifiedStatesCount orders the results by modified_states count. func ByModifiedStatesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -755,6 +824,27 @@ func newModifiedTracksStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, ModifiedTracksTable, ModifiedTracksColumn), ) } +func newCreatedQuestionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(CreatedQuestionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, CreatedQuestionsTable, CreatedQuestionsColumn), + ) +} +func newModifiedQuestionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModifiedQuestionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ModifiedQuestionsTable, ModifiedQuestionsColumn), + ) +} +func newCreatedAnswersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(CreatedAnswersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, CreatedAnswersTable, CreatedAnswersColumn), + ) +} func newModifiedStatesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/components/backend/ent/user/where.go b/components/backend/ent/user/where.go index 9f35050a..ec738d42 100644 --- a/components/backend/ent/user/where.go +++ b/components/backend/ent/user/where.go @@ -814,6 +814,75 @@ func HasModifiedTracksWith(preds ...predicate.Track) predicate.User { }) } +// HasCreatedQuestions applies the HasEdge predicate on the "created_questions" edge. +func HasCreatedQuestions() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, CreatedQuestionsTable, CreatedQuestionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasCreatedQuestionsWith applies the HasEdge predicate on the "created_questions" edge with a given conditions (other predicates). +func HasCreatedQuestionsWith(preds ...predicate.Question) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newCreatedQuestionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasModifiedQuestions applies the HasEdge predicate on the "modified_questions" edge. +func HasModifiedQuestions() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ModifiedQuestionsTable, ModifiedQuestionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModifiedQuestionsWith applies the HasEdge predicate on the "modified_questions" edge with a given conditions (other predicates). +func HasModifiedQuestionsWith(preds ...predicate.Question) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newModifiedQuestionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasCreatedAnswers applies the HasEdge predicate on the "created_answers" edge. +func HasCreatedAnswers() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, CreatedAnswersTable, CreatedAnswersColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasCreatedAnswersWith applies the HasEdge predicate on the "created_answers" edge with a given conditions (other predicates). +func HasCreatedAnswersWith(preds ...predicate.Answer) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newCreatedAnswersStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasModifiedStates applies the HasEdge predicate on the "modified_states" edge. func HasModifiedStates() predicate.User { return predicate.User(func(s *sql.Selector) { diff --git a/components/backend/ent/user_create.go b/components/backend/ent/user_create.go index 2295bc5c..86fdb28f 100644 --- a/components/backend/ent/user_create.go +++ b/components/backend/ent/user_create.go @@ -11,11 +11,13 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathonstate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/submission" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/team" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/track" @@ -353,6 +355,51 @@ func (_c *UserCreate) AddModifiedTracks(v ...*Track) *UserCreate { return _c.AddModifiedTrackIDs(ids...) } +// AddCreatedQuestionIDs adds the "created_questions" edge to the Question entity by IDs. +func (_c *UserCreate) AddCreatedQuestionIDs(ids ...uuid.UUID) *UserCreate { + _c.mutation.AddCreatedQuestionIDs(ids...) + return _c +} + +// AddCreatedQuestions adds the "created_questions" edges to the Question entity. +func (_c *UserCreate) AddCreatedQuestions(v ...*Question) *UserCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddCreatedQuestionIDs(ids...) +} + +// AddModifiedQuestionIDs adds the "modified_questions" edge to the Question entity by IDs. +func (_c *UserCreate) AddModifiedQuestionIDs(ids ...uuid.UUID) *UserCreate { + _c.mutation.AddModifiedQuestionIDs(ids...) + return _c +} + +// AddModifiedQuestions adds the "modified_questions" edges to the Question entity. +func (_c *UserCreate) AddModifiedQuestions(v ...*Question) *UserCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddModifiedQuestionIDs(ids...) +} + +// AddCreatedAnswerIDs adds the "created_answers" edge to the Answer entity by IDs. +func (_c *UserCreate) AddCreatedAnswerIDs(ids ...uuid.UUID) *UserCreate { + _c.mutation.AddCreatedAnswerIDs(ids...) + return _c +} + +// AddCreatedAnswers adds the "created_answers" edges to the Answer entity. +func (_c *UserCreate) AddCreatedAnswers(v ...*Answer) *UserCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddCreatedAnswerIDs(ids...) +} + // AddModifiedStateIDs adds the "modified_states" edge to the HackathonState entity by IDs. func (_c *UserCreate) AddModifiedStateIDs(ids ...uuid.UUID) *UserCreate { _c.mutation.AddModifiedStateIDs(ids...) @@ -827,6 +874,54 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := _c.mutation.CreatedQuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedQuestionsTable, + Columns: []string{user.CreatedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.ModifiedQuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.ModifiedQuestionsTable, + Columns: []string{user.ModifiedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.CreatedAnswersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedAnswersTable, + Columns: []string{user.CreatedAnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.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.ModifiedStatesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/components/backend/ent/user_query.go b/components/backend/ent/user_query.go index f3cb6a13..de14c63a 100644 --- a/components/backend/ent/user_query.go +++ b/components/backend/ent/user_query.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathonstate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" @@ -20,6 +21,7 @@ import ( "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/submission" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/team" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/teamparticipant" @@ -52,6 +54,9 @@ type UserQuery struct { withModifiedSubmissions *SubmissionQuery withCreatedTracks *TrackQuery withModifiedTracks *TrackQuery + withCreatedQuestions *QuestionQuery + withModifiedQuestions *QuestionQuery + withCreatedAnswers *AnswerQuery withModifiedStates *HackathonStateQuery withPreferredProjects *ProjectQuery withVotes *VoteQuery @@ -447,6 +452,72 @@ func (_q *UserQuery) QueryModifiedTracks() *TrackQuery { return query } +// QueryCreatedQuestions chains the current query on the "created_questions" edge. +func (_q *UserQuery) QueryCreatedQuestions() *QuestionQuery { + query := (&QuestionClient{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(user.Table, user.FieldID, selector), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.CreatedQuestionsTable, user.CreatedQuestionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryModifiedQuestions chains the current query on the "modified_questions" edge. +func (_q *UserQuery) QueryModifiedQuestions() *QuestionQuery { + query := (&QuestionClient{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(user.Table, user.FieldID, selector), + sqlgraph.To(question.Table, question.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.ModifiedQuestionsTable, user.ModifiedQuestionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryCreatedAnswers chains the current query on the "created_answers" edge. +func (_q *UserQuery) QueryCreatedAnswers() *AnswerQuery { + query := (&AnswerClient{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(user.Table, user.FieldID, selector), + sqlgraph.To(answer.Table, answer.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.CreatedAnswersTable, user.CreatedAnswersColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryModifiedStates chains the current query on the "modified_states" edge. func (_q *UserQuery) QueryModifiedStates() *HackathonStateQuery { query := (&HackathonStateClient{config: _q.config}).Query() @@ -809,6 +880,9 @@ func (_q *UserQuery) Clone() *UserQuery { withModifiedSubmissions: _q.withModifiedSubmissions.Clone(), withCreatedTracks: _q.withCreatedTracks.Clone(), withModifiedTracks: _q.withModifiedTracks.Clone(), + withCreatedQuestions: _q.withCreatedQuestions.Clone(), + withModifiedQuestions: _q.withModifiedQuestions.Clone(), + withCreatedAnswers: _q.withCreatedAnswers.Clone(), withModifiedStates: _q.withModifiedStates.Clone(), withPreferredProjects: _q.withPreferredProjects.Clone(), withVotes: _q.withVotes.Clone(), @@ -998,6 +1072,39 @@ func (_q *UserQuery) WithModifiedTracks(opts ...func(*TrackQuery)) *UserQuery { return _q } +// WithCreatedQuestions tells the query-builder to eager-load the nodes that are connected to +// the "created_questions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *UserQuery) WithCreatedQuestions(opts ...func(*QuestionQuery)) *UserQuery { + query := (&QuestionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withCreatedQuestions = query + return _q +} + +// WithModifiedQuestions tells the query-builder to eager-load the nodes that are connected to +// the "modified_questions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *UserQuery) WithModifiedQuestions(opts ...func(*QuestionQuery)) *UserQuery { + query := (&QuestionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withModifiedQuestions = query + return _q +} + +// WithCreatedAnswers tells the query-builder to eager-load the nodes that are connected to +// the "created_answers" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *UserQuery) WithCreatedAnswers(opts ...func(*AnswerQuery)) *UserQuery { + query := (&AnswerClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withCreatedAnswers = query + return _q +} + // WithModifiedStates tells the query-builder to eager-load the nodes that are connected to // the "modified_states" edge. The optional arguments are used to configure the query builder of the edge. func (_q *UserQuery) WithModifiedStates(opts ...func(*HackathonStateQuery)) *UserQuery { @@ -1153,7 +1260,7 @@ func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e var ( nodes = []*User{} _spec = _q.querySpec() - loadedTypes = [23]bool{ + loadedTypes = [26]bool{ _q.withCreatedHackathons != nil, _q.withModifiedHackathons != nil, _q.withCreatedProjects != nil, @@ -1170,6 +1277,9 @@ func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e _q.withModifiedSubmissions != nil, _q.withCreatedTracks != nil, _q.withModifiedTracks != nil, + _q.withCreatedQuestions != nil, + _q.withModifiedQuestions != nil, + _q.withCreatedAnswers != nil, _q.withModifiedStates != nil, _q.withPreferredProjects != nil, _q.withVotes != nil, @@ -1311,6 +1421,27 @@ func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e return nil, err } } + if query := _q.withCreatedQuestions; query != nil { + if err := _q.loadCreatedQuestions(ctx, query, nodes, + func(n *User) { n.Edges.CreatedQuestions = []*Question{} }, + func(n *User, e *Question) { n.Edges.CreatedQuestions = append(n.Edges.CreatedQuestions, e) }); err != nil { + return nil, err + } + } + if query := _q.withModifiedQuestions; query != nil { + if err := _q.loadModifiedQuestions(ctx, query, nodes, + func(n *User) { n.Edges.ModifiedQuestions = []*Question{} }, + func(n *User, e *Question) { n.Edges.ModifiedQuestions = append(n.Edges.ModifiedQuestions, e) }); err != nil { + return nil, err + } + } + if query := _q.withCreatedAnswers; query != nil { + if err := _q.loadCreatedAnswers(ctx, query, nodes, + func(n *User) { n.Edges.CreatedAnswers = []*Answer{} }, + func(n *User, e *Answer) { n.Edges.CreatedAnswers = append(n.Edges.CreatedAnswers, e) }); err != nil { + return nil, err + } + } if query := _q.withModifiedStates; query != nil { if err := _q.loadModifiedStates(ctx, query, nodes, func(n *User) { n.Edges.ModifiedStates = []*HackathonState{} }, @@ -1919,6 +2050,98 @@ func (_q *UserQuery) loadModifiedTracks(ctx context.Context, query *TrackQuery, } return nil } +func (_q *UserQuery) loadCreatedQuestions(ctx context.Context, query *QuestionQuery, nodes []*User, init func(*User), assign func(*User, *Question)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Question(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.CreatedQuestionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.user_created_questions + if fk == nil { + return fmt.Errorf(`foreign-key "user_created_questions" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_created_questions" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *UserQuery) loadModifiedQuestions(ctx context.Context, query *QuestionQuery, nodes []*User, init func(*User), assign func(*User, *Question)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Question(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.ModifiedQuestionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.user_modified_questions + if fk == nil { + return fmt.Errorf(`foreign-key "user_modified_questions" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_modified_questions" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *UserQuery) loadCreatedAnswers(ctx context.Context, query *AnswerQuery, nodes []*User, init func(*User), assign func(*User, *Answer)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(answer.FieldUserID) + } + query.Where(predicate.Answer(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.CreatedAnswersColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.UserID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (_q *UserQuery) loadModifiedStates(ctx context.Context, query *HackathonStateQuery, nodes []*User, init func(*User), assign func(*User, *HackathonState)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[uuid.UUID]*User) diff --git a/components/backend/ent/user_update.go b/components/backend/ent/user_update.go index 10b28e34..c290dafe 100644 --- a/components/backend/ent/user_update.go +++ b/components/backend/ent/user_update.go @@ -12,12 +12,14 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/answer" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathon" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/hackathonstate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/page" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/phase" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/predicate" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/project" + "github.com/swissdatasciencecenter/hackagon/components/backend/ent/question" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/submission" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/team" "github.com/swissdatasciencecenter/hackagon/components/backend/ent/track" @@ -353,6 +355,51 @@ func (_u *UserUpdate) AddModifiedTracks(v ...*Track) *UserUpdate { return _u.AddModifiedTrackIDs(ids...) } +// AddCreatedQuestionIDs adds the "created_questions" edge to the Question entity by IDs. +func (_u *UserUpdate) AddCreatedQuestionIDs(ids ...uuid.UUID) *UserUpdate { + _u.mutation.AddCreatedQuestionIDs(ids...) + return _u +} + +// AddCreatedQuestions adds the "created_questions" edges to the Question entity. +func (_u *UserUpdate) AddCreatedQuestions(v ...*Question) *UserUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddCreatedQuestionIDs(ids...) +} + +// AddModifiedQuestionIDs adds the "modified_questions" edge to the Question entity by IDs. +func (_u *UserUpdate) AddModifiedQuestionIDs(ids ...uuid.UUID) *UserUpdate { + _u.mutation.AddModifiedQuestionIDs(ids...) + return _u +} + +// AddModifiedQuestions adds the "modified_questions" edges to the Question entity. +func (_u *UserUpdate) AddModifiedQuestions(v ...*Question) *UserUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddModifiedQuestionIDs(ids...) +} + +// AddCreatedAnswerIDs adds the "created_answers" edge to the Answer entity by IDs. +func (_u *UserUpdate) AddCreatedAnswerIDs(ids ...uuid.UUID) *UserUpdate { + _u.mutation.AddCreatedAnswerIDs(ids...) + return _u +} + +// AddCreatedAnswers adds the "created_answers" edges to the Answer entity. +func (_u *UserUpdate) AddCreatedAnswers(v ...*Answer) *UserUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddCreatedAnswerIDs(ids...) +} + // AddModifiedStateIDs adds the "modified_states" edge to the HackathonState entity by IDs. func (_u *UserUpdate) AddModifiedStateIDs(ids ...uuid.UUID) *UserUpdate { _u.mutation.AddModifiedStateIDs(ids...) @@ -769,6 +816,69 @@ func (_u *UserUpdate) RemoveModifiedTracks(v ...*Track) *UserUpdate { return _u.RemoveModifiedTrackIDs(ids...) } +// ClearCreatedQuestions clears all "created_questions" edges to the Question entity. +func (_u *UserUpdate) ClearCreatedQuestions() *UserUpdate { + _u.mutation.ClearCreatedQuestions() + return _u +} + +// RemoveCreatedQuestionIDs removes the "created_questions" edge to Question entities by IDs. +func (_u *UserUpdate) RemoveCreatedQuestionIDs(ids ...uuid.UUID) *UserUpdate { + _u.mutation.RemoveCreatedQuestionIDs(ids...) + return _u +} + +// RemoveCreatedQuestions removes "created_questions" edges to Question entities. +func (_u *UserUpdate) RemoveCreatedQuestions(v ...*Question) *UserUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveCreatedQuestionIDs(ids...) +} + +// ClearModifiedQuestions clears all "modified_questions" edges to the Question entity. +func (_u *UserUpdate) ClearModifiedQuestions() *UserUpdate { + _u.mutation.ClearModifiedQuestions() + return _u +} + +// RemoveModifiedQuestionIDs removes the "modified_questions" edge to Question entities by IDs. +func (_u *UserUpdate) RemoveModifiedQuestionIDs(ids ...uuid.UUID) *UserUpdate { + _u.mutation.RemoveModifiedQuestionIDs(ids...) + return _u +} + +// RemoveModifiedQuestions removes "modified_questions" edges to Question entities. +func (_u *UserUpdate) RemoveModifiedQuestions(v ...*Question) *UserUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveModifiedQuestionIDs(ids...) +} + +// ClearCreatedAnswers clears all "created_answers" edges to the Answer entity. +func (_u *UserUpdate) ClearCreatedAnswers() *UserUpdate { + _u.mutation.ClearCreatedAnswers() + return _u +} + +// RemoveCreatedAnswerIDs removes the "created_answers" edge to Answer entities by IDs. +func (_u *UserUpdate) RemoveCreatedAnswerIDs(ids ...uuid.UUID) *UserUpdate { + _u.mutation.RemoveCreatedAnswerIDs(ids...) + return _u +} + +// RemoveCreatedAnswers removes "created_answers" edges to Answer entities. +func (_u *UserUpdate) RemoveCreatedAnswers(v ...*Answer) *UserUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveCreatedAnswerIDs(ids...) +} + // ClearModifiedStates clears all "modified_states" edges to the HackathonState entity. func (_u *UserUpdate) ClearModifiedStates() *UserUpdate { _u.mutation.ClearModifiedStates() @@ -1697,6 +1807,141 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.CreatedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedQuestionsTable, + Columns: []string{user.CreatedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedCreatedQuestionsIDs(); len(nodes) > 0 && !_u.mutation.CreatedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedQuestionsTable, + Columns: []string{user.CreatedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.CreatedQuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedQuestionsTable, + Columns: []string{user.CreatedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.ModifiedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.ModifiedQuestionsTable, + Columns: []string{user.ModifiedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedModifiedQuestionsIDs(); len(nodes) > 0 && !_u.mutation.ModifiedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.ModifiedQuestionsTable, + Columns: []string{user.ModifiedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ModifiedQuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.ModifiedQuestionsTable, + Columns: []string{user.ModifiedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.CreatedAnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedAnswersTable, + Columns: []string{user.CreatedAnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedCreatedAnswersIDs(); len(nodes) > 0 && !_u.mutation.CreatedAnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedAnswersTable, + Columns: []string{user.CreatedAnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.CreatedAnswersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedAnswersTable, + Columns: []string{user.CreatedAnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.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.ModifiedStatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -2256,6 +2501,51 @@ func (_u *UserUpdateOne) AddModifiedTracks(v ...*Track) *UserUpdateOne { return _u.AddModifiedTrackIDs(ids...) } +// AddCreatedQuestionIDs adds the "created_questions" edge to the Question entity by IDs. +func (_u *UserUpdateOne) AddCreatedQuestionIDs(ids ...uuid.UUID) *UserUpdateOne { + _u.mutation.AddCreatedQuestionIDs(ids...) + return _u +} + +// AddCreatedQuestions adds the "created_questions" edges to the Question entity. +func (_u *UserUpdateOne) AddCreatedQuestions(v ...*Question) *UserUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddCreatedQuestionIDs(ids...) +} + +// AddModifiedQuestionIDs adds the "modified_questions" edge to the Question entity by IDs. +func (_u *UserUpdateOne) AddModifiedQuestionIDs(ids ...uuid.UUID) *UserUpdateOne { + _u.mutation.AddModifiedQuestionIDs(ids...) + return _u +} + +// AddModifiedQuestions adds the "modified_questions" edges to the Question entity. +func (_u *UserUpdateOne) AddModifiedQuestions(v ...*Question) *UserUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddModifiedQuestionIDs(ids...) +} + +// AddCreatedAnswerIDs adds the "created_answers" edge to the Answer entity by IDs. +func (_u *UserUpdateOne) AddCreatedAnswerIDs(ids ...uuid.UUID) *UserUpdateOne { + _u.mutation.AddCreatedAnswerIDs(ids...) + return _u +} + +// AddCreatedAnswers adds the "created_answers" edges to the Answer entity. +func (_u *UserUpdateOne) AddCreatedAnswers(v ...*Answer) *UserUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddCreatedAnswerIDs(ids...) +} + // AddModifiedStateIDs adds the "modified_states" edge to the HackathonState entity by IDs. func (_u *UserUpdateOne) AddModifiedStateIDs(ids ...uuid.UUID) *UserUpdateOne { _u.mutation.AddModifiedStateIDs(ids...) @@ -2672,6 +2962,69 @@ func (_u *UserUpdateOne) RemoveModifiedTracks(v ...*Track) *UserUpdateOne { return _u.RemoveModifiedTrackIDs(ids...) } +// ClearCreatedQuestions clears all "created_questions" edges to the Question entity. +func (_u *UserUpdateOne) ClearCreatedQuestions() *UserUpdateOne { + _u.mutation.ClearCreatedQuestions() + return _u +} + +// RemoveCreatedQuestionIDs removes the "created_questions" edge to Question entities by IDs. +func (_u *UserUpdateOne) RemoveCreatedQuestionIDs(ids ...uuid.UUID) *UserUpdateOne { + _u.mutation.RemoveCreatedQuestionIDs(ids...) + return _u +} + +// RemoveCreatedQuestions removes "created_questions" edges to Question entities. +func (_u *UserUpdateOne) RemoveCreatedQuestions(v ...*Question) *UserUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveCreatedQuestionIDs(ids...) +} + +// ClearModifiedQuestions clears all "modified_questions" edges to the Question entity. +func (_u *UserUpdateOne) ClearModifiedQuestions() *UserUpdateOne { + _u.mutation.ClearModifiedQuestions() + return _u +} + +// RemoveModifiedQuestionIDs removes the "modified_questions" edge to Question entities by IDs. +func (_u *UserUpdateOne) RemoveModifiedQuestionIDs(ids ...uuid.UUID) *UserUpdateOne { + _u.mutation.RemoveModifiedQuestionIDs(ids...) + return _u +} + +// RemoveModifiedQuestions removes "modified_questions" edges to Question entities. +func (_u *UserUpdateOne) RemoveModifiedQuestions(v ...*Question) *UserUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveModifiedQuestionIDs(ids...) +} + +// ClearCreatedAnswers clears all "created_answers" edges to the Answer entity. +func (_u *UserUpdateOne) ClearCreatedAnswers() *UserUpdateOne { + _u.mutation.ClearCreatedAnswers() + return _u +} + +// RemoveCreatedAnswerIDs removes the "created_answers" edge to Answer entities by IDs. +func (_u *UserUpdateOne) RemoveCreatedAnswerIDs(ids ...uuid.UUID) *UserUpdateOne { + _u.mutation.RemoveCreatedAnswerIDs(ids...) + return _u +} + +// RemoveCreatedAnswers removes "created_answers" edges to Answer entities. +func (_u *UserUpdateOne) RemoveCreatedAnswers(v ...*Answer) *UserUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveCreatedAnswerIDs(ids...) +} + // ClearModifiedStates clears all "modified_states" edges to the HackathonState entity. func (_u *UserUpdateOne) ClearModifiedStates() *UserUpdateOne { _u.mutation.ClearModifiedStates() @@ -3630,6 +3983,141 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.CreatedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedQuestionsTable, + Columns: []string{user.CreatedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedCreatedQuestionsIDs(); len(nodes) > 0 && !_u.mutation.CreatedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedQuestionsTable, + Columns: []string{user.CreatedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.CreatedQuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedQuestionsTable, + Columns: []string{user.CreatedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.ModifiedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.ModifiedQuestionsTable, + Columns: []string{user.ModifiedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedModifiedQuestionsIDs(); len(nodes) > 0 && !_u.mutation.ModifiedQuestionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.ModifiedQuestionsTable, + Columns: []string{user.ModifiedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ModifiedQuestionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.ModifiedQuestionsTable, + Columns: []string{user.ModifiedQuestionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(question.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.CreatedAnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedAnswersTable, + Columns: []string{user.CreatedAnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedCreatedAnswersIDs(); len(nodes) > 0 && !_u.mutation.CreatedAnswersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedAnswersTable, + Columns: []string{user.CreatedAnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.CreatedAnswersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.CreatedAnswersTable, + Columns: []string{user.CreatedAnswersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(answer.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.ModifiedStatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/components/backend/go.sum b/components/backend/go.sum index 7c3dd192..93aeaf4b 100644 --- a/components/backend/go.sum +++ b/components/backend/go.sum @@ -45,6 +45,12 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/clipperhouse/displaywidth v0.6.2 h1:ZDpTkFfpHOKte4RG5O/BOyf3ysnvFswpyYrV7z2uAKo= +github.com/clipperhouse/displaywidth v0.6.2/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o= +github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= +github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= +github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4= +github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -52,6 +58,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BNhXs= @@ -144,6 +152,12 @@ github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ= github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA= github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/mattn/go-sqlite3 v1.14.42 h1:MigqEP4ZmHw3aIdIT7T+9TLa90Z6smwcthx+Azv4Cgo= github.com/mattn/go-sqlite3 v1.14.42/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ= github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= @@ -154,6 +168,14 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc= +github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0= +github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM= +github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y= +github.com/olekukonko/ll v0.1.4-0.20260115111900-9e59c2286df0 h1:jrYnow5+hy3WRDCBypUFvVKNSPPCdqgSXIE9eJDD8LM= +github.com/olekukonko/ll v0.1.4-0.20260115111900-9e59c2286df0/go.mod h1:b52bVQRRPObe+yyBl0TxNfhesL0nedD4Cht0/zx55Ew= +github.com/olekukonko/tablewriter v1.1.3 h1:VSHhghXxrP0JHl+0NnKid7WoEmd9/urKRJLysb70nnA= +github.com/olekukonko/tablewriter v1.1.3/go.mod h1:9VU0knjhmMkXjnMKrZ3+L2JhhtsQ/L38BbL3CRNE8tM= github.com/onsi/ginkgo/v2 v2.27.5 h1:ZeVgZMx2PDMdJm/+w5fE/OyG6ILo1Y3e+QX4zSR0zTE= github.com/onsi/ginkgo/v2 v2.27.5/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= github.com/onsi/gomega v1.40.0 h1:Vtol0e1MghCD2ZVIilPDIg44XSL9l2QAn8ZNaljWcJc= @@ -170,6 +192,10 @@ github.com/rodaine/protogofakeit v0.1.1/go.mod h1:pXn/AstBYMaSfc1/RqH3N82pBuxtWg github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= From 01a65d446544e9da4e771c8b95abfa5031452536 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Fri, 21 Aug 2026 13:26:39 +0200 Subject: [PATCH 2/2] update protobuf files for registration form --- api/proto/API.md | 503 ++++++++++++++++++ api/proto/hackathon/entities/answer.proto | 14 + api/proto/hackathon/entities/question.proto | 22 + api/proto/hackathon/hackathon_service.proto | 20 + .../create_question_request.proto | 24 + .../create_question_response.proto | 9 + .../hackathon_svc/edit_question_request.proto | 20 + .../edit_question_response.proto | 7 + .../messages/hackathon_svc/join_request.proto | 6 +- .../list_participant_answers_request.proto | 12 + .../list_participant_answers_response.proto | 11 + .../list_questions_request.proto | 11 + .../list_questions_response.proto | 11 + .../remove_question_request.proto | 12 + .../remove_question_response.proto | 7 + .../submit_answers_request.proto | 13 + .../submit_answers_response.proto | 7 + components/backend/go.sum | 26 - .../proto/hackathon/entities/answer.pb.go | 145 +++++ .../proto/hackathon/entities/question.pb.go | 225 ++++++++ .../proto/hackathon/hackathon_service.pb.go | 105 ++-- .../hackathon/hackathon_service_grpc.pb.go | 254 ++++++++- .../create_question_request.pb.go | 172 ++++++ .../create_question_response.pb.go | 123 +++++ .../hackathon_svc/edit_question_request.pb.go | 179 +++++++ .../edit_question_response.pb.go | 113 ++++ .../messages/hackathon_svc/join_request.pb.go | 31 +- .../list_participant_answers_request.pb.go | 135 +++++ .../list_participant_answers_response.pb.go | 125 +++++ .../list_questions_request.pb.go | 123 +++++ .../list_questions_response.pb.go | 125 +++++ .../remove_question_request.pb.go | 133 +++++ .../remove_question_response.pb.go | 113 ++++ .../submit_answers_request.pb.go | 135 +++++ .../submit_answers_response.pb.go | 113 ++++ .../generated/hackathon/entities/answer.ts | 134 +++++ .../generated/hackathon/entities/question.ts | 219 ++++++++ .../generated/hackathon/hackathon_service.ts | 114 ++++ .../hackathon_svc/create_question_request.ts | 185 +++++++ .../hackathon_svc/create_question_response.ts | 99 ++++ .../hackathon_svc/edit_question_request.ts | 189 +++++++ .../hackathon_svc/edit_question_response.ts | 73 +++ .../messages/hackathon_svc/join_request.ts | 20 +- .../list_participant_answers_request.ts | 120 +++++ .../list_participant_answers_response.ts | 92 ++++ .../hackathon_svc/list_questions_request.ts | 99 ++++ .../hackathon_svc/list_questions_response.ts | 94 ++++ .../hackathon_svc/remove_question_request.ts | 120 +++++ .../hackathon_svc/remove_question_response.ts | 73 +++ .../hackathon_svc/submit_answers_request.ts | 117 ++++ .../hackathon_svc/submit_answers_response.ts | 73 +++ 51 files changed, 4819 insertions(+), 86 deletions(-) create mode 100644 api/proto/hackathon/entities/answer.proto create mode 100644 api/proto/hackathon/entities/question.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/create_question_request.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/create_question_response.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/edit_question_request.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/edit_question_response.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/list_questions_request.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/list_questions_response.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/remove_question_request.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/remove_question_response.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/submit_answers_request.proto create mode 100644 api/proto/hackathon/messages/hackathon_svc/submit_answers_response.proto create mode 100644 components/backend/internal/proto/hackathon/entities/answer.pb.go create mode 100644 components/backend/internal/proto/hackathon/entities/question.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_request.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_response.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_request.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_response.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_request.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_response.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_request.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_response.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_request.pb.go create mode 100644 components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_response.pb.go create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/entities/answer.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/entities/question.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_request.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_response.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_request.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_response.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_request.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_response.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_request.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_response.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_request.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_response.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_request.ts create mode 100644 components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_response.ts diff --git a/api/proto/API.md b/api/proto/API.md index 7f2eaec2..471e1a13 100644 --- a/api/proto/API.md +++ b/api/proto/API.md @@ -3,6 +3,14 @@ ## Table of Contents +- [hackathon/entities/question.proto](#hackathon_entities_question-proto) + - [Question](#hackathon-entities-Question) + + - [QuestionType](#hackathon-entities-QuestionType) + +- [hackathon/entities/answer.proto](#hackathon_entities_answer-proto) + - [Answer](#hackathon-entities-Answer) + - [hackathon/entities/capability.proto](#hackathon_entities_capability-proto) - [Capability](#hackathon-entities-Capability) @@ -70,12 +78,24 @@ - [hackathon/messages/hackathon_svc/approve_participant_response.proto](#hackathon_messages_hackathon_svc_approve_participant_response-proto) - [ApproveParticipantResponse](#hackathon-messages-hackathon_svc-ApproveParticipantResponse) +- [hackathon/messages/hackathon_svc/create_question_request.proto](#hackathon_messages_hackathon_svc_create_question_request-proto) + - [CreateQuestionRequest](#hackathon-messages-hackathon_svc-CreateQuestionRequest) + +- [hackathon/messages/hackathon_svc/create_question_response.proto](#hackathon_messages_hackathon_svc_create_question_response-proto) + - [CreateQuestionResponse](#hackathon-messages-hackathon_svc-CreateQuestionResponse) + - [hackathon/messages/hackathon_svc/create_request.proto](#hackathon_messages_hackathon_svc_create_request-proto) - [CreateRequest](#hackathon-messages-hackathon_svc-CreateRequest) - [hackathon/messages/hackathon_svc/create_response.proto](#hackathon_messages_hackathon_svc_create_response-proto) - [CreateResponse](#hackathon-messages-hackathon_svc-CreateResponse) +- [hackathon/messages/hackathon_svc/edit_question_request.proto](#hackathon_messages_hackathon_svc_edit_question_request-proto) + - [EditQuestionRequest](#hackathon-messages-hackathon_svc-EditQuestionRequest) + +- [hackathon/messages/hackathon_svc/edit_question_response.proto](#hackathon_messages_hackathon_svc_edit_question_response-proto) + - [EditQuestionResponse](#hackathon-messages-hackathon_svc-EditQuestionResponse) + - [hackathon/messages/hackathon_svc/edit_request.proto](#hackathon_messages_hackathon_svc_edit_request-proto) - [EditRequest](#hackathon-messages-hackathon_svc-EditRequest) @@ -94,6 +114,18 @@ - [hackathon/messages/hackathon_svc/join_response.proto](#hackathon_messages_hackathon_svc_join_response-proto) - [JoinResponse](#hackathon-messages-hackathon_svc-JoinResponse) +- [hackathon/messages/hackathon_svc/list_participant_answers_request.proto](#hackathon_messages_hackathon_svc_list_participant_answers_request-proto) + - [ListParticipantAnswersRequest](#hackathon-messages-hackathon_svc-ListParticipantAnswersRequest) + +- [hackathon/messages/hackathon_svc/list_participant_answers_response.proto](#hackathon_messages_hackathon_svc_list_participant_answers_response-proto) + - [ListParticipantAnswersResponse](#hackathon-messages-hackathon_svc-ListParticipantAnswersResponse) + +- [hackathon/messages/hackathon_svc/list_questions_request.proto](#hackathon_messages_hackathon_svc_list_questions_request-proto) + - [ListQuestionsRequest](#hackathon-messages-hackathon_svc-ListQuestionsRequest) + +- [hackathon/messages/hackathon_svc/list_questions_response.proto](#hackathon_messages_hackathon_svc_list_questions_response-proto) + - [ListQuestionsResponse](#hackathon-messages-hackathon_svc-ListQuestionsResponse) + - [hackathon/messages/hackathon_svc/list_request.proto](#hackathon_messages_hackathon_svc_list_request-proto) - [ListRequest](#hackathon-messages-hackathon_svc-ListRequest) @@ -112,6 +144,12 @@ - [hackathon/messages/hackathon_svc/remove_participant_response.proto](#hackathon_messages_hackathon_svc_remove_participant_response-proto) - [RemoveParticipantResponse](#hackathon-messages-hackathon_svc-RemoveParticipantResponse) +- [hackathon/messages/hackathon_svc/remove_question_request.proto](#hackathon_messages_hackathon_svc_remove_question_request-proto) + - [RemoveQuestionRequest](#hackathon-messages-hackathon_svc-RemoveQuestionRequest) + +- [hackathon/messages/hackathon_svc/remove_question_response.proto](#hackathon_messages_hackathon_svc_remove_question_response-proto) + - [RemoveQuestionResponse](#hackathon-messages-hackathon_svc-RemoveQuestionResponse) + - [hackathon/messages/hackathon_svc/set_capabilities_request.proto](#hackathon_messages_hackathon_svc_set_capabilities_request-proto) - [CapabilityState](#hackathon-messages-hackathon_svc-CapabilityState) - [SetCapabilitiesRequest](#hackathon-messages-hackathon_svc-SetCapabilitiesRequest) @@ -125,6 +163,12 @@ - [hackathon/messages/hackathon_svc/set_current_phase_response.proto](#hackathon_messages_hackathon_svc_set_current_phase_response-proto) - [SetCurrentPhaseResponse](#hackathon-messages-hackathon_svc-SetCurrentPhaseResponse) +- [hackathon/messages/hackathon_svc/submit_answers_request.proto](#hackathon_messages_hackathon_svc_submit_answers_request-proto) + - [SubmitAnswersRequest](#hackathon-messages-hackathon_svc-SubmitAnswersRequest) + +- [hackathon/messages/hackathon_svc/submit_answers_response.proto](#hackathon_messages_hackathon_svc_submit_answers_response-proto) + - [SubmitAnswersResponse](#hackathon-messages-hackathon_svc-SubmitAnswersResponse) + - [hackathon/hackathon_service.proto](#hackathon_hackathon_service-proto) - [HackathonService](#hackathon-HackathonService) @@ -545,6 +589,88 @@ + +

Top

+ +## hackathon/entities/question.proto + + + + + +### Question + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| id | [string](#string) | | | +| key | [string](#string) | | | +| label | [string](#string) | | | +| type | [QuestionType](#hackathon-entities-QuestionType) | | | +| mandatory | [bool](#bool) | | | +| order | [int32](#int32) | | | + + + + + + + + + + +### QuestionType + + +| Name | Number | Description | +| ---- | ------ | ----------- | +| QUESTION_TYPE_UNSPECIFIED | 0 | | +| QUESTION_TYPE_TEXT | 1 | | +| QUESTION_TYPE_BOOL | 2 | | + + + + + + + + + + + +

Top

+ +## hackathon/entities/answer.proto + + + + + +### Answer + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| question_id | [string](#string) | | | +| value | [string](#string) | | | +| type | [QuestionType](#hackathon-entities-QuestionType) | | | + + + + + + + + + + + + + + +

Top

@@ -1326,6 +1452,73 @@ casbin role for this hackathon; `is_waiting` is false once approved. + +

Top

+ +## hackathon/messages/hackathon_svc/create_question_request.proto + + + + + +### CreateQuestionRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| hackathon_id | [string](#string) | | | +| key | [string](#string) | | | +| label | [string](#string) | | | +| type | [hackathon.entities.QuestionType](#hackathon-entities-QuestionType) | | | +| mandatory | [bool](#bool) | | | +| order | [int32](#int32) | | | + + + + + + + + + + + + + + + + +

Top

+ +## hackathon/messages/hackathon_svc/create_question_response.proto + + + + + +### CreateQuestionResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| question_id | [string](#string) | | | + + + + + + + + + + + + + + +

Top

@@ -1393,6 +1586,68 @@ casbin role for this hackathon; `is_waiting` is false once approved. + +

Top

+ +## hackathon/messages/hackathon_svc/edit_question_request.proto + + + + + +### EditQuestionRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| hackathon_id | [string](#string) | | | +| question_id | [string](#string) | | | +| label | [string](#string) | optional | | +| type | [hackathon.entities.QuestionType](#hackathon-entities-QuestionType) | optional | | +| mandatory | [bool](#bool) | optional | | +| order | [int32](#int32) | optional | | + + + + + + + + + + + + + + + + +

Top

+ +## hackathon/messages/hackathon_svc/edit_question_response.proto + + + + + +### EditQuestionResponse + + + + + + + + + + + + + + + +

Top

@@ -1539,6 +1794,7 @@ casbin role for this hackathon; `is_waiting` is false once approved. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | hackathon_id | [string](#string) | | | +| answers | [hackathon.entities.Answer](#hackathon-entities-Answer) | repeated | | @@ -1585,6 +1841,131 @@ casbin role for this hackathon; `is_waiting` is false once approved. + +

Top

+ +## hackathon/messages/hackathon_svc/list_participant_answers_request.proto + + + + + +### ListParticipantAnswersRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| hackathon_id | [string](#string) | | | +| user_id | [string](#string) | optional | | + + + + + + + + + + + + + + + + +

Top

+ +## hackathon/messages/hackathon_svc/list_participant_answers_response.proto + + + + + +### ListParticipantAnswersResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| answers | [hackathon.entities.Answer](#hackathon-entities-Answer) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ +## hackathon/messages/hackathon_svc/list_questions_request.proto + + + + + +### ListQuestionsRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| hackathon_id | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ +## hackathon/messages/hackathon_svc/list_questions_response.proto + + + + + +### ListQuestionsResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| questions | [hackathon.entities.Question](#hackathon-entities-Question) | repeated | | + + + + + + + + + + + + + + +

Top

@@ -1766,6 +2147,64 @@ casbin role for this hackathon; `is_waiting` is false once approved. + +

Top

+ +## hackathon/messages/hackathon_svc/remove_question_request.proto + + + + + +### RemoveQuestionRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| hackathon_id | [string](#string) | | | +| question_id | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ +## hackathon/messages/hackathon_svc/remove_question_response.proto + + + + + +### RemoveQuestionResponse + + + + + + + + + + + + + + + +

Top

@@ -1908,6 +2347,64 @@ casbin role for this hackathon; `is_waiting` is false once approved. + +

Top

+ +## hackathon/messages/hackathon_svc/submit_answers_request.proto + + + + + +### SubmitAnswersRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| hackathon_id | [string](#string) | | | +| answers | [hackathon.entities.Answer](#hackathon-entities-Answer) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ +## hackathon/messages/hackathon_svc/submit_answers_response.proto + + + + + +### SubmitAnswersResponse + + + + + + + + + + + + + + + +

Top

@@ -1939,6 +2436,12 @@ casbin role for this hackathon; `is_waiting` is false once approved. | RemoveParticipant | [messages.hackathon_svc.RemoveParticipantRequest](#hackathon-messages-hackathon_svc-RemoveParticipantRequest) | [messages.hackathon_svc.RemoveParticipantResponse](#hackathon-messages-hackathon_svc-RemoveParticipantResponse) | | | AddOwner | [messages.hackathon_svc.AddOwnerRequest](#hackathon-messages-hackathon_svc-AddOwnerRequest) | [messages.hackathon_svc.AddOwnerResponse](#hackathon-messages-hackathon_svc-AddOwnerResponse) | | | RemoveOwner | [messages.hackathon_svc.RemoveOwnerRequest](#hackathon-messages-hackathon_svc-RemoveOwnerRequest) | [messages.hackathon_svc.RemoveOwnerResponse](#hackathon-messages-hackathon_svc-RemoveOwnerResponse) | | +| CreateQuestion | [messages.hackathon_svc.CreateQuestionRequest](#hackathon-messages-hackathon_svc-CreateQuestionRequest) | [messages.hackathon_svc.CreateQuestionResponse](#hackathon-messages-hackathon_svc-CreateQuestionResponse) | Registration questions | +| EditQuestion | [messages.hackathon_svc.EditQuestionRequest](#hackathon-messages-hackathon_svc-EditQuestionRequest) | [messages.hackathon_svc.EditQuestionResponse](#hackathon-messages-hackathon_svc-EditQuestionResponse) | | +| RemoveQuestion | [messages.hackathon_svc.RemoveQuestionRequest](#hackathon-messages-hackathon_svc-RemoveQuestionRequest) | [messages.hackathon_svc.RemoveQuestionResponse](#hackathon-messages-hackathon_svc-RemoveQuestionResponse) | | +| ListQuestions | [messages.hackathon_svc.ListQuestionsRequest](#hackathon-messages-hackathon_svc-ListQuestionsRequest) | [messages.hackathon_svc.ListQuestionsResponse](#hackathon-messages-hackathon_svc-ListQuestionsResponse) | | +| SubmitAnswers | [messages.hackathon_svc.SubmitAnswersRequest](#hackathon-messages-hackathon_svc-SubmitAnswersRequest) | [messages.hackathon_svc.SubmitAnswersResponse](#hackathon-messages-hackathon_svc-SubmitAnswersResponse) | | +| ListParticipantAnswers | [messages.hackathon_svc.ListParticipantAnswersRequest](#hackathon-messages-hackathon_svc-ListParticipantAnswersRequest) | [messages.hackathon_svc.ListParticipantAnswersResponse](#hackathon-messages-hackathon_svc-ListParticipantAnswersResponse) | Participant answers (admin) | diff --git a/api/proto/hackathon/entities/answer.proto b/api/proto/hackathon/entities/answer.proto new file mode 100644 index 00000000..70d0f409 --- /dev/null +++ b/api/proto/hackathon/entities/answer.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package hackathon.entities; + +import "buf/validate/validate.proto"; +import "hackathon/entities/question.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities"; + +message Answer { + string question_id = 1; + string value = 2; + QuestionType type = 3 [(buf.validate.field).enum.defined_only = true]; +} diff --git a/api/proto/hackathon/entities/question.proto b/api/proto/hackathon/entities/question.proto new file mode 100644 index 00000000..643da519 --- /dev/null +++ b/api/proto/hackathon/entities/question.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package hackathon.entities; + +import "buf/validate/validate.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities"; + +enum QuestionType { + QUESTION_TYPE_UNSPECIFIED = 0; + QUESTION_TYPE_TEXT = 1; + QUESTION_TYPE_BOOL = 2; +} + +message Question { + string id = 1; + string key = 2 [(buf.validate.field).string.pattern = "^[a-z][a-z0-9_]*$"]; + string label = 3; + QuestionType type = 4 [(buf.validate.field).enum.defined_only = true]; + bool mandatory = 5; + int32 order = 6; +} diff --git a/api/proto/hackathon/hackathon_service.proto b/api/proto/hackathon/hackathon_service.proto index 966a61e6..03c95e61 100644 --- a/api/proto/hackathon/hackathon_service.proto +++ b/api/proto/hackathon/hackathon_service.proto @@ -6,24 +6,36 @@ import "hackathon/messages/hackathon_svc/add_owner_request.proto"; import "hackathon/messages/hackathon_svc/add_owner_response.proto"; import "hackathon/messages/hackathon_svc/approve_participant_request.proto"; import "hackathon/messages/hackathon_svc/approve_participant_response.proto"; +import "hackathon/messages/hackathon_svc/create_question_request.proto"; +import "hackathon/messages/hackathon_svc/create_question_response.proto"; import "hackathon/messages/hackathon_svc/create_request.proto"; import "hackathon/messages/hackathon_svc/create_response.proto"; +import "hackathon/messages/hackathon_svc/edit_question_request.proto"; +import "hackathon/messages/hackathon_svc/edit_question_response.proto"; import "hackathon/messages/hackathon_svc/edit_request.proto"; import "hackathon/messages/hackathon_svc/edit_response.proto"; import "hackathon/messages/hackathon_svc/get_request.proto"; import "hackathon/messages/hackathon_svc/get_response.proto"; import "hackathon/messages/hackathon_svc/join_request.proto"; import "hackathon/messages/hackathon_svc/join_response.proto"; +import "hackathon/messages/hackathon_svc/list_participant_answers_request.proto"; +import "hackathon/messages/hackathon_svc/list_participant_answers_response.proto"; +import "hackathon/messages/hackathon_svc/list_questions_request.proto"; +import "hackathon/messages/hackathon_svc/list_questions_response.proto"; import "hackathon/messages/hackathon_svc/list_request.proto"; import "hackathon/messages/hackathon_svc/list_response.proto"; import "hackathon/messages/hackathon_svc/remove_owner_request.proto"; import "hackathon/messages/hackathon_svc/remove_owner_response.proto"; import "hackathon/messages/hackathon_svc/remove_participant_request.proto"; import "hackathon/messages/hackathon_svc/remove_participant_response.proto"; +import "hackathon/messages/hackathon_svc/remove_question_request.proto"; +import "hackathon/messages/hackathon_svc/remove_question_response.proto"; import "hackathon/messages/hackathon_svc/set_capabilities_request.proto"; import "hackathon/messages/hackathon_svc/set_capabilities_response.proto"; import "hackathon/messages/hackathon_svc/set_current_phase_request.proto"; import "hackathon/messages/hackathon_svc/set_current_phase_response.proto"; +import "hackathon/messages/hackathon_svc/submit_answers_request.proto"; +import "hackathon/messages/hackathon_svc/submit_answers_response.proto"; option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon"; @@ -39,4 +51,12 @@ service HackathonService { rpc RemoveParticipant(hackathon.messages.hackathon_svc.RemoveParticipantRequest) returns (hackathon.messages.hackathon_svc.RemoveParticipantResponse); rpc AddOwner(hackathon.messages.hackathon_svc.AddOwnerRequest) returns (hackathon.messages.hackathon_svc.AddOwnerResponse); rpc RemoveOwner(hackathon.messages.hackathon_svc.RemoveOwnerRequest) returns (hackathon.messages.hackathon_svc.RemoveOwnerResponse); + // Registration questions + rpc CreateQuestion(hackathon.messages.hackathon_svc.CreateQuestionRequest) returns (hackathon.messages.hackathon_svc.CreateQuestionResponse); + rpc EditQuestion(hackathon.messages.hackathon_svc.EditQuestionRequest) returns (hackathon.messages.hackathon_svc.EditQuestionResponse); + rpc RemoveQuestion(hackathon.messages.hackathon_svc.RemoveQuestionRequest) returns (hackathon.messages.hackathon_svc.RemoveQuestionResponse); + rpc ListQuestions(hackathon.messages.hackathon_svc.ListQuestionsRequest) returns (hackathon.messages.hackathon_svc.ListQuestionsResponse); + rpc SubmitAnswers(hackathon.messages.hackathon_svc.SubmitAnswersRequest) returns (hackathon.messages.hackathon_svc.SubmitAnswersResponse); + // Participant answers (admin) + rpc ListParticipantAnswers(hackathon.messages.hackathon_svc.ListParticipantAnswersRequest) returns (hackathon.messages.hackathon_svc.ListParticipantAnswersResponse); } diff --git a/api/proto/hackathon/messages/hackathon_svc/create_question_request.proto b/api/proto/hackathon/messages/hackathon_svc/create_question_request.proto new file mode 100644 index 00000000..cb47a0ee --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/create_question_request.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "buf/validate/validate.proto"; +import "hackathon/entities/question.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message CreateQuestionRequest { + string hackathon_id = 1 [(buf.validate.field).string.uuid = true]; + string key = 2 [ + (buf.validate.field).string.min_len = 1, + (buf.validate.field).string.max_len = 64, + (buf.validate.field).string.pattern = "^[a-z][a-z0-9_]*$" + ]; + string label = 3 [ + (buf.validate.field).string.min_len = 1, + (buf.validate.field).string.max_len = 255 + ]; + hackathon.entities.QuestionType type = 4 [(buf.validate.field).enum.defined_only = true]; + bool mandatory = 5; + int32 order = 6; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/create_question_response.proto b/api/proto/hackathon/messages/hackathon_svc/create_question_response.proto new file mode 100644 index 00000000..230d32aa --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/create_question_response.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message CreateQuestionResponse { + string question_id = 1; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/edit_question_request.proto b/api/proto/hackathon/messages/hackathon_svc/edit_question_request.proto new file mode 100644 index 00000000..7d83325c --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/edit_question_request.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "buf/validate/validate.proto"; +import "hackathon/entities/question.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message EditQuestionRequest { + string hackathon_id = 1 [(buf.validate.field).string.uuid = true]; + string question_id = 2 [(buf.validate.field).string.uuid = true]; + optional string label = 3 [ + (buf.validate.field).string.min_len = 1, + (buf.validate.field).string.max_len = 255 + ]; + optional hackathon.entities.QuestionType type = 4; + optional bool mandatory = 5; + optional int32 order = 6; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/edit_question_response.proto b/api/proto/hackathon/messages/hackathon_svc/edit_question_response.proto new file mode 100644 index 00000000..decac276 --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/edit_question_response.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message EditQuestionResponse {} diff --git a/api/proto/hackathon/messages/hackathon_svc/join_request.proto b/api/proto/hackathon/messages/hackathon_svc/join_request.proto index 6bd1d0da..709975ed 100644 --- a/api/proto/hackathon/messages/hackathon_svc/join_request.proto +++ b/api/proto/hackathon/messages/hackathon_svc/join_request.proto @@ -2,8 +2,12 @@ syntax = "proto3"; package hackathon.messages.hackathon_svc; +import "buf/validate/validate.proto"; +import "hackathon/entities/answer.proto"; + option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; message JoinRequest { - string hackathon_id = 1; + string hackathon_id = 1 [(buf.validate.field).string.uuid = true]; + repeated hackathon.entities.Answer answers = 2; } diff --git a/api/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.proto b/api/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.proto new file mode 100644 index 00000000..bbd33fe2 --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "buf/validate/validate.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message ListParticipantAnswersRequest { + string hackathon_id = 1 [(buf.validate.field).string.uuid = true]; + optional string user_id = 2 [(buf.validate.field).string.uuid = true]; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.proto b/api/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.proto new file mode 100644 index 00000000..dea4893e --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "hackathon/entities/answer.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message ListParticipantAnswersResponse { + repeated hackathon.entities.Answer answers = 1; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/list_questions_request.proto b/api/proto/hackathon/messages/hackathon_svc/list_questions_request.proto new file mode 100644 index 00000000..2235447d --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/list_questions_request.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "buf/validate/validate.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message ListQuestionsRequest { + string hackathon_id = 1 [(buf.validate.field).string.uuid = true]; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/list_questions_response.proto b/api/proto/hackathon/messages/hackathon_svc/list_questions_response.proto new file mode 100644 index 00000000..cbf726e4 --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/list_questions_response.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "hackathon/entities/question.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message ListQuestionsResponse { + repeated hackathon.entities.Question questions = 1; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/remove_question_request.proto b/api/proto/hackathon/messages/hackathon_svc/remove_question_request.proto new file mode 100644 index 00000000..d7c14245 --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/remove_question_request.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "buf/validate/validate.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message RemoveQuestionRequest { + string hackathon_id = 1 [(buf.validate.field).string.uuid = true]; + string question_id = 2 [(buf.validate.field).string.uuid = true]; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/remove_question_response.proto b/api/proto/hackathon/messages/hackathon_svc/remove_question_response.proto new file mode 100644 index 00000000..408433a7 --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/remove_question_response.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message RemoveQuestionResponse {} diff --git a/api/proto/hackathon/messages/hackathon_svc/submit_answers_request.proto b/api/proto/hackathon/messages/hackathon_svc/submit_answers_request.proto new file mode 100644 index 00000000..a7a532e6 --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/submit_answers_request.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +import "buf/validate/validate.proto"; +import "hackathon/entities/answer.proto"; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message SubmitAnswersRequest { + string hackathon_id = 1 [(buf.validate.field).string.uuid = true]; + repeated hackathon.entities.Answer answers = 2; +} diff --git a/api/proto/hackathon/messages/hackathon_svc/submit_answers_response.proto b/api/proto/hackathon/messages/hackathon_svc/submit_answers_response.proto new file mode 100644 index 00000000..226e71f7 --- /dev/null +++ b/api/proto/hackathon/messages/hackathon_svc/submit_answers_response.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package hackathon.messages.hackathon_svc; + +option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc"; + +message SubmitAnswersResponse {} diff --git a/components/backend/go.sum b/components/backend/go.sum index 93aeaf4b..7c3dd192 100644 --- a/components/backend/go.sum +++ b/components/backend/go.sum @@ -45,12 +45,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/clipperhouse/displaywidth v0.6.2 h1:ZDpTkFfpHOKte4RG5O/BOyf3ysnvFswpyYrV7z2uAKo= -github.com/clipperhouse/displaywidth v0.6.2/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o= -github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= -github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= -github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4= -github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -58,8 +52,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BNhXs= @@ -152,12 +144,6 @@ github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ= github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA= github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= -github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/mattn/go-sqlite3 v1.14.42 h1:MigqEP4ZmHw3aIdIT7T+9TLa90Z6smwcthx+Azv4Cgo= github.com/mattn/go-sqlite3 v1.14.42/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ= github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= @@ -168,14 +154,6 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc= -github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0= -github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM= -github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y= -github.com/olekukonko/ll v0.1.4-0.20260115111900-9e59c2286df0 h1:jrYnow5+hy3WRDCBypUFvVKNSPPCdqgSXIE9eJDD8LM= -github.com/olekukonko/ll v0.1.4-0.20260115111900-9e59c2286df0/go.mod h1:b52bVQRRPObe+yyBl0TxNfhesL0nedD4Cht0/zx55Ew= -github.com/olekukonko/tablewriter v1.1.3 h1:VSHhghXxrP0JHl+0NnKid7WoEmd9/urKRJLysb70nnA= -github.com/olekukonko/tablewriter v1.1.3/go.mod h1:9VU0knjhmMkXjnMKrZ3+L2JhhtsQ/L38BbL3CRNE8tM= github.com/onsi/ginkgo/v2 v2.27.5 h1:ZeVgZMx2PDMdJm/+w5fE/OyG6ILo1Y3e+QX4zSR0zTE= github.com/onsi/ginkgo/v2 v2.27.5/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= github.com/onsi/gomega v1.40.0 h1:Vtol0e1MghCD2ZVIilPDIg44XSL9l2QAn8ZNaljWcJc= @@ -192,10 +170,6 @@ github.com/rodaine/protogofakeit v0.1.1/go.mod h1:pXn/AstBYMaSfc1/RqH3N82pBuxtWg github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/components/backend/internal/proto/hackathon/entities/answer.pb.go b/components/backend/internal/proto/hackathon/entities/answer.pb.go new file mode 100644 index 00000000..2e6bdd31 --- /dev/null +++ b/components/backend/internal/proto/hackathon/entities/answer.pb.go @@ -0,0 +1,145 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/entities/answer.proto + +package entities + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Answer struct { + state protoimpl.MessageState `protogen:"open.v1"` + QuestionId string `protobuf:"bytes,1,opt,name=question_id,json=questionId,proto3" json:"question_id,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Type QuestionType `protobuf:"varint,3,opt,name=type,proto3,enum=hackathon.entities.QuestionType" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Answer) Reset() { + *x = Answer{} + mi := &file_hackathon_entities_answer_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Answer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Answer) ProtoMessage() {} + +func (x *Answer) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_entities_answer_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Answer.ProtoReflect.Descriptor instead. +func (*Answer) Descriptor() ([]byte, []int) { + return file_hackathon_entities_answer_proto_rawDescGZIP(), []int{0} +} + +func (x *Answer) GetQuestionId() string { + if x != nil { + return x.QuestionId + } + return "" +} + +func (x *Answer) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *Answer) GetType() QuestionType { + if x != nil { + return x.Type + } + return QuestionType_QUESTION_TYPE_UNSPECIFIED +} + +var File_hackathon_entities_answer_proto protoreflect.FileDescriptor + +const file_hackathon_entities_answer_proto_rawDesc = "" + + "\n" + + "\x1fhackathon/entities/answer.proto\x12\x12hackathon.entities\x1a\x1bbuf/validate/validate.proto\x1a!hackathon/entities/question.proto\"\x7f\n" + + "\x06Answer\x12\x1f\n" + + "\vquestion_id\x18\x01 \x01(\tR\n" + + "questionId\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\x12>\n" + + "\x04type\x18\x03 \x01(\x0e2 .hackathon.entities.QuestionTypeB\b\xbaH\x05\x82\x01\x02\x10\x01R\x04typeBaZ_github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entitiesb\x06proto3" + +var ( + file_hackathon_entities_answer_proto_rawDescOnce sync.Once + file_hackathon_entities_answer_proto_rawDescData []byte +) + +func file_hackathon_entities_answer_proto_rawDescGZIP() []byte { + file_hackathon_entities_answer_proto_rawDescOnce.Do(func() { + file_hackathon_entities_answer_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_entities_answer_proto_rawDesc), len(file_hackathon_entities_answer_proto_rawDesc))) + }) + return file_hackathon_entities_answer_proto_rawDescData +} + +var file_hackathon_entities_answer_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_entities_answer_proto_goTypes = []any{ + (*Answer)(nil), // 0: hackathon.entities.Answer + (QuestionType)(0), // 1: hackathon.entities.QuestionType +} +var file_hackathon_entities_answer_proto_depIdxs = []int32{ + 1, // 0: hackathon.entities.Answer.type:type_name -> hackathon.entities.QuestionType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_hackathon_entities_answer_proto_init() } +func file_hackathon_entities_answer_proto_init() { + if File_hackathon_entities_answer_proto != nil { + return + } + file_hackathon_entities_question_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_entities_answer_proto_rawDesc), len(file_hackathon_entities_answer_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_entities_answer_proto_goTypes, + DependencyIndexes: file_hackathon_entities_answer_proto_depIdxs, + MessageInfos: file_hackathon_entities_answer_proto_msgTypes, + }.Build() + File_hackathon_entities_answer_proto = out.File + file_hackathon_entities_answer_proto_goTypes = nil + file_hackathon_entities_answer_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/entities/question.pb.go b/components/backend/internal/proto/hackathon/entities/question.pb.go new file mode 100644 index 00000000..8722de6e --- /dev/null +++ b/components/backend/internal/proto/hackathon/entities/question.pb.go @@ -0,0 +1,225 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/entities/question.proto + +package entities + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type QuestionType int32 + +const ( + QuestionType_QUESTION_TYPE_UNSPECIFIED QuestionType = 0 + QuestionType_QUESTION_TYPE_TEXT QuestionType = 1 + QuestionType_QUESTION_TYPE_BOOL QuestionType = 2 +) + +// Enum value maps for QuestionType. +var ( + QuestionType_name = map[int32]string{ + 0: "QUESTION_TYPE_UNSPECIFIED", + 1: "QUESTION_TYPE_TEXT", + 2: "QUESTION_TYPE_BOOL", + } + QuestionType_value = map[string]int32{ + "QUESTION_TYPE_UNSPECIFIED": 0, + "QUESTION_TYPE_TEXT": 1, + "QUESTION_TYPE_BOOL": 2, + } +) + +func (x QuestionType) Enum() *QuestionType { + p := new(QuestionType) + *p = x + return p +} + +func (x QuestionType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (QuestionType) Descriptor() protoreflect.EnumDescriptor { + return file_hackathon_entities_question_proto_enumTypes[0].Descriptor() +} + +func (QuestionType) Type() protoreflect.EnumType { + return &file_hackathon_entities_question_proto_enumTypes[0] +} + +func (x QuestionType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use QuestionType.Descriptor instead. +func (QuestionType) EnumDescriptor() ([]byte, []int) { + return file_hackathon_entities_question_proto_rawDescGZIP(), []int{0} +} + +type Question struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"` + Type QuestionType `protobuf:"varint,4,opt,name=type,proto3,enum=hackathon.entities.QuestionType" json:"type,omitempty"` + Mandatory bool `protobuf:"varint,5,opt,name=mandatory,proto3" json:"mandatory,omitempty"` + Order int32 `protobuf:"varint,6,opt,name=order,proto3" json:"order,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Question) Reset() { + *x = Question{} + mi := &file_hackathon_entities_question_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Question) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Question) ProtoMessage() {} + +func (x *Question) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_entities_question_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Question.ProtoReflect.Descriptor instead. +func (*Question) Descriptor() ([]byte, []int) { + return file_hackathon_entities_question_proto_rawDescGZIP(), []int{0} +} + +func (x *Question) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Question) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Question) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *Question) GetType() QuestionType { + if x != nil { + return x.Type + } + return QuestionType_QUESTION_TYPE_UNSPECIFIED +} + +func (x *Question) GetMandatory() bool { + if x != nil { + return x.Mandatory + } + return false +} + +func (x *Question) GetOrder() int32 { + if x != nil { + return x.Order + } + return 0 +} + +var File_hackathon_entities_question_proto protoreflect.FileDescriptor + +const file_hackathon_entities_question_proto_rawDesc = "" + + "\n" + + "!hackathon/entities/question.proto\x12\x12hackathon.entities\x1a\x1bbuf/validate/validate.proto\"\xd0\x01\n" + + "\bQuestion\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12*\n" + + "\x03key\x18\x02 \x01(\tB\x18\xbaH\x15r\x132\x11^[a-z][a-z0-9_]*$R\x03key\x12\x14\n" + + "\x05label\x18\x03 \x01(\tR\x05label\x12>\n" + + "\x04type\x18\x04 \x01(\x0e2 .hackathon.entities.QuestionTypeB\b\xbaH\x05\x82\x01\x02\x10\x01R\x04type\x12\x1c\n" + + "\tmandatory\x18\x05 \x01(\bR\tmandatory\x12\x14\n" + + "\x05order\x18\x06 \x01(\x05R\x05order*]\n" + + "\fQuestionType\x12\x1d\n" + + "\x19QUESTION_TYPE_UNSPECIFIED\x10\x00\x12\x16\n" + + "\x12QUESTION_TYPE_TEXT\x10\x01\x12\x16\n" + + "\x12QUESTION_TYPE_BOOL\x10\x02BaZ_github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entitiesb\x06proto3" + +var ( + file_hackathon_entities_question_proto_rawDescOnce sync.Once + file_hackathon_entities_question_proto_rawDescData []byte +) + +func file_hackathon_entities_question_proto_rawDescGZIP() []byte { + file_hackathon_entities_question_proto_rawDescOnce.Do(func() { + file_hackathon_entities_question_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_entities_question_proto_rawDesc), len(file_hackathon_entities_question_proto_rawDesc))) + }) + return file_hackathon_entities_question_proto_rawDescData +} + +var file_hackathon_entities_question_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_hackathon_entities_question_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_entities_question_proto_goTypes = []any{ + (QuestionType)(0), // 0: hackathon.entities.QuestionType + (*Question)(nil), // 1: hackathon.entities.Question +} +var file_hackathon_entities_question_proto_depIdxs = []int32{ + 0, // 0: hackathon.entities.Question.type:type_name -> hackathon.entities.QuestionType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_hackathon_entities_question_proto_init() } +func file_hackathon_entities_question_proto_init() { + if File_hackathon_entities_question_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_entities_question_proto_rawDesc), len(file_hackathon_entities_question_proto_rawDesc)), + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_entities_question_proto_goTypes, + DependencyIndexes: file_hackathon_entities_question_proto_depIdxs, + EnumInfos: file_hackathon_entities_question_proto_enumTypes, + MessageInfos: file_hackathon_entities_question_proto_msgTypes, + }.Build() + File_hackathon_entities_question_proto = out.File + file_hackathon_entities_question_proto_goTypes = nil + file_hackathon_entities_question_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/hackathon_service.pb.go b/components/backend/internal/proto/hackathon/hackathon_service.pb.go index e42ba462..fae78db6 100644 --- a/components/backend/internal/proto/hackathon/hackathon_service.pb.go +++ b/components/backend/internal/proto/hackathon/hackathon_service.pb.go @@ -25,8 +25,7 @@ var File_hackathon_hackathon_service_proto protoreflect.FileDescriptor const file_hackathon_hackathon_service_proto_rawDesc = "" + "\n" + - "!hackathon/hackathon_service.proto\x12\thackathon\x1a8hackathon/messages/hackathon_svc/add_owner_request.proto\x1a9hackathon/messages/hackathon_svc/add_owner_response.proto\x1aBhackathon/messages/hackathon_svc/approve_participant_request.proto\x1aChackathon/messages/hackathon_svc/approve_participant_response.proto\x1a5hackathon/messages/hackathon_svc/create_request.proto\x1a6hackathon/messages/hackathon_svc/create_response.proto\x1a3hackathon/messages/hackathon_svc/edit_request.proto\x1a4hackathon/messages/hackathon_svc/edit_response.proto\x1a2hackathon/messages/hackathon_svc/get_request.proto\x1a3hackathon/messages/hackathon_svc/get_response.proto\x1a3hackathon/messages/hackathon_svc/join_request.proto\x1a4hackathon/messages/hackathon_svc/join_response.proto\x1a3hackathon/messages/hackathon_svc/list_request.proto\x1a4hackathon/messages/hackathon_svc/list_response.proto\x1a;hackathon/messages/hackathon_svc/remove_owner_request.proto\x1ahackathon/messages/hackathon_svc/create_question_request.proto\x1a?hackathon/messages/hackathon_svc/create_question_response.proto\x1a5hackathon/messages/hackathon_svc/create_request.proto\x1a6hackathon/messages/hackathon_svc/create_response.proto\x1ahackathon/messages/hackathon_svc/list_questions_response.proto\x1a3hackathon/messages/hackathon_svc/list_request.proto\x1a4hackathon/messages/hackathon_svc/list_response.proto\x1a;hackathon/messages/hackathon_svc/remove_owner_request.proto\x1ahackathon/messages/hackathon_svc/remove_question_request.proto\x1a?hackathon/messages/hackathon_svc/remove_question_response.proto\x1a?hackathon/messages/hackathon_svc/set_capabilities_request.proto\x1a@hackathon/messages/hackathon_svc/set_capabilities_response.proto\x1a@hackathon/messages/hackathon_svc/set_current_phase_request.proto\x1aAhackathon/messages/hackathon_svc/set_current_phase_response.proto\x1a=hackathon/messages/hackathon_svc/submit_answers_request.proto\x1a>hackathon/messages/hackathon_svc/submit_answers_response.proto2\xe9\x10\n" + "\x10HackathonService\x12e\n" + "\x04List\x12-.hackathon.messages.hackathon_svc.ListRequest\x1a..hackathon.messages.hackathon_svc.ListResponse\x12b\n" + "\x03Get\x12,.hackathon.messages.hackathon_svc.GetRequest\x1a-.hackathon.messages.hackathon_svc.GetResponse\x12k\n" + @@ -38,31 +37,49 @@ const file_hackathon_hackathon_service_proto_rawDesc = "" + "\x12ApproveParticipant\x12;.hackathon.messages.hackathon_svc.ApproveParticipantRequest\x1a<.hackathon.messages.hackathon_svc.ApproveParticipantResponse\x12\x8c\x01\n" + "\x11RemoveParticipant\x12:.hackathon.messages.hackathon_svc.RemoveParticipantRequest\x1a;.hackathon.messages.hackathon_svc.RemoveParticipantResponse\x12q\n" + "\bAddOwner\x121.hackathon.messages.hackathon_svc.AddOwnerRequest\x1a2.hackathon.messages.hackathon_svc.AddOwnerResponse\x12z\n" + - "\vRemoveOwner\x124.hackathon.messages.hackathon_svc.RemoveOwnerRequest\x1a5.hackathon.messages.hackathon_svc.RemoveOwnerResponseBXZVgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathonb\x06proto3" + "\vRemoveOwner\x124.hackathon.messages.hackathon_svc.RemoveOwnerRequest\x1a5.hackathon.messages.hackathon_svc.RemoveOwnerResponse\x12\x83\x01\n" + + "\x0eCreateQuestion\x127.hackathon.messages.hackathon_svc.CreateQuestionRequest\x1a8.hackathon.messages.hackathon_svc.CreateQuestionResponse\x12}\n" + + "\fEditQuestion\x125.hackathon.messages.hackathon_svc.EditQuestionRequest\x1a6.hackathon.messages.hackathon_svc.EditQuestionResponse\x12\x83\x01\n" + + "\x0eRemoveQuestion\x127.hackathon.messages.hackathon_svc.RemoveQuestionRequest\x1a8.hackathon.messages.hackathon_svc.RemoveQuestionResponse\x12\x80\x01\n" + + "\rListQuestions\x126.hackathon.messages.hackathon_svc.ListQuestionsRequest\x1a7.hackathon.messages.hackathon_svc.ListQuestionsResponse\x12\x80\x01\n" + + "\rSubmitAnswers\x126.hackathon.messages.hackathon_svc.SubmitAnswersRequest\x1a7.hackathon.messages.hackathon_svc.SubmitAnswersResponse\x12\x9b\x01\n" + + "\x16ListParticipantAnswers\x12?.hackathon.messages.hackathon_svc.ListParticipantAnswersRequest\x1a@.hackathon.messages.hackathon_svc.ListParticipantAnswersResponseBXZVgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathonb\x06proto3" var file_hackathon_hackathon_service_proto_goTypes = []any{ - (*hackathon_svc.ListRequest)(nil), // 0: hackathon.messages.hackathon_svc.ListRequest - (*hackathon_svc.GetRequest)(nil), // 1: hackathon.messages.hackathon_svc.GetRequest - (*hackathon_svc.CreateRequest)(nil), // 2: hackathon.messages.hackathon_svc.CreateRequest - (*hackathon_svc.EditRequest)(nil), // 3: hackathon.messages.hackathon_svc.EditRequest - (*hackathon_svc.SetCapabilitiesRequest)(nil), // 4: hackathon.messages.hackathon_svc.SetCapabilitiesRequest - (*hackathon_svc.SetCurrentPhaseRequest)(nil), // 5: hackathon.messages.hackathon_svc.SetCurrentPhaseRequest - (*hackathon_svc.JoinRequest)(nil), // 6: hackathon.messages.hackathon_svc.JoinRequest - (*hackathon_svc.ApproveParticipantRequest)(nil), // 7: hackathon.messages.hackathon_svc.ApproveParticipantRequest - (*hackathon_svc.RemoveParticipantRequest)(nil), // 8: hackathon.messages.hackathon_svc.RemoveParticipantRequest - (*hackathon_svc.AddOwnerRequest)(nil), // 9: hackathon.messages.hackathon_svc.AddOwnerRequest - (*hackathon_svc.RemoveOwnerRequest)(nil), // 10: hackathon.messages.hackathon_svc.RemoveOwnerRequest - (*hackathon_svc.ListResponse)(nil), // 11: hackathon.messages.hackathon_svc.ListResponse - (*hackathon_svc.GetResponse)(nil), // 12: hackathon.messages.hackathon_svc.GetResponse - (*hackathon_svc.CreateResponse)(nil), // 13: hackathon.messages.hackathon_svc.CreateResponse - (*hackathon_svc.EditResponse)(nil), // 14: hackathon.messages.hackathon_svc.EditResponse - (*hackathon_svc.SetCapabilitiesResponse)(nil), // 15: hackathon.messages.hackathon_svc.SetCapabilitiesResponse - (*hackathon_svc.SetCurrentPhaseResponse)(nil), // 16: hackathon.messages.hackathon_svc.SetCurrentPhaseResponse - (*hackathon_svc.JoinResponse)(nil), // 17: hackathon.messages.hackathon_svc.JoinResponse - (*hackathon_svc.ApproveParticipantResponse)(nil), // 18: hackathon.messages.hackathon_svc.ApproveParticipantResponse - (*hackathon_svc.RemoveParticipantResponse)(nil), // 19: hackathon.messages.hackathon_svc.RemoveParticipantResponse - (*hackathon_svc.AddOwnerResponse)(nil), // 20: hackathon.messages.hackathon_svc.AddOwnerResponse - (*hackathon_svc.RemoveOwnerResponse)(nil), // 21: hackathon.messages.hackathon_svc.RemoveOwnerResponse + (*hackathon_svc.ListRequest)(nil), // 0: hackathon.messages.hackathon_svc.ListRequest + (*hackathon_svc.GetRequest)(nil), // 1: hackathon.messages.hackathon_svc.GetRequest + (*hackathon_svc.CreateRequest)(nil), // 2: hackathon.messages.hackathon_svc.CreateRequest + (*hackathon_svc.EditRequest)(nil), // 3: hackathon.messages.hackathon_svc.EditRequest + (*hackathon_svc.SetCapabilitiesRequest)(nil), // 4: hackathon.messages.hackathon_svc.SetCapabilitiesRequest + (*hackathon_svc.SetCurrentPhaseRequest)(nil), // 5: hackathon.messages.hackathon_svc.SetCurrentPhaseRequest + (*hackathon_svc.JoinRequest)(nil), // 6: hackathon.messages.hackathon_svc.JoinRequest + (*hackathon_svc.ApproveParticipantRequest)(nil), // 7: hackathon.messages.hackathon_svc.ApproveParticipantRequest + (*hackathon_svc.RemoveParticipantRequest)(nil), // 8: hackathon.messages.hackathon_svc.RemoveParticipantRequest + (*hackathon_svc.AddOwnerRequest)(nil), // 9: hackathon.messages.hackathon_svc.AddOwnerRequest + (*hackathon_svc.RemoveOwnerRequest)(nil), // 10: hackathon.messages.hackathon_svc.RemoveOwnerRequest + (*hackathon_svc.CreateQuestionRequest)(nil), // 11: hackathon.messages.hackathon_svc.CreateQuestionRequest + (*hackathon_svc.EditQuestionRequest)(nil), // 12: hackathon.messages.hackathon_svc.EditQuestionRequest + (*hackathon_svc.RemoveQuestionRequest)(nil), // 13: hackathon.messages.hackathon_svc.RemoveQuestionRequest + (*hackathon_svc.ListQuestionsRequest)(nil), // 14: hackathon.messages.hackathon_svc.ListQuestionsRequest + (*hackathon_svc.SubmitAnswersRequest)(nil), // 15: hackathon.messages.hackathon_svc.SubmitAnswersRequest + (*hackathon_svc.ListParticipantAnswersRequest)(nil), // 16: hackathon.messages.hackathon_svc.ListParticipantAnswersRequest + (*hackathon_svc.ListResponse)(nil), // 17: hackathon.messages.hackathon_svc.ListResponse + (*hackathon_svc.GetResponse)(nil), // 18: hackathon.messages.hackathon_svc.GetResponse + (*hackathon_svc.CreateResponse)(nil), // 19: hackathon.messages.hackathon_svc.CreateResponse + (*hackathon_svc.EditResponse)(nil), // 20: hackathon.messages.hackathon_svc.EditResponse + (*hackathon_svc.SetCapabilitiesResponse)(nil), // 21: hackathon.messages.hackathon_svc.SetCapabilitiesResponse + (*hackathon_svc.SetCurrentPhaseResponse)(nil), // 22: hackathon.messages.hackathon_svc.SetCurrentPhaseResponse + (*hackathon_svc.JoinResponse)(nil), // 23: hackathon.messages.hackathon_svc.JoinResponse + (*hackathon_svc.ApproveParticipantResponse)(nil), // 24: hackathon.messages.hackathon_svc.ApproveParticipantResponse + (*hackathon_svc.RemoveParticipantResponse)(nil), // 25: hackathon.messages.hackathon_svc.RemoveParticipantResponse + (*hackathon_svc.AddOwnerResponse)(nil), // 26: hackathon.messages.hackathon_svc.AddOwnerResponse + (*hackathon_svc.RemoveOwnerResponse)(nil), // 27: hackathon.messages.hackathon_svc.RemoveOwnerResponse + (*hackathon_svc.CreateQuestionResponse)(nil), // 28: hackathon.messages.hackathon_svc.CreateQuestionResponse + (*hackathon_svc.EditQuestionResponse)(nil), // 29: hackathon.messages.hackathon_svc.EditQuestionResponse + (*hackathon_svc.RemoveQuestionResponse)(nil), // 30: hackathon.messages.hackathon_svc.RemoveQuestionResponse + (*hackathon_svc.ListQuestionsResponse)(nil), // 31: hackathon.messages.hackathon_svc.ListQuestionsResponse + (*hackathon_svc.SubmitAnswersResponse)(nil), // 32: hackathon.messages.hackathon_svc.SubmitAnswersResponse + (*hackathon_svc.ListParticipantAnswersResponse)(nil), // 33: hackathon.messages.hackathon_svc.ListParticipantAnswersResponse } var file_hackathon_hackathon_service_proto_depIdxs = []int32{ 0, // 0: hackathon.HackathonService.List:input_type -> hackathon.messages.hackathon_svc.ListRequest @@ -76,19 +93,31 @@ var file_hackathon_hackathon_service_proto_depIdxs = []int32{ 8, // 8: hackathon.HackathonService.RemoveParticipant:input_type -> hackathon.messages.hackathon_svc.RemoveParticipantRequest 9, // 9: hackathon.HackathonService.AddOwner:input_type -> hackathon.messages.hackathon_svc.AddOwnerRequest 10, // 10: hackathon.HackathonService.RemoveOwner:input_type -> hackathon.messages.hackathon_svc.RemoveOwnerRequest - 11, // 11: hackathon.HackathonService.List:output_type -> hackathon.messages.hackathon_svc.ListResponse - 12, // 12: hackathon.HackathonService.Get:output_type -> hackathon.messages.hackathon_svc.GetResponse - 13, // 13: hackathon.HackathonService.Create:output_type -> hackathon.messages.hackathon_svc.CreateResponse - 14, // 14: hackathon.HackathonService.Edit:output_type -> hackathon.messages.hackathon_svc.EditResponse - 15, // 15: hackathon.HackathonService.SetCapabilities:output_type -> hackathon.messages.hackathon_svc.SetCapabilitiesResponse - 16, // 16: hackathon.HackathonService.SetCurrentPhase:output_type -> hackathon.messages.hackathon_svc.SetCurrentPhaseResponse - 17, // 17: hackathon.HackathonService.Join:output_type -> hackathon.messages.hackathon_svc.JoinResponse - 18, // 18: hackathon.HackathonService.ApproveParticipant:output_type -> hackathon.messages.hackathon_svc.ApproveParticipantResponse - 19, // 19: hackathon.HackathonService.RemoveParticipant:output_type -> hackathon.messages.hackathon_svc.RemoveParticipantResponse - 20, // 20: hackathon.HackathonService.AddOwner:output_type -> hackathon.messages.hackathon_svc.AddOwnerResponse - 21, // 21: hackathon.HackathonService.RemoveOwner:output_type -> hackathon.messages.hackathon_svc.RemoveOwnerResponse - 11, // [11:22] is the sub-list for method output_type - 0, // [0:11] is the sub-list for method input_type + 11, // 11: hackathon.HackathonService.CreateQuestion:input_type -> hackathon.messages.hackathon_svc.CreateQuestionRequest + 12, // 12: hackathon.HackathonService.EditQuestion:input_type -> hackathon.messages.hackathon_svc.EditQuestionRequest + 13, // 13: hackathon.HackathonService.RemoveQuestion:input_type -> hackathon.messages.hackathon_svc.RemoveQuestionRequest + 14, // 14: hackathon.HackathonService.ListQuestions:input_type -> hackathon.messages.hackathon_svc.ListQuestionsRequest + 15, // 15: hackathon.HackathonService.SubmitAnswers:input_type -> hackathon.messages.hackathon_svc.SubmitAnswersRequest + 16, // 16: hackathon.HackathonService.ListParticipantAnswers:input_type -> hackathon.messages.hackathon_svc.ListParticipantAnswersRequest + 17, // 17: hackathon.HackathonService.List:output_type -> hackathon.messages.hackathon_svc.ListResponse + 18, // 18: hackathon.HackathonService.Get:output_type -> hackathon.messages.hackathon_svc.GetResponse + 19, // 19: hackathon.HackathonService.Create:output_type -> hackathon.messages.hackathon_svc.CreateResponse + 20, // 20: hackathon.HackathonService.Edit:output_type -> hackathon.messages.hackathon_svc.EditResponse + 21, // 21: hackathon.HackathonService.SetCapabilities:output_type -> hackathon.messages.hackathon_svc.SetCapabilitiesResponse + 22, // 22: hackathon.HackathonService.SetCurrentPhase:output_type -> hackathon.messages.hackathon_svc.SetCurrentPhaseResponse + 23, // 23: hackathon.HackathonService.Join:output_type -> hackathon.messages.hackathon_svc.JoinResponse + 24, // 24: hackathon.HackathonService.ApproveParticipant:output_type -> hackathon.messages.hackathon_svc.ApproveParticipantResponse + 25, // 25: hackathon.HackathonService.RemoveParticipant:output_type -> hackathon.messages.hackathon_svc.RemoveParticipantResponse + 26, // 26: hackathon.HackathonService.AddOwner:output_type -> hackathon.messages.hackathon_svc.AddOwnerResponse + 27, // 27: hackathon.HackathonService.RemoveOwner:output_type -> hackathon.messages.hackathon_svc.RemoveOwnerResponse + 28, // 28: hackathon.HackathonService.CreateQuestion:output_type -> hackathon.messages.hackathon_svc.CreateQuestionResponse + 29, // 29: hackathon.HackathonService.EditQuestion:output_type -> hackathon.messages.hackathon_svc.EditQuestionResponse + 30, // 30: hackathon.HackathonService.RemoveQuestion:output_type -> hackathon.messages.hackathon_svc.RemoveQuestionResponse + 31, // 31: hackathon.HackathonService.ListQuestions:output_type -> hackathon.messages.hackathon_svc.ListQuestionsResponse + 32, // 32: hackathon.HackathonService.SubmitAnswers:output_type -> hackathon.messages.hackathon_svc.SubmitAnswersResponse + 33, // 33: hackathon.HackathonService.ListParticipantAnswers:output_type -> hackathon.messages.hackathon_svc.ListParticipantAnswersResponse + 17, // [17:34] is the sub-list for method output_type + 0, // [0:17] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name diff --git a/components/backend/internal/proto/hackathon/hackathon_service_grpc.pb.go b/components/backend/internal/proto/hackathon/hackathon_service_grpc.pb.go index 5588d241..777bd03a 100644 --- a/components/backend/internal/proto/hackathon/hackathon_service_grpc.pb.go +++ b/components/backend/internal/proto/hackathon/hackathon_service_grpc.pb.go @@ -20,17 +20,23 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - HackathonService_List_FullMethodName = "/hackathon.HackathonService/List" - HackathonService_Get_FullMethodName = "/hackathon.HackathonService/Get" - HackathonService_Create_FullMethodName = "/hackathon.HackathonService/Create" - HackathonService_Edit_FullMethodName = "/hackathon.HackathonService/Edit" - HackathonService_SetCapabilities_FullMethodName = "/hackathon.HackathonService/SetCapabilities" - HackathonService_SetCurrentPhase_FullMethodName = "/hackathon.HackathonService/SetCurrentPhase" - HackathonService_Join_FullMethodName = "/hackathon.HackathonService/Join" - HackathonService_ApproveParticipant_FullMethodName = "/hackathon.HackathonService/ApproveParticipant" - HackathonService_RemoveParticipant_FullMethodName = "/hackathon.HackathonService/RemoveParticipant" - HackathonService_AddOwner_FullMethodName = "/hackathon.HackathonService/AddOwner" - HackathonService_RemoveOwner_FullMethodName = "/hackathon.HackathonService/RemoveOwner" + HackathonService_List_FullMethodName = "/hackathon.HackathonService/List" + HackathonService_Get_FullMethodName = "/hackathon.HackathonService/Get" + HackathonService_Create_FullMethodName = "/hackathon.HackathonService/Create" + HackathonService_Edit_FullMethodName = "/hackathon.HackathonService/Edit" + HackathonService_SetCapabilities_FullMethodName = "/hackathon.HackathonService/SetCapabilities" + HackathonService_SetCurrentPhase_FullMethodName = "/hackathon.HackathonService/SetCurrentPhase" + HackathonService_Join_FullMethodName = "/hackathon.HackathonService/Join" + HackathonService_ApproveParticipant_FullMethodName = "/hackathon.HackathonService/ApproveParticipant" + HackathonService_RemoveParticipant_FullMethodName = "/hackathon.HackathonService/RemoveParticipant" + HackathonService_AddOwner_FullMethodName = "/hackathon.HackathonService/AddOwner" + HackathonService_RemoveOwner_FullMethodName = "/hackathon.HackathonService/RemoveOwner" + HackathonService_CreateQuestion_FullMethodName = "/hackathon.HackathonService/CreateQuestion" + HackathonService_EditQuestion_FullMethodName = "/hackathon.HackathonService/EditQuestion" + HackathonService_RemoveQuestion_FullMethodName = "/hackathon.HackathonService/RemoveQuestion" + HackathonService_ListQuestions_FullMethodName = "/hackathon.HackathonService/ListQuestions" + HackathonService_SubmitAnswers_FullMethodName = "/hackathon.HackathonService/SubmitAnswers" + HackathonService_ListParticipantAnswers_FullMethodName = "/hackathon.HackathonService/ListParticipantAnswers" ) // HackathonServiceClient is the client API for HackathonService service. @@ -48,6 +54,14 @@ type HackathonServiceClient interface { RemoveParticipant(ctx context.Context, in *hackathon_svc.RemoveParticipantRequest, opts ...grpc.CallOption) (*hackathon_svc.RemoveParticipantResponse, error) AddOwner(ctx context.Context, in *hackathon_svc.AddOwnerRequest, opts ...grpc.CallOption) (*hackathon_svc.AddOwnerResponse, error) RemoveOwner(ctx context.Context, in *hackathon_svc.RemoveOwnerRequest, opts ...grpc.CallOption) (*hackathon_svc.RemoveOwnerResponse, error) + // Registration questions + CreateQuestion(ctx context.Context, in *hackathon_svc.CreateQuestionRequest, opts ...grpc.CallOption) (*hackathon_svc.CreateQuestionResponse, error) + EditQuestion(ctx context.Context, in *hackathon_svc.EditQuestionRequest, opts ...grpc.CallOption) (*hackathon_svc.EditQuestionResponse, error) + RemoveQuestion(ctx context.Context, in *hackathon_svc.RemoveQuestionRequest, opts ...grpc.CallOption) (*hackathon_svc.RemoveQuestionResponse, error) + ListQuestions(ctx context.Context, in *hackathon_svc.ListQuestionsRequest, opts ...grpc.CallOption) (*hackathon_svc.ListQuestionsResponse, error) + SubmitAnswers(ctx context.Context, in *hackathon_svc.SubmitAnswersRequest, opts ...grpc.CallOption) (*hackathon_svc.SubmitAnswersResponse, error) + // Participant answers (admin) + ListParticipantAnswers(ctx context.Context, in *hackathon_svc.ListParticipantAnswersRequest, opts ...grpc.CallOption) (*hackathon_svc.ListParticipantAnswersResponse, error) } type hackathonServiceClient struct { @@ -168,6 +182,66 @@ func (c *hackathonServiceClient) RemoveOwner(ctx context.Context, in *hackathon_ return out, nil } +func (c *hackathonServiceClient) CreateQuestion(ctx context.Context, in *hackathon_svc.CreateQuestionRequest, opts ...grpc.CallOption) (*hackathon_svc.CreateQuestionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(hackathon_svc.CreateQuestionResponse) + err := c.cc.Invoke(ctx, HackathonService_CreateQuestion_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hackathonServiceClient) EditQuestion(ctx context.Context, in *hackathon_svc.EditQuestionRequest, opts ...grpc.CallOption) (*hackathon_svc.EditQuestionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(hackathon_svc.EditQuestionResponse) + err := c.cc.Invoke(ctx, HackathonService_EditQuestion_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hackathonServiceClient) RemoveQuestion(ctx context.Context, in *hackathon_svc.RemoveQuestionRequest, opts ...grpc.CallOption) (*hackathon_svc.RemoveQuestionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(hackathon_svc.RemoveQuestionResponse) + err := c.cc.Invoke(ctx, HackathonService_RemoveQuestion_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hackathonServiceClient) ListQuestions(ctx context.Context, in *hackathon_svc.ListQuestionsRequest, opts ...grpc.CallOption) (*hackathon_svc.ListQuestionsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(hackathon_svc.ListQuestionsResponse) + err := c.cc.Invoke(ctx, HackathonService_ListQuestions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hackathonServiceClient) SubmitAnswers(ctx context.Context, in *hackathon_svc.SubmitAnswersRequest, opts ...grpc.CallOption) (*hackathon_svc.SubmitAnswersResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(hackathon_svc.SubmitAnswersResponse) + err := c.cc.Invoke(ctx, HackathonService_SubmitAnswers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hackathonServiceClient) ListParticipantAnswers(ctx context.Context, in *hackathon_svc.ListParticipantAnswersRequest, opts ...grpc.CallOption) (*hackathon_svc.ListParticipantAnswersResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(hackathon_svc.ListParticipantAnswersResponse) + err := c.cc.Invoke(ctx, HackathonService_ListParticipantAnswers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // HackathonServiceServer is the server API for HackathonService service. // All implementations must embed UnimplementedHackathonServiceServer // for forward compatibility. @@ -183,6 +257,14 @@ type HackathonServiceServer interface { RemoveParticipant(context.Context, *hackathon_svc.RemoveParticipantRequest) (*hackathon_svc.RemoveParticipantResponse, error) AddOwner(context.Context, *hackathon_svc.AddOwnerRequest) (*hackathon_svc.AddOwnerResponse, error) RemoveOwner(context.Context, *hackathon_svc.RemoveOwnerRequest) (*hackathon_svc.RemoveOwnerResponse, error) + // Registration questions + CreateQuestion(context.Context, *hackathon_svc.CreateQuestionRequest) (*hackathon_svc.CreateQuestionResponse, error) + EditQuestion(context.Context, *hackathon_svc.EditQuestionRequest) (*hackathon_svc.EditQuestionResponse, error) + RemoveQuestion(context.Context, *hackathon_svc.RemoveQuestionRequest) (*hackathon_svc.RemoveQuestionResponse, error) + ListQuestions(context.Context, *hackathon_svc.ListQuestionsRequest) (*hackathon_svc.ListQuestionsResponse, error) + SubmitAnswers(context.Context, *hackathon_svc.SubmitAnswersRequest) (*hackathon_svc.SubmitAnswersResponse, error) + // Participant answers (admin) + ListParticipantAnswers(context.Context, *hackathon_svc.ListParticipantAnswersRequest) (*hackathon_svc.ListParticipantAnswersResponse, error) mustEmbedUnimplementedHackathonServiceServer() } @@ -226,6 +308,24 @@ func (UnimplementedHackathonServiceServer) AddOwner(context.Context, *hackathon_ func (UnimplementedHackathonServiceServer) RemoveOwner(context.Context, *hackathon_svc.RemoveOwnerRequest) (*hackathon_svc.RemoveOwnerResponse, error) { return nil, status.Error(codes.Unimplemented, "method RemoveOwner not implemented") } +func (UnimplementedHackathonServiceServer) CreateQuestion(context.Context, *hackathon_svc.CreateQuestionRequest) (*hackathon_svc.CreateQuestionResponse, error) { + return nil, status.Error(codes.Unimplemented, "method CreateQuestion not implemented") +} +func (UnimplementedHackathonServiceServer) EditQuestion(context.Context, *hackathon_svc.EditQuestionRequest) (*hackathon_svc.EditQuestionResponse, error) { + return nil, status.Error(codes.Unimplemented, "method EditQuestion not implemented") +} +func (UnimplementedHackathonServiceServer) RemoveQuestion(context.Context, *hackathon_svc.RemoveQuestionRequest) (*hackathon_svc.RemoveQuestionResponse, error) { + return nil, status.Error(codes.Unimplemented, "method RemoveQuestion not implemented") +} +func (UnimplementedHackathonServiceServer) ListQuestions(context.Context, *hackathon_svc.ListQuestionsRequest) (*hackathon_svc.ListQuestionsResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ListQuestions not implemented") +} +func (UnimplementedHackathonServiceServer) SubmitAnswers(context.Context, *hackathon_svc.SubmitAnswersRequest) (*hackathon_svc.SubmitAnswersResponse, error) { + return nil, status.Error(codes.Unimplemented, "method SubmitAnswers not implemented") +} +func (UnimplementedHackathonServiceServer) ListParticipantAnswers(context.Context, *hackathon_svc.ListParticipantAnswersRequest) (*hackathon_svc.ListParticipantAnswersResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ListParticipantAnswers not implemented") +} func (UnimplementedHackathonServiceServer) mustEmbedUnimplementedHackathonServiceServer() {} func (UnimplementedHackathonServiceServer) testEmbeddedByValue() {} @@ -445,6 +545,114 @@ func _HackathonService_RemoveOwner_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _HackathonService_CreateQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(hackathon_svc.CreateQuestionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HackathonServiceServer).CreateQuestion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HackathonService_CreateQuestion_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HackathonServiceServer).CreateQuestion(ctx, req.(*hackathon_svc.CreateQuestionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HackathonService_EditQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(hackathon_svc.EditQuestionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HackathonServiceServer).EditQuestion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HackathonService_EditQuestion_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HackathonServiceServer).EditQuestion(ctx, req.(*hackathon_svc.EditQuestionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HackathonService_RemoveQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(hackathon_svc.RemoveQuestionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HackathonServiceServer).RemoveQuestion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HackathonService_RemoveQuestion_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HackathonServiceServer).RemoveQuestion(ctx, req.(*hackathon_svc.RemoveQuestionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HackathonService_ListQuestions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(hackathon_svc.ListQuestionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HackathonServiceServer).ListQuestions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HackathonService_ListQuestions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HackathonServiceServer).ListQuestions(ctx, req.(*hackathon_svc.ListQuestionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HackathonService_SubmitAnswers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(hackathon_svc.SubmitAnswersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HackathonServiceServer).SubmitAnswers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HackathonService_SubmitAnswers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HackathonServiceServer).SubmitAnswers(ctx, req.(*hackathon_svc.SubmitAnswersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HackathonService_ListParticipantAnswers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(hackathon_svc.ListParticipantAnswersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HackathonServiceServer).ListParticipantAnswers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HackathonService_ListParticipantAnswers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HackathonServiceServer).ListParticipantAnswers(ctx, req.(*hackathon_svc.ListParticipantAnswersRequest)) + } + return interceptor(ctx, in, info, handler) +} + // HackathonService_ServiceDesc is the grpc.ServiceDesc for HackathonService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -496,6 +704,30 @@ var HackathonService_ServiceDesc = grpc.ServiceDesc{ MethodName: "RemoveOwner", Handler: _HackathonService_RemoveOwner_Handler, }, + { + MethodName: "CreateQuestion", + Handler: _HackathonService_CreateQuestion_Handler, + }, + { + MethodName: "EditQuestion", + Handler: _HackathonService_EditQuestion_Handler, + }, + { + MethodName: "RemoveQuestion", + Handler: _HackathonService_RemoveQuestion_Handler, + }, + { + MethodName: "ListQuestions", + Handler: _HackathonService_ListQuestions_Handler, + }, + { + MethodName: "SubmitAnswers", + Handler: _HackathonService_SubmitAnswers_Handler, + }, + { + MethodName: "ListParticipantAnswers", + Handler: _HackathonService_ListParticipantAnswers_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "hackathon/hackathon_service.proto", diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_request.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_request.pb.go new file mode 100644 index 00000000..37eaf175 --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_request.pb.go @@ -0,0 +1,172 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/create_question_request.proto + +package hackathon_svc + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + entities "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CreateQuestionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + HackathonId string `protobuf:"bytes,1,opt,name=hackathon_id,json=hackathonId,proto3" json:"hackathon_id,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"` + Type entities.QuestionType `protobuf:"varint,4,opt,name=type,proto3,enum=hackathon.entities.QuestionType" json:"type,omitempty"` + Mandatory bool `protobuf:"varint,5,opt,name=mandatory,proto3" json:"mandatory,omitempty"` + Order int32 `protobuf:"varint,6,opt,name=order,proto3" json:"order,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateQuestionRequest) Reset() { + *x = CreateQuestionRequest{} + mi := &file_hackathon_messages_hackathon_svc_create_question_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateQuestionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateQuestionRequest) ProtoMessage() {} + +func (x *CreateQuestionRequest) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_create_question_request_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateQuestionRequest.ProtoReflect.Descriptor instead. +func (*CreateQuestionRequest) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateQuestionRequest) GetHackathonId() string { + if x != nil { + return x.HackathonId + } + return "" +} + +func (x *CreateQuestionRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *CreateQuestionRequest) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *CreateQuestionRequest) GetType() entities.QuestionType { + if x != nil { + return x.Type + } + return entities.QuestionType(0) +} + +func (x *CreateQuestionRequest) GetMandatory() bool { + if x != nil { + return x.Mandatory + } + return false +} + +func (x *CreateQuestionRequest) GetOrder() int32 { + if x != nil { + return x.Order + } + return 0 +} + +var File_hackathon_messages_hackathon_svc_create_question_request_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDesc = "" + + "\n" + + ">hackathon/messages/hackathon_svc/create_question_request.proto\x12 hackathon.messages.hackathon_svc\x1a\x1bbuf/validate/validate.proto\x1a!hackathon/entities/question.proto\"\x8a\x02\n" + + "\x15CreateQuestionRequest\x12+\n" + + "\fhackathon_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\vhackathonId\x12.\n" + + "\x03key\x18\x02 \x01(\tB\x1c\xbaH\x19r\x17\x10\x01\x18@2\x11^[a-z][a-z0-9_]*$R\x03key\x12 \n" + + "\x05label\x18\x03 \x01(\tB\n" + + "\xbaH\ar\x05\x10\x01\x18\xff\x01R\x05label\x12>\n" + + "\x04type\x18\x04 \x01(\x0e2 .hackathon.entities.QuestionTypeB\b\xbaH\x05\x82\x01\x02\x10\x01R\x04type\x12\x1c\n" + + "\tmandatory\x18\x05 \x01(\bR\tmandatory\x12\x14\n" + + "\x05order\x18\x06 \x01(\x05R\x05orderBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_create_question_request_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_create_question_request_proto_goTypes = []any{ + (*CreateQuestionRequest)(nil), // 0: hackathon.messages.hackathon_svc.CreateQuestionRequest + (entities.QuestionType)(0), // 1: hackathon.entities.QuestionType +} +var file_hackathon_messages_hackathon_svc_create_question_request_proto_depIdxs = []int32{ + 1, // 0: hackathon.messages.hackathon_svc.CreateQuestionRequest.type:type_name -> hackathon.entities.QuestionType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_create_question_request_proto_init() } +func file_hackathon_messages_hackathon_svc_create_question_request_proto_init() { + if File_hackathon_messages_hackathon_svc_create_question_request_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_create_question_request_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_create_question_request_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_create_question_request_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_create_question_request_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_create_question_request_proto = out.File + file_hackathon_messages_hackathon_svc_create_question_request_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_create_question_request_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_response.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_response.pb.go new file mode 100644 index 00000000..ffba4a1e --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/create_question_response.pb.go @@ -0,0 +1,123 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/create_question_response.proto + +package hackathon_svc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CreateQuestionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + QuestionId string `protobuf:"bytes,1,opt,name=question_id,json=questionId,proto3" json:"question_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateQuestionResponse) Reset() { + *x = CreateQuestionResponse{} + mi := &file_hackathon_messages_hackathon_svc_create_question_response_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateQuestionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateQuestionResponse) ProtoMessage() {} + +func (x *CreateQuestionResponse) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_create_question_response_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateQuestionResponse.ProtoReflect.Descriptor instead. +func (*CreateQuestionResponse) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateQuestionResponse) GetQuestionId() string { + if x != nil { + return x.QuestionId + } + return "" +} + +var File_hackathon_messages_hackathon_svc_create_question_response_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDesc = "" + + "\n" + + "?hackathon/messages/hackathon_svc/create_question_response.proto\x12 hackathon.messages.hackathon_svc\"9\n" + + "\x16CreateQuestionResponse\x12\x1f\n" + + "\vquestion_id\x18\x01 \x01(\tR\n" + + "questionIdBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_create_question_response_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_create_question_response_proto_goTypes = []any{ + (*CreateQuestionResponse)(nil), // 0: hackathon.messages.hackathon_svc.CreateQuestionResponse +} +var file_hackathon_messages_hackathon_svc_create_question_response_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_create_question_response_proto_init() } +func file_hackathon_messages_hackathon_svc_create_question_response_proto_init() { + if File_hackathon_messages_hackathon_svc_create_question_response_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_create_question_response_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_create_question_response_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_create_question_response_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_create_question_response_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_create_question_response_proto = out.File + file_hackathon_messages_hackathon_svc_create_question_response_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_create_question_response_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_request.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_request.pb.go new file mode 100644 index 00000000..525b637d --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_request.pb.go @@ -0,0 +1,179 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/edit_question_request.proto + +package hackathon_svc + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + entities "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type EditQuestionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + HackathonId string `protobuf:"bytes,1,opt,name=hackathon_id,json=hackathonId,proto3" json:"hackathon_id,omitempty"` + QuestionId string `protobuf:"bytes,2,opt,name=question_id,json=questionId,proto3" json:"question_id,omitempty"` + Label *string `protobuf:"bytes,3,opt,name=label,proto3,oneof" json:"label,omitempty"` + Type *entities.QuestionType `protobuf:"varint,4,opt,name=type,proto3,enum=hackathon.entities.QuestionType,oneof" json:"type,omitempty"` + Mandatory *bool `protobuf:"varint,5,opt,name=mandatory,proto3,oneof" json:"mandatory,omitempty"` + Order *int32 `protobuf:"varint,6,opt,name=order,proto3,oneof" json:"order,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EditQuestionRequest) Reset() { + *x = EditQuestionRequest{} + mi := &file_hackathon_messages_hackathon_svc_edit_question_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EditQuestionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EditQuestionRequest) ProtoMessage() {} + +func (x *EditQuestionRequest) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_edit_question_request_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EditQuestionRequest.ProtoReflect.Descriptor instead. +func (*EditQuestionRequest) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_edit_question_request_proto_rawDescGZIP(), []int{0} +} + +func (x *EditQuestionRequest) GetHackathonId() string { + if x != nil { + return x.HackathonId + } + return "" +} + +func (x *EditQuestionRequest) GetQuestionId() string { + if x != nil { + return x.QuestionId + } + return "" +} + +func (x *EditQuestionRequest) GetLabel() string { + if x != nil && x.Label != nil { + return *x.Label + } + return "" +} + +func (x *EditQuestionRequest) GetType() entities.QuestionType { + if x != nil && x.Type != nil { + return *x.Type + } + return entities.QuestionType(0) +} + +func (x *EditQuestionRequest) GetMandatory() bool { + if x != nil && x.Mandatory != nil { + return *x.Mandatory + } + return false +} + +func (x *EditQuestionRequest) GetOrder() int32 { + if x != nil && x.Order != nil { + return *x.Order + } + return 0 +} + +var File_hackathon_messages_hackathon_svc_edit_question_request_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_edit_question_request_proto_rawDesc = "" + + "\n" + + " hackathon.entities.QuestionType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_edit_question_request_proto_init() } +func file_hackathon_messages_hackathon_svc_edit_question_request_proto_init() { + if File_hackathon_messages_hackathon_svc_edit_question_request_proto != nil { + return + } + file_hackathon_messages_hackathon_svc_edit_question_request_proto_msgTypes[0].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_edit_question_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_edit_question_request_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_edit_question_request_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_edit_question_request_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_edit_question_request_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_edit_question_request_proto = out.File + file_hackathon_messages_hackathon_svc_edit_question_request_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_edit_question_request_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_response.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_response.pb.go new file mode 100644 index 00000000..46ed76fe --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/edit_question_response.pb.go @@ -0,0 +1,113 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/edit_question_response.proto + +package hackathon_svc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type EditQuestionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EditQuestionResponse) Reset() { + *x = EditQuestionResponse{} + mi := &file_hackathon_messages_hackathon_svc_edit_question_response_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EditQuestionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EditQuestionResponse) ProtoMessage() {} + +func (x *EditQuestionResponse) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_edit_question_response_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EditQuestionResponse.ProtoReflect.Descriptor instead. +func (*EditQuestionResponse) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDescGZIP(), []int{0} +} + +var File_hackathon_messages_hackathon_svc_edit_question_response_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDesc = "" + + "\n" + + "=hackathon/messages/hackathon_svc/edit_question_response.proto\x12 hackathon.messages.hackathon_svc\"\x16\n" + + "\x14EditQuestionResponseBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_edit_question_response_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_edit_question_response_proto_goTypes = []any{ + (*EditQuestionResponse)(nil), // 0: hackathon.messages.hackathon_svc.EditQuestionResponse +} +var file_hackathon_messages_hackathon_svc_edit_question_response_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_edit_question_response_proto_init() } +func file_hackathon_messages_hackathon_svc_edit_question_response_proto_init() { + if File_hackathon_messages_hackathon_svc_edit_question_response_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_edit_question_response_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_edit_question_response_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_edit_question_response_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_edit_question_response_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_edit_question_response_proto = out.File + file_hackathon_messages_hackathon_svc_edit_question_response_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_edit_question_response_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/join_request.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/join_request.pb.go index d786fa70..93466d81 100644 --- a/components/backend/internal/proto/hackathon/messages/hackathon_svc/join_request.pb.go +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/join_request.pb.go @@ -7,6 +7,8 @@ package hackathon_svc import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + entities "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -24,6 +26,7 @@ const ( type JoinRequest struct { state protoimpl.MessageState `protogen:"open.v1"` HackathonId string `protobuf:"bytes,1,opt,name=hackathon_id,json=hackathonId,proto3" json:"hackathon_id,omitempty"` + Answers []*entities.Answer `protobuf:"bytes,2,rep,name=answers,proto3" json:"answers,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -65,13 +68,21 @@ func (x *JoinRequest) GetHackathonId() string { return "" } +func (x *JoinRequest) GetAnswers() []*entities.Answer { + if x != nil { + return x.Answers + } + return nil +} + var File_hackathon_messages_hackathon_svc_join_request_proto protoreflect.FileDescriptor const file_hackathon_messages_hackathon_svc_join_request_proto_rawDesc = "" + "\n" + - "3hackathon/messages/hackathon_svc/join_request.proto\x12 hackathon.messages.hackathon_svc\"0\n" + - "\vJoinRequest\x12!\n" + - "\fhackathon_id\x18\x01 \x01(\tR\vhackathonIdBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + "3hackathon/messages/hackathon_svc/join_request.proto\x12 hackathon.messages.hackathon_svc\x1a\x1bbuf/validate/validate.proto\x1a\x1fhackathon/entities/answer.proto\"p\n" + + "\vJoinRequest\x12+\n" + + "\fhackathon_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\vhackathonId\x124\n" + + "\aanswers\x18\x02 \x03(\v2\x1a.hackathon.entities.AnswerR\aanswersBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" var ( file_hackathon_messages_hackathon_svc_join_request_proto_rawDescOnce sync.Once @@ -87,14 +98,16 @@ func file_hackathon_messages_hackathon_svc_join_request_proto_rawDescGZIP() []by var file_hackathon_messages_hackathon_svc_join_request_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_hackathon_messages_hackathon_svc_join_request_proto_goTypes = []any{ - (*JoinRequest)(nil), // 0: hackathon.messages.hackathon_svc.JoinRequest + (*JoinRequest)(nil), // 0: hackathon.messages.hackathon_svc.JoinRequest + (*entities.Answer)(nil), // 1: hackathon.entities.Answer } var file_hackathon_messages_hackathon_svc_join_request_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: hackathon.messages.hackathon_svc.JoinRequest.answers:type_name -> hackathon.entities.Answer + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_hackathon_messages_hackathon_svc_join_request_proto_init() } diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.pb.go new file mode 100644 index 00000000..69c982ac --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_request.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/list_participant_answers_request.proto + +package hackathon_svc + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListParticipantAnswersRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + HackathonId string `protobuf:"bytes,1,opt,name=hackathon_id,json=hackathonId,proto3" json:"hackathon_id,omitempty"` + UserId *string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListParticipantAnswersRequest) Reset() { + *x = ListParticipantAnswersRequest{} + mi := &file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListParticipantAnswersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListParticipantAnswersRequest) ProtoMessage() {} + +func (x *ListParticipantAnswersRequest) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListParticipantAnswersRequest.ProtoReflect.Descriptor instead. +func (*ListParticipantAnswersRequest) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDescGZIP(), []int{0} +} + +func (x *ListParticipantAnswersRequest) GetHackathonId() string { + if x != nil { + return x.HackathonId + } + return "" +} + +func (x *ListParticipantAnswersRequest) GetUserId() string { + if x != nil && x.UserId != nil { + return *x.UserId + } + return "" +} + +var File_hackathon_messages_hackathon_svc_list_participant_answers_request_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDesc = "" + + "\n" + + "Ghackathon/messages/hackathon_svc/list_participant_answers_request.proto\x12 hackathon.messages.hackathon_svc\x1a\x1bbuf/validate/validate.proto\"\x80\x01\n" + + "\x1dListParticipantAnswersRequest\x12+\n" + + "\fhackathon_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\vhackathonId\x12&\n" + + "\auser_id\x18\x02 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01H\x00R\x06userId\x88\x01\x01B\n" + + "\n" + + "\b_user_idBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_goTypes = []any{ + (*ListParticipantAnswersRequest)(nil), // 0: hackathon.messages.hackathon_svc.ListParticipantAnswersRequest +} +var file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_init() } +func file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_init() { + if File_hackathon_messages_hackathon_svc_list_participant_answers_request_proto != nil { + return + } + file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_msgTypes[0].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_list_participant_answers_request_proto = out.File + file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_list_participant_answers_request_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.pb.go new file mode 100644 index 00000000..cf6092eb --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_participant_answers_response.pb.go @@ -0,0 +1,125 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/list_participant_answers_response.proto + +package hackathon_svc + +import ( + entities "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListParticipantAnswersResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Answers []*entities.Answer `protobuf:"bytes,1,rep,name=answers,proto3" json:"answers,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListParticipantAnswersResponse) Reset() { + *x = ListParticipantAnswersResponse{} + mi := &file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListParticipantAnswersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListParticipantAnswersResponse) ProtoMessage() {} + +func (x *ListParticipantAnswersResponse) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListParticipantAnswersResponse.ProtoReflect.Descriptor instead. +func (*ListParticipantAnswersResponse) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDescGZIP(), []int{0} +} + +func (x *ListParticipantAnswersResponse) GetAnswers() []*entities.Answer { + if x != nil { + return x.Answers + } + return nil +} + +var File_hackathon_messages_hackathon_svc_list_participant_answers_response_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDesc = "" + + "\n" + + "Hhackathon/messages/hackathon_svc/list_participant_answers_response.proto\x12 hackathon.messages.hackathon_svc\x1a\x1fhackathon/entities/answer.proto\"V\n" + + "\x1eListParticipantAnswersResponse\x124\n" + + "\aanswers\x18\x01 \x03(\v2\x1a.hackathon.entities.AnswerR\aanswersBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_goTypes = []any{ + (*ListParticipantAnswersResponse)(nil), // 0: hackathon.messages.hackathon_svc.ListParticipantAnswersResponse + (*entities.Answer)(nil), // 1: hackathon.entities.Answer +} +var file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_depIdxs = []int32{ + 1, // 0: hackathon.messages.hackathon_svc.ListParticipantAnswersResponse.answers:type_name -> hackathon.entities.Answer + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_init() } +func file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_init() { + if File_hackathon_messages_hackathon_svc_list_participant_answers_response_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_list_participant_answers_response_proto = out.File + file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_list_participant_answers_response_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_request.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_request.pb.go new file mode 100644 index 00000000..9355741a --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_request.pb.go @@ -0,0 +1,123 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/list_questions_request.proto + +package hackathon_svc + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListQuestionsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + HackathonId string `protobuf:"bytes,1,opt,name=hackathon_id,json=hackathonId,proto3" json:"hackathon_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListQuestionsRequest) Reset() { + *x = ListQuestionsRequest{} + mi := &file_hackathon_messages_hackathon_svc_list_questions_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListQuestionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListQuestionsRequest) ProtoMessage() {} + +func (x *ListQuestionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_list_questions_request_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListQuestionsRequest.ProtoReflect.Descriptor instead. +func (*ListQuestionsRequest) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDescGZIP(), []int{0} +} + +func (x *ListQuestionsRequest) GetHackathonId() string { + if x != nil { + return x.HackathonId + } + return "" +} + +var File_hackathon_messages_hackathon_svc_list_questions_request_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDesc = "" + + "\n" + + "=hackathon/messages/hackathon_svc/list_questions_request.proto\x12 hackathon.messages.hackathon_svc\x1a\x1bbuf/validate/validate.proto\"C\n" + + "\x14ListQuestionsRequest\x12+\n" + + "\fhackathon_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\vhackathonIdBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_list_questions_request_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_list_questions_request_proto_goTypes = []any{ + (*ListQuestionsRequest)(nil), // 0: hackathon.messages.hackathon_svc.ListQuestionsRequest +} +var file_hackathon_messages_hackathon_svc_list_questions_request_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_list_questions_request_proto_init() } +func file_hackathon_messages_hackathon_svc_list_questions_request_proto_init() { + if File_hackathon_messages_hackathon_svc_list_questions_request_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_questions_request_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_list_questions_request_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_list_questions_request_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_list_questions_request_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_list_questions_request_proto = out.File + file_hackathon_messages_hackathon_svc_list_questions_request_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_list_questions_request_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_response.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_response.pb.go new file mode 100644 index 00000000..dbbb0237 --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/list_questions_response.pb.go @@ -0,0 +1,125 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/list_questions_response.proto + +package hackathon_svc + +import ( + entities "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListQuestionsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Questions []*entities.Question `protobuf:"bytes,1,rep,name=questions,proto3" json:"questions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListQuestionsResponse) Reset() { + *x = ListQuestionsResponse{} + mi := &file_hackathon_messages_hackathon_svc_list_questions_response_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListQuestionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListQuestionsResponse) ProtoMessage() {} + +func (x *ListQuestionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_list_questions_response_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListQuestionsResponse.ProtoReflect.Descriptor instead. +func (*ListQuestionsResponse) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDescGZIP(), []int{0} +} + +func (x *ListQuestionsResponse) GetQuestions() []*entities.Question { + if x != nil { + return x.Questions + } + return nil +} + +var File_hackathon_messages_hackathon_svc_list_questions_response_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDesc = "" + + "\n" + + ">hackathon/messages/hackathon_svc/list_questions_response.proto\x12 hackathon.messages.hackathon_svc\x1a!hackathon/entities/question.proto\"S\n" + + "\x15ListQuestionsResponse\x12:\n" + + "\tquestions\x18\x01 \x03(\v2\x1c.hackathon.entities.QuestionR\tquestionsBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_list_questions_response_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_list_questions_response_proto_goTypes = []any{ + (*ListQuestionsResponse)(nil), // 0: hackathon.messages.hackathon_svc.ListQuestionsResponse + (*entities.Question)(nil), // 1: hackathon.entities.Question +} +var file_hackathon_messages_hackathon_svc_list_questions_response_proto_depIdxs = []int32{ + 1, // 0: hackathon.messages.hackathon_svc.ListQuestionsResponse.questions:type_name -> hackathon.entities.Question + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_list_questions_response_proto_init() } +func file_hackathon_messages_hackathon_svc_list_questions_response_proto_init() { + if File_hackathon_messages_hackathon_svc_list_questions_response_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_list_questions_response_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_list_questions_response_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_list_questions_response_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_list_questions_response_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_list_questions_response_proto = out.File + file_hackathon_messages_hackathon_svc_list_questions_response_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_list_questions_response_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_request.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_request.pb.go new file mode 100644 index 00000000..63e3f995 --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_request.pb.go @@ -0,0 +1,133 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/remove_question_request.proto + +package hackathon_svc + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type RemoveQuestionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + HackathonId string `protobuf:"bytes,1,opt,name=hackathon_id,json=hackathonId,proto3" json:"hackathon_id,omitempty"` + QuestionId string `protobuf:"bytes,2,opt,name=question_id,json=questionId,proto3" json:"question_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RemoveQuestionRequest) Reset() { + *x = RemoveQuestionRequest{} + mi := &file_hackathon_messages_hackathon_svc_remove_question_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RemoveQuestionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveQuestionRequest) ProtoMessage() {} + +func (x *RemoveQuestionRequest) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_remove_question_request_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveQuestionRequest.ProtoReflect.Descriptor instead. +func (*RemoveQuestionRequest) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDescGZIP(), []int{0} +} + +func (x *RemoveQuestionRequest) GetHackathonId() string { + if x != nil { + return x.HackathonId + } + return "" +} + +func (x *RemoveQuestionRequest) GetQuestionId() string { + if x != nil { + return x.QuestionId + } + return "" +} + +var File_hackathon_messages_hackathon_svc_remove_question_request_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDesc = "" + + "\n" + + ">hackathon/messages/hackathon_svc/remove_question_request.proto\x12 hackathon.messages.hackathon_svc\x1a\x1bbuf/validate/validate.proto\"o\n" + + "\x15RemoveQuestionRequest\x12+\n" + + "\fhackathon_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\vhackathonId\x12)\n" + + "\vquestion_id\x18\x02 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\n" + + "questionIdBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_remove_question_request_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_remove_question_request_proto_goTypes = []any{ + (*RemoveQuestionRequest)(nil), // 0: hackathon.messages.hackathon_svc.RemoveQuestionRequest +} +var file_hackathon_messages_hackathon_svc_remove_question_request_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_remove_question_request_proto_init() } +func file_hackathon_messages_hackathon_svc_remove_question_request_proto_init() { + if File_hackathon_messages_hackathon_svc_remove_question_request_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_remove_question_request_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_remove_question_request_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_remove_question_request_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_remove_question_request_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_remove_question_request_proto = out.File + file_hackathon_messages_hackathon_svc_remove_question_request_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_remove_question_request_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_response.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_response.pb.go new file mode 100644 index 00000000..b415e3e5 --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/remove_question_response.pb.go @@ -0,0 +1,113 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/remove_question_response.proto + +package hackathon_svc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type RemoveQuestionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RemoveQuestionResponse) Reset() { + *x = RemoveQuestionResponse{} + mi := &file_hackathon_messages_hackathon_svc_remove_question_response_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RemoveQuestionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveQuestionResponse) ProtoMessage() {} + +func (x *RemoveQuestionResponse) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_remove_question_response_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveQuestionResponse.ProtoReflect.Descriptor instead. +func (*RemoveQuestionResponse) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDescGZIP(), []int{0} +} + +var File_hackathon_messages_hackathon_svc_remove_question_response_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDesc = "" + + "\n" + + "?hackathon/messages/hackathon_svc/remove_question_response.proto\x12 hackathon.messages.hackathon_svc\"\x18\n" + + "\x16RemoveQuestionResponseBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_remove_question_response_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_remove_question_response_proto_goTypes = []any{ + (*RemoveQuestionResponse)(nil), // 0: hackathon.messages.hackathon_svc.RemoveQuestionResponse +} +var file_hackathon_messages_hackathon_svc_remove_question_response_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_remove_question_response_proto_init() } +func file_hackathon_messages_hackathon_svc_remove_question_response_proto_init() { + if File_hackathon_messages_hackathon_svc_remove_question_response_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_remove_question_response_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_remove_question_response_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_remove_question_response_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_remove_question_response_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_remove_question_response_proto = out.File + file_hackathon_messages_hackathon_svc_remove_question_response_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_remove_question_response_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_request.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_request.pb.go new file mode 100644 index 00000000..267c2edf --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_request.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/submit_answers_request.proto + +package hackathon_svc + +import ( + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + entities "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SubmitAnswersRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + HackathonId string `protobuf:"bytes,1,opt,name=hackathon_id,json=hackathonId,proto3" json:"hackathon_id,omitempty"` + Answers []*entities.Answer `protobuf:"bytes,2,rep,name=answers,proto3" json:"answers,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SubmitAnswersRequest) Reset() { + *x = SubmitAnswersRequest{} + mi := &file_hackathon_messages_hackathon_svc_submit_answers_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SubmitAnswersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitAnswersRequest) ProtoMessage() {} + +func (x *SubmitAnswersRequest) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_submit_answers_request_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitAnswersRequest.ProtoReflect.Descriptor instead. +func (*SubmitAnswersRequest) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDescGZIP(), []int{0} +} + +func (x *SubmitAnswersRequest) GetHackathonId() string { + if x != nil { + return x.HackathonId + } + return "" +} + +func (x *SubmitAnswersRequest) GetAnswers() []*entities.Answer { + if x != nil { + return x.Answers + } + return nil +} + +var File_hackathon_messages_hackathon_svc_submit_answers_request_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDesc = "" + + "\n" + + "=hackathon/messages/hackathon_svc/submit_answers_request.proto\x12 hackathon.messages.hackathon_svc\x1a\x1bbuf/validate/validate.proto\x1a\x1fhackathon/entities/answer.proto\"y\n" + + "\x14SubmitAnswersRequest\x12+\n" + + "\fhackathon_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\vhackathonId\x124\n" + + "\aanswers\x18\x02 \x03(\v2\x1a.hackathon.entities.AnswerR\aanswersBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_submit_answers_request_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_submit_answers_request_proto_goTypes = []any{ + (*SubmitAnswersRequest)(nil), // 0: hackathon.messages.hackathon_svc.SubmitAnswersRequest + (*entities.Answer)(nil), // 1: hackathon.entities.Answer +} +var file_hackathon_messages_hackathon_svc_submit_answers_request_proto_depIdxs = []int32{ + 1, // 0: hackathon.messages.hackathon_svc.SubmitAnswersRequest.answers:type_name -> hackathon.entities.Answer + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_submit_answers_request_proto_init() } +func file_hackathon_messages_hackathon_svc_submit_answers_request_proto_init() { + if File_hackathon_messages_hackathon_svc_submit_answers_request_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_submit_answers_request_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_submit_answers_request_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_submit_answers_request_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_submit_answers_request_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_submit_answers_request_proto = out.File + file_hackathon_messages_hackathon_svc_submit_answers_request_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_submit_answers_request_proto_depIdxs = nil +} diff --git a/components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_response.pb.go b/components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_response.pb.go new file mode 100644 index 00000000..bf63c207 --- /dev/null +++ b/components/backend/internal/proto/hackathon/messages/hackathon_svc/submit_answers_response.pb.go @@ -0,0 +1,113 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: hackathon/messages/hackathon_svc/submit_answers_response.proto + +package hackathon_svc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SubmitAnswersResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SubmitAnswersResponse) Reset() { + *x = SubmitAnswersResponse{} + mi := &file_hackathon_messages_hackathon_svc_submit_answers_response_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SubmitAnswersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitAnswersResponse) ProtoMessage() {} + +func (x *SubmitAnswersResponse) ProtoReflect() protoreflect.Message { + mi := &file_hackathon_messages_hackathon_svc_submit_answers_response_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitAnswersResponse.ProtoReflect.Descriptor instead. +func (*SubmitAnswersResponse) Descriptor() ([]byte, []int) { + return file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDescGZIP(), []int{0} +} + +var File_hackathon_messages_hackathon_svc_submit_answers_response_proto protoreflect.FileDescriptor + +const file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDesc = "" + + "\n" + + ">hackathon/messages/hackathon_svc/submit_answers_response.proto\x12 hackathon.messages.hackathon_svc\"\x17\n" + + "\x15SubmitAnswersResponseBoZmgithub.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svcb\x06proto3" + +var ( + file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDescOnce sync.Once + file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDescData []byte +) + +func file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDescGZIP() []byte { + file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDescOnce.Do(func() { + file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDesc))) + }) + return file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDescData +} + +var file_hackathon_messages_hackathon_svc_submit_answers_response_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_hackathon_messages_hackathon_svc_submit_answers_response_proto_goTypes = []any{ + (*SubmitAnswersResponse)(nil), // 0: hackathon.messages.hackathon_svc.SubmitAnswersResponse +} +var file_hackathon_messages_hackathon_svc_submit_answers_response_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hackathon_messages_hackathon_svc_submit_answers_response_proto_init() } +func file_hackathon_messages_hackathon_svc_submit_answers_response_proto_init() { + if File_hackathon_messages_hackathon_svc_submit_answers_response_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDesc), len(file_hackathon_messages_hackathon_svc_submit_answers_response_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_hackathon_messages_hackathon_svc_submit_answers_response_proto_goTypes, + DependencyIndexes: file_hackathon_messages_hackathon_svc_submit_answers_response_proto_depIdxs, + MessageInfos: file_hackathon_messages_hackathon_svc_submit_answers_response_proto_msgTypes, + }.Build() + File_hackathon_messages_hackathon_svc_submit_answers_response_proto = out.File + file_hackathon_messages_hackathon_svc_submit_answers_response_proto_goTypes = nil + file_hackathon_messages_hackathon_svc_submit_answers_response_proto_depIdxs = nil +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/entities/answer.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/entities/answer.ts new file mode 100644 index 00000000..ada4f2c2 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/entities/answer.ts @@ -0,0 +1,134 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/entities/answer.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { QuestionType, questionTypeFromJSON, questionTypeToJSON } from "./question"; + +export const protobufPackage = "hackathon.entities"; + +export interface Answer { + questionId: string; + value: string; + type: QuestionType; +} + +function createBaseAnswer(): Answer { + return { questionId: "", value: "", type: 0 }; +} + +export const Answer: MessageFns = { + encode(message: Answer, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.questionId !== "") { + writer.uint32(10).string(message.questionId); + } + if (message.value !== "") { + writer.uint32(18).string(message.value); + } + if (message.type !== 0) { + writer.uint32(24).int32(message.type); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Answer { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAnswer(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.questionId = reader.string(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } + + message.value = reader.string(); + continue; + } + case 3: { + if (tag !== 24) { + break; + } + + message.type = reader.int32() as any; + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): Answer { + return { + questionId: isSet(object.questionId) + ? globalThis.String(object.questionId) + : isSet(object.question_id) + ? globalThis.String(object.question_id) + : "", + value: isSet(object.value) ? globalThis.String(object.value) : "", + type: isSet(object.type) ? questionTypeFromJSON(object.type) : 0, + }; + }, + + toJSON(message: Answer): unknown { + const obj: any = {}; + if (message.questionId !== "") { + obj.questionId = message.questionId; + } + if (message.value !== "") { + obj.value = message.value; + } + if (message.type !== 0) { + obj.type = questionTypeToJSON(message.type); + } + return obj; + }, + + create(base?: DeepPartial): Answer { + return Answer.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): Answer { + const message = createBaseAnswer(); + message.questionId = object.questionId ?? ""; + message.value = object.value ?? ""; + message.type = object.type ?? 0; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/entities/question.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/entities/question.ts new file mode 100644 index 00000000..47bd17c8 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/entities/question.ts @@ -0,0 +1,219 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/entities/question.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.entities"; + +export enum QuestionType { + QUESTION_TYPE_UNSPECIFIED = 0, + QUESTION_TYPE_TEXT = 1, + QUESTION_TYPE_BOOL = 2, + UNRECOGNIZED = -1, +} + +export function questionTypeFromJSON(object: any): QuestionType { + switch (object) { + case 0: + case "QUESTION_TYPE_UNSPECIFIED": + return QuestionType.QUESTION_TYPE_UNSPECIFIED; + case 1: + case "QUESTION_TYPE_TEXT": + return QuestionType.QUESTION_TYPE_TEXT; + case 2: + case "QUESTION_TYPE_BOOL": + return QuestionType.QUESTION_TYPE_BOOL; + case -1: + case "UNRECOGNIZED": + default: + return QuestionType.UNRECOGNIZED; + } +} + +export function questionTypeToJSON(object: QuestionType): string { + switch (object) { + case QuestionType.QUESTION_TYPE_UNSPECIFIED: + return "QUESTION_TYPE_UNSPECIFIED"; + case QuestionType.QUESTION_TYPE_TEXT: + return "QUESTION_TYPE_TEXT"; + case QuestionType.QUESTION_TYPE_BOOL: + return "QUESTION_TYPE_BOOL"; + case QuestionType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export interface Question { + id: string; + key: string; + label: string; + type: QuestionType; + mandatory: boolean; + order: number; +} + +function createBaseQuestion(): Question { + return { id: "", key: "", label: "", type: 0, mandatory: false, order: 0 }; +} + +export const Question: MessageFns = { + encode(message: Question, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.key !== "") { + writer.uint32(18).string(message.key); + } + if (message.label !== "") { + writer.uint32(26).string(message.label); + } + if (message.type !== 0) { + writer.uint32(32).int32(message.type); + } + if (message.mandatory !== false) { + writer.uint32(40).bool(message.mandatory); + } + if (message.order !== 0) { + writer.uint32(48).int32(message.order); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Question { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuestion(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.id = reader.string(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } + + message.key = reader.string(); + continue; + } + case 3: { + if (tag !== 26) { + break; + } + + message.label = reader.string(); + continue; + } + case 4: { + if (tag !== 32) { + break; + } + + message.type = reader.int32() as any; + continue; + } + case 5: { + if (tag !== 40) { + break; + } + + message.mandatory = reader.bool(); + continue; + } + case 6: { + if (tag !== 48) { + break; + } + + message.order = reader.int32(); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): Question { + return { + id: isSet(object.id) ? globalThis.String(object.id) : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", + label: isSet(object.label) ? globalThis.String(object.label) : "", + type: isSet(object.type) ? questionTypeFromJSON(object.type) : 0, + mandatory: isSet(object.mandatory) ? globalThis.Boolean(object.mandatory) : false, + order: isSet(object.order) ? globalThis.Number(object.order) : 0, + }; + }, + + toJSON(message: Question): unknown { + const obj: any = {}; + if (message.id !== "") { + obj.id = message.id; + } + if (message.key !== "") { + obj.key = message.key; + } + if (message.label !== "") { + obj.label = message.label; + } + if (message.type !== 0) { + obj.type = questionTypeToJSON(message.type); + } + if (message.mandatory !== false) { + obj.mandatory = message.mandatory; + } + if (message.order !== 0) { + obj.order = Math.round(message.order); + } + return obj; + }, + + create(base?: DeepPartial): Question { + return Question.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): Question { + const message = createBaseQuestion(); + message.id = object.id ?? ""; + message.key = object.key ?? ""; + message.label = object.label ?? ""; + message.type = object.type ?? 0; + message.mandatory = object.mandatory ?? false; + message.order = object.order ?? 0; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/hackathon_service.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/hackathon_service.ts index d615bca1..b690e241 100644 --- a/components/frontend/src/lib/server/grpc/generated/hackathon/hackathon_service.ts +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/hackathon_service.ts @@ -10,24 +10,36 @@ import { AddOwnerRequest } from "./messages/hackathon_svc/add_owner_request"; import { AddOwnerResponse } from "./messages/hackathon_svc/add_owner_response"; import { ApproveParticipantRequest } from "./messages/hackathon_svc/approve_participant_request"; import { ApproveParticipantResponse } from "./messages/hackathon_svc/approve_participant_response"; +import { CreateQuestionRequest } from "./messages/hackathon_svc/create_question_request"; +import { CreateQuestionResponse } from "./messages/hackathon_svc/create_question_response"; import { CreateRequest } from "./messages/hackathon_svc/create_request"; import { CreateResponse } from "./messages/hackathon_svc/create_response"; +import { EditQuestionRequest } from "./messages/hackathon_svc/edit_question_request"; +import { EditQuestionResponse } from "./messages/hackathon_svc/edit_question_response"; import { EditRequest } from "./messages/hackathon_svc/edit_request"; import { EditResponse } from "./messages/hackathon_svc/edit_response"; import { GetRequest } from "./messages/hackathon_svc/get_request"; import { GetResponse } from "./messages/hackathon_svc/get_response"; import { JoinRequest } from "./messages/hackathon_svc/join_request"; import { JoinResponse } from "./messages/hackathon_svc/join_response"; +import { ListParticipantAnswersRequest } from "./messages/hackathon_svc/list_participant_answers_request"; +import { ListParticipantAnswersResponse } from "./messages/hackathon_svc/list_participant_answers_response"; +import { ListQuestionsRequest } from "./messages/hackathon_svc/list_questions_request"; +import { ListQuestionsResponse } from "./messages/hackathon_svc/list_questions_response"; import { ListRequest } from "./messages/hackathon_svc/list_request"; import { ListResponse } from "./messages/hackathon_svc/list_response"; import { RemoveOwnerRequest } from "./messages/hackathon_svc/remove_owner_request"; import { RemoveOwnerResponse } from "./messages/hackathon_svc/remove_owner_response"; import { RemoveParticipantRequest } from "./messages/hackathon_svc/remove_participant_request"; import { RemoveParticipantResponse } from "./messages/hackathon_svc/remove_participant_response"; +import { RemoveQuestionRequest } from "./messages/hackathon_svc/remove_question_request"; +import { RemoveQuestionResponse } from "./messages/hackathon_svc/remove_question_response"; import { SetCapabilitiesRequest } from "./messages/hackathon_svc/set_capabilities_request"; import { SetCapabilitiesResponse } from "./messages/hackathon_svc/set_capabilities_response"; import { SetCurrentPhaseRequest } from "./messages/hackathon_svc/set_current_phase_request"; import { SetCurrentPhaseResponse } from "./messages/hackathon_svc/set_current_phase_response"; +import { SubmitAnswersRequest } from "./messages/hackathon_svc/submit_answers_request"; +import { SubmitAnswersResponse } from "./messages/hackathon_svc/submit_answers_response"; export const protobufPackage = "hackathon"; @@ -124,6 +136,56 @@ export const HackathonServiceDefinition = { responseStream: false, options: {}, }, + /** Registration questions */ + createQuestion: { + name: "CreateQuestion", + requestType: CreateQuestionRequest as typeof CreateQuestionRequest, + requestStream: false, + responseType: CreateQuestionResponse as typeof CreateQuestionResponse, + responseStream: false, + options: {}, + }, + editQuestion: { + name: "EditQuestion", + requestType: EditQuestionRequest as typeof EditQuestionRequest, + requestStream: false, + responseType: EditQuestionResponse as typeof EditQuestionResponse, + responseStream: false, + options: {}, + }, + removeQuestion: { + name: "RemoveQuestion", + requestType: RemoveQuestionRequest as typeof RemoveQuestionRequest, + requestStream: false, + responseType: RemoveQuestionResponse as typeof RemoveQuestionResponse, + responseStream: false, + options: {}, + }, + listQuestions: { + name: "ListQuestions", + requestType: ListQuestionsRequest as typeof ListQuestionsRequest, + requestStream: false, + responseType: ListQuestionsResponse as typeof ListQuestionsResponse, + responseStream: false, + options: {}, + }, + submitAnswers: { + name: "SubmitAnswers", + requestType: SubmitAnswersRequest as typeof SubmitAnswersRequest, + requestStream: false, + responseType: SubmitAnswersResponse as typeof SubmitAnswersResponse, + responseStream: false, + options: {}, + }, + /** Participant answers (admin) */ + listParticipantAnswers: { + name: "ListParticipantAnswers", + requestType: ListParticipantAnswersRequest as typeof ListParticipantAnswersRequest, + requestStream: false, + responseType: ListParticipantAnswersResponse as typeof ListParticipantAnswersResponse, + responseStream: false, + options: {}, + }, }, } as const; @@ -154,6 +216,32 @@ export interface HackathonServiceImplementation { request: RemoveOwnerRequest, context: CallContext & CallContextExt, ): Promise>; + /** Registration questions */ + createQuestion( + request: CreateQuestionRequest, + context: CallContext & CallContextExt, + ): Promise>; + editQuestion( + request: EditQuestionRequest, + context: CallContext & CallContextExt, + ): Promise>; + removeQuestion( + request: RemoveQuestionRequest, + context: CallContext & CallContextExt, + ): Promise>; + listQuestions( + request: ListQuestionsRequest, + context: CallContext & CallContextExt, + ): Promise>; + submitAnswers( + request: SubmitAnswersRequest, + context: CallContext & CallContextExt, + ): Promise>; + /** Participant answers (admin) */ + listParticipantAnswers( + request: ListParticipantAnswersRequest, + context: CallContext & CallContextExt, + ): Promise>; } export interface HackathonServiceClient { @@ -183,6 +271,32 @@ export interface HackathonServiceClient { request: DeepPartial, options?: CallOptions & CallOptionsExt, ): Promise; + /** Registration questions */ + createQuestion( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + editQuestion( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + removeQuestion( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + listQuestions( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + submitAnswers( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + /** Participant answers (admin) */ + listParticipantAnswers( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_request.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_request.ts new file mode 100644 index 00000000..91362165 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_request.ts @@ -0,0 +1,185 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/create_question_request.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { QuestionType, questionTypeFromJSON, questionTypeToJSON } from "../../entities/question"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface CreateQuestionRequest { + hackathonId: string; + key: string; + label: string; + type: QuestionType; + mandatory: boolean; + order: number; +} + +function createBaseCreateQuestionRequest(): CreateQuestionRequest { + return { hackathonId: "", key: "", label: "", type: 0, mandatory: false, order: 0 }; +} + +export const CreateQuestionRequest: MessageFns = { + encode(message: CreateQuestionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.hackathonId !== "") { + writer.uint32(10).string(message.hackathonId); + } + if (message.key !== "") { + writer.uint32(18).string(message.key); + } + if (message.label !== "") { + writer.uint32(26).string(message.label); + } + if (message.type !== 0) { + writer.uint32(32).int32(message.type); + } + if (message.mandatory !== false) { + writer.uint32(40).bool(message.mandatory); + } + if (message.order !== 0) { + writer.uint32(48).int32(message.order); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): CreateQuestionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateQuestionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.hackathonId = reader.string(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } + + message.key = reader.string(); + continue; + } + case 3: { + if (tag !== 26) { + break; + } + + message.label = reader.string(); + continue; + } + case 4: { + if (tag !== 32) { + break; + } + + message.type = reader.int32() as any; + continue; + } + case 5: { + if (tag !== 40) { + break; + } + + message.mandatory = reader.bool(); + continue; + } + case 6: { + if (tag !== 48) { + break; + } + + message.order = reader.int32(); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): CreateQuestionRequest { + return { + hackathonId: isSet(object.hackathonId) + ? globalThis.String(object.hackathonId) + : isSet(object.hackathon_id) + ? globalThis.String(object.hackathon_id) + : "", + key: isSet(object.key) ? globalThis.String(object.key) : "", + label: isSet(object.label) ? globalThis.String(object.label) : "", + type: isSet(object.type) ? questionTypeFromJSON(object.type) : 0, + mandatory: isSet(object.mandatory) ? globalThis.Boolean(object.mandatory) : false, + order: isSet(object.order) ? globalThis.Number(object.order) : 0, + }; + }, + + toJSON(message: CreateQuestionRequest): unknown { + const obj: any = {}; + if (message.hackathonId !== "") { + obj.hackathonId = message.hackathonId; + } + if (message.key !== "") { + obj.key = message.key; + } + if (message.label !== "") { + obj.label = message.label; + } + if (message.type !== 0) { + obj.type = questionTypeToJSON(message.type); + } + if (message.mandatory !== false) { + obj.mandatory = message.mandatory; + } + if (message.order !== 0) { + obj.order = Math.round(message.order); + } + return obj; + }, + + create(base?: DeepPartial): CreateQuestionRequest { + return CreateQuestionRequest.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): CreateQuestionRequest { + const message = createBaseCreateQuestionRequest(); + message.hackathonId = object.hackathonId ?? ""; + message.key = object.key ?? ""; + message.label = object.label ?? ""; + message.type = object.type ?? 0; + message.mandatory = object.mandatory ?? false; + message.order = object.order ?? 0; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_response.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_response.ts new file mode 100644 index 00000000..4c484065 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/create_question_response.ts @@ -0,0 +1,99 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/create_question_response.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface CreateQuestionResponse { + questionId: string; +} + +function createBaseCreateQuestionResponse(): CreateQuestionResponse { + return { questionId: "" }; +} + +export const CreateQuestionResponse: MessageFns = { + encode(message: CreateQuestionResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.questionId !== "") { + writer.uint32(10).string(message.questionId); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): CreateQuestionResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateQuestionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.questionId = reader.string(); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): CreateQuestionResponse { + return { + questionId: isSet(object.questionId) + ? globalThis.String(object.questionId) + : isSet(object.question_id) + ? globalThis.String(object.question_id) + : "", + }; + }, + + toJSON(message: CreateQuestionResponse): unknown { + const obj: any = {}; + if (message.questionId !== "") { + obj.questionId = message.questionId; + } + return obj; + }, + + create(base?: DeepPartial): CreateQuestionResponse { + return CreateQuestionResponse.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): CreateQuestionResponse { + const message = createBaseCreateQuestionResponse(); + message.questionId = object.questionId ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_request.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_request.ts new file mode 100644 index 00000000..552de3a8 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_request.ts @@ -0,0 +1,189 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/edit_question_request.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { QuestionType, questionTypeFromJSON, questionTypeToJSON } from "../../entities/question"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface EditQuestionRequest { + hackathonId: string; + questionId: string; + label?: string | undefined; + type?: QuestionType | undefined; + mandatory?: boolean | undefined; + order?: number | undefined; +} + +function createBaseEditQuestionRequest(): EditQuestionRequest { + return { hackathonId: "", questionId: "", label: undefined, type: undefined, mandatory: undefined, order: undefined }; +} + +export const EditQuestionRequest: MessageFns = { + encode(message: EditQuestionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.hackathonId !== "") { + writer.uint32(10).string(message.hackathonId); + } + if (message.questionId !== "") { + writer.uint32(18).string(message.questionId); + } + if (message.label !== undefined) { + writer.uint32(26).string(message.label); + } + if (message.type !== undefined) { + writer.uint32(32).int32(message.type); + } + if (message.mandatory !== undefined) { + writer.uint32(40).bool(message.mandatory); + } + if (message.order !== undefined) { + writer.uint32(48).int32(message.order); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EditQuestionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEditQuestionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.hackathonId = reader.string(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } + + message.questionId = reader.string(); + continue; + } + case 3: { + if (tag !== 26) { + break; + } + + message.label = reader.string(); + continue; + } + case 4: { + if (tag !== 32) { + break; + } + + message.type = reader.int32() as any; + continue; + } + case 5: { + if (tag !== 40) { + break; + } + + message.mandatory = reader.bool(); + continue; + } + case 6: { + if (tag !== 48) { + break; + } + + message.order = reader.int32(); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EditQuestionRequest { + return { + hackathonId: isSet(object.hackathonId) + ? globalThis.String(object.hackathonId) + : isSet(object.hackathon_id) + ? globalThis.String(object.hackathon_id) + : "", + questionId: isSet(object.questionId) + ? globalThis.String(object.questionId) + : isSet(object.question_id) + ? globalThis.String(object.question_id) + : "", + label: isSet(object.label) ? globalThis.String(object.label) : undefined, + type: isSet(object.type) ? questionTypeFromJSON(object.type) : undefined, + mandatory: isSet(object.mandatory) ? globalThis.Boolean(object.mandatory) : undefined, + order: isSet(object.order) ? globalThis.Number(object.order) : undefined, + }; + }, + + toJSON(message: EditQuestionRequest): unknown { + const obj: any = {}; + if (message.hackathonId !== "") { + obj.hackathonId = message.hackathonId; + } + if (message.questionId !== "") { + obj.questionId = message.questionId; + } + if (message.label !== undefined) { + obj.label = message.label; + } + if (message.type !== undefined) { + obj.type = questionTypeToJSON(message.type); + } + if (message.mandatory !== undefined) { + obj.mandatory = message.mandatory; + } + if (message.order !== undefined) { + obj.order = Math.round(message.order); + } + return obj; + }, + + create(base?: DeepPartial): EditQuestionRequest { + return EditQuestionRequest.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): EditQuestionRequest { + const message = createBaseEditQuestionRequest(); + message.hackathonId = object.hackathonId ?? ""; + message.questionId = object.questionId ?? ""; + message.label = object.label ?? undefined; + message.type = object.type ?? undefined; + message.mandatory = object.mandatory ?? undefined; + message.order = object.order ?? undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_response.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_response.ts new file mode 100644 index 00000000..ed4d3e40 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/edit_question_response.ts @@ -0,0 +1,73 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/edit_question_response.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface EditQuestionResponse { +} + +function createBaseEditQuestionResponse(): EditQuestionResponse { + return {}; +} + +export const EditQuestionResponse: MessageFns = { + encode(_: EditQuestionResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EditQuestionResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEditQuestionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): EditQuestionResponse { + return {}; + }, + + toJSON(_: EditQuestionResponse): unknown { + const obj: any = {}; + return obj; + }, + + create(base?: DeepPartial): EditQuestionResponse { + return EditQuestionResponse.fromPartial(base ?? {}); + }, + fromPartial(_: DeepPartial): EditQuestionResponse { + const message = createBaseEditQuestionResponse(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/join_request.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/join_request.ts index cf2b71b8..f061e376 100644 --- a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/join_request.ts +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/join_request.ts @@ -6,15 +6,17 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Answer } from "../../entities/answer"; export const protobufPackage = "hackathon.messages.hackathon_svc"; export interface JoinRequest { hackathonId: string; + answers: Answer[]; } function createBaseJoinRequest(): JoinRequest { - return { hackathonId: "" }; + return { hackathonId: "", answers: [] }; } export const JoinRequest: MessageFns = { @@ -22,6 +24,9 @@ export const JoinRequest: MessageFns = { if (message.hackathonId !== "") { writer.uint32(10).string(message.hackathonId); } + for (const v of message.answers) { + Answer.encode(v!, writer.uint32(18).fork()).join(); + } return writer; }, @@ -40,6 +45,14 @@ export const JoinRequest: MessageFns = { message.hackathonId = reader.string(); continue; } + case 2: { + if (tag !== 18) { + break; + } + + message.answers.push(Answer.decode(reader, reader.uint32())); + continue; + } } if ((tag & 7) === 4 || tag === 0) { break; @@ -56,6 +69,7 @@ export const JoinRequest: MessageFns = { : isSet(object.hackathon_id) ? globalThis.String(object.hackathon_id) : "", + answers: globalThis.Array.isArray(object?.answers) ? object.answers.map((e: any) => Answer.fromJSON(e)) : [], }; }, @@ -64,6 +78,9 @@ export const JoinRequest: MessageFns = { if (message.hackathonId !== "") { obj.hackathonId = message.hackathonId; } + if (message.answers?.length) { + obj.answers = message.answers.map((e) => Answer.toJSON(e)); + } return obj; }, @@ -73,6 +90,7 @@ export const JoinRequest: MessageFns = { fromPartial(object: DeepPartial): JoinRequest { const message = createBaseJoinRequest(); message.hackathonId = object.hackathonId ?? ""; + message.answers = object.answers?.map((e) => Answer.fromPartial(e)) || []; return message; }, }; diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_request.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_request.ts new file mode 100644 index 00000000..432ef56f --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_request.ts @@ -0,0 +1,120 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/list_participant_answers_request.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface ListParticipantAnswersRequest { + hackathonId: string; + userId?: string | undefined; +} + +function createBaseListParticipantAnswersRequest(): ListParticipantAnswersRequest { + return { hackathonId: "", userId: undefined }; +} + +export const ListParticipantAnswersRequest: MessageFns = { + encode(message: ListParticipantAnswersRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.hackathonId !== "") { + writer.uint32(10).string(message.hackathonId); + } + if (message.userId !== undefined) { + writer.uint32(18).string(message.userId); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): ListParticipantAnswersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListParticipantAnswersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.hackathonId = reader.string(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } + + message.userId = reader.string(); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ListParticipantAnswersRequest { + return { + hackathonId: isSet(object.hackathonId) + ? globalThis.String(object.hackathonId) + : isSet(object.hackathon_id) + ? globalThis.String(object.hackathon_id) + : "", + userId: isSet(object.userId) + ? globalThis.String(object.userId) + : isSet(object.user_id) + ? globalThis.String(object.user_id) + : undefined, + }; + }, + + toJSON(message: ListParticipantAnswersRequest): unknown { + const obj: any = {}; + if (message.hackathonId !== "") { + obj.hackathonId = message.hackathonId; + } + if (message.userId !== undefined) { + obj.userId = message.userId; + } + return obj; + }, + + create(base?: DeepPartial): ListParticipantAnswersRequest { + return ListParticipantAnswersRequest.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): ListParticipantAnswersRequest { + const message = createBaseListParticipantAnswersRequest(); + message.hackathonId = object.hackathonId ?? ""; + message.userId = object.userId ?? undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_response.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_response.ts new file mode 100644 index 00000000..3fab606c --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_participant_answers_response.ts @@ -0,0 +1,92 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/list_participant_answers_response.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Answer } from "../../entities/answer"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface ListParticipantAnswersResponse { + answers: Answer[]; +} + +function createBaseListParticipantAnswersResponse(): ListParticipantAnswersResponse { + return { answers: [] }; +} + +export const ListParticipantAnswersResponse: MessageFns = { + encode(message: ListParticipantAnswersResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.answers) { + Answer.encode(v!, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): ListParticipantAnswersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListParticipantAnswersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.answers.push(Answer.decode(reader, reader.uint32())); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ListParticipantAnswersResponse { + return { + answers: globalThis.Array.isArray(object?.answers) ? object.answers.map((e: any) => Answer.fromJSON(e)) : [], + }; + }, + + toJSON(message: ListParticipantAnswersResponse): unknown { + const obj: any = {}; + if (message.answers?.length) { + obj.answers = message.answers.map((e) => Answer.toJSON(e)); + } + return obj; + }, + + create(base?: DeepPartial): ListParticipantAnswersResponse { + return ListParticipantAnswersResponse.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): ListParticipantAnswersResponse { + const message = createBaseListParticipantAnswersResponse(); + message.answers = object.answers?.map((e) => Answer.fromPartial(e)) || []; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_request.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_request.ts new file mode 100644 index 00000000..3bbd5b65 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_request.ts @@ -0,0 +1,99 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/list_questions_request.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface ListQuestionsRequest { + hackathonId: string; +} + +function createBaseListQuestionsRequest(): ListQuestionsRequest { + return { hackathonId: "" }; +} + +export const ListQuestionsRequest: MessageFns = { + encode(message: ListQuestionsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.hackathonId !== "") { + writer.uint32(10).string(message.hackathonId); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): ListQuestionsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListQuestionsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.hackathonId = reader.string(); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ListQuestionsRequest { + return { + hackathonId: isSet(object.hackathonId) + ? globalThis.String(object.hackathonId) + : isSet(object.hackathon_id) + ? globalThis.String(object.hackathon_id) + : "", + }; + }, + + toJSON(message: ListQuestionsRequest): unknown { + const obj: any = {}; + if (message.hackathonId !== "") { + obj.hackathonId = message.hackathonId; + } + return obj; + }, + + create(base?: DeepPartial): ListQuestionsRequest { + return ListQuestionsRequest.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): ListQuestionsRequest { + const message = createBaseListQuestionsRequest(); + message.hackathonId = object.hackathonId ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_response.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_response.ts new file mode 100644 index 00000000..b5a7e831 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/list_questions_response.ts @@ -0,0 +1,94 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/list_questions_response.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Question } from "../../entities/question"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface ListQuestionsResponse { + questions: Question[]; +} + +function createBaseListQuestionsResponse(): ListQuestionsResponse { + return { questions: [] }; +} + +export const ListQuestionsResponse: MessageFns = { + encode(message: ListQuestionsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.questions) { + Question.encode(v!, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): ListQuestionsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListQuestionsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.questions.push(Question.decode(reader, reader.uint32())); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ListQuestionsResponse { + return { + questions: globalThis.Array.isArray(object?.questions) + ? object.questions.map((e: any) => Question.fromJSON(e)) + : [], + }; + }, + + toJSON(message: ListQuestionsResponse): unknown { + const obj: any = {}; + if (message.questions?.length) { + obj.questions = message.questions.map((e) => Question.toJSON(e)); + } + return obj; + }, + + create(base?: DeepPartial): ListQuestionsResponse { + return ListQuestionsResponse.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): ListQuestionsResponse { + const message = createBaseListQuestionsResponse(); + message.questions = object.questions?.map((e) => Question.fromPartial(e)) || []; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_request.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_request.ts new file mode 100644 index 00000000..59829ab4 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_request.ts @@ -0,0 +1,120 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/remove_question_request.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface RemoveQuestionRequest { + hackathonId: string; + questionId: string; +} + +function createBaseRemoveQuestionRequest(): RemoveQuestionRequest { + return { hackathonId: "", questionId: "" }; +} + +export const RemoveQuestionRequest: MessageFns = { + encode(message: RemoveQuestionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.hackathonId !== "") { + writer.uint32(10).string(message.hackathonId); + } + if (message.questionId !== "") { + writer.uint32(18).string(message.questionId); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RemoveQuestionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRemoveQuestionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.hackathonId = reader.string(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } + + message.questionId = reader.string(); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): RemoveQuestionRequest { + return { + hackathonId: isSet(object.hackathonId) + ? globalThis.String(object.hackathonId) + : isSet(object.hackathon_id) + ? globalThis.String(object.hackathon_id) + : "", + questionId: isSet(object.questionId) + ? globalThis.String(object.questionId) + : isSet(object.question_id) + ? globalThis.String(object.question_id) + : "", + }; + }, + + toJSON(message: RemoveQuestionRequest): unknown { + const obj: any = {}; + if (message.hackathonId !== "") { + obj.hackathonId = message.hackathonId; + } + if (message.questionId !== "") { + obj.questionId = message.questionId; + } + return obj; + }, + + create(base?: DeepPartial): RemoveQuestionRequest { + return RemoveQuestionRequest.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): RemoveQuestionRequest { + const message = createBaseRemoveQuestionRequest(); + message.hackathonId = object.hackathonId ?? ""; + message.questionId = object.questionId ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_response.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_response.ts new file mode 100644 index 00000000..63cec7dd --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/remove_question_response.ts @@ -0,0 +1,73 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/remove_question_response.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface RemoveQuestionResponse { +} + +function createBaseRemoveQuestionResponse(): RemoveQuestionResponse { + return {}; +} + +export const RemoveQuestionResponse: MessageFns = { + encode(_: RemoveQuestionResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RemoveQuestionResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRemoveQuestionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): RemoveQuestionResponse { + return {}; + }, + + toJSON(_: RemoveQuestionResponse): unknown { + const obj: any = {}; + return obj; + }, + + create(base?: DeepPartial): RemoveQuestionResponse { + return RemoveQuestionResponse.fromPartial(base ?? {}); + }, + fromPartial(_: DeepPartial): RemoveQuestionResponse { + const message = createBaseRemoveQuestionResponse(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_request.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_request.ts new file mode 100644 index 00000000..4b1b7486 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_request.ts @@ -0,0 +1,117 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/submit_answers_request.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Answer } from "../../entities/answer"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface SubmitAnswersRequest { + hackathonId: string; + answers: Answer[]; +} + +function createBaseSubmitAnswersRequest(): SubmitAnswersRequest { + return { hackathonId: "", answers: [] }; +} + +export const SubmitAnswersRequest: MessageFns = { + encode(message: SubmitAnswersRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.hackathonId !== "") { + writer.uint32(10).string(message.hackathonId); + } + for (const v of message.answers) { + Answer.encode(v!, writer.uint32(18).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): SubmitAnswersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSubmitAnswersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break; + } + + message.hackathonId = reader.string(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } + + message.answers.push(Answer.decode(reader, reader.uint32())); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): SubmitAnswersRequest { + return { + hackathonId: isSet(object.hackathonId) + ? globalThis.String(object.hackathonId) + : isSet(object.hackathon_id) + ? globalThis.String(object.hackathon_id) + : "", + answers: globalThis.Array.isArray(object?.answers) ? object.answers.map((e: any) => Answer.fromJSON(e)) : [], + }; + }, + + toJSON(message: SubmitAnswersRequest): unknown { + const obj: any = {}; + if (message.hackathonId !== "") { + obj.hackathonId = message.hackathonId; + } + if (message.answers?.length) { + obj.answers = message.answers.map((e) => Answer.toJSON(e)); + } + return obj; + }, + + create(base?: DeepPartial): SubmitAnswersRequest { + return SubmitAnswersRequest.fromPartial(base ?? {}); + }, + fromPartial(object: DeepPartial): SubmitAnswersRequest { + const message = createBaseSubmitAnswersRequest(); + message.hackathonId = object.hackathonId ?? ""; + message.answers = object.answers?.map((e) => Answer.fromPartial(e)) || []; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +} diff --git a/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_response.ts b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_response.ts new file mode 100644 index 00000000..e90076f5 --- /dev/null +++ b/components/frontend/src/lib/server/grpc/generated/hackathon/messages/hackathon_svc/submit_answers_response.ts @@ -0,0 +1,73 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc unknown +// source: hackathon/messages/hackathon_svc/submit_answers_response.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "hackathon.messages.hackathon_svc"; + +export interface SubmitAnswersResponse { +} + +function createBaseSubmitAnswersResponse(): SubmitAnswersResponse { + return {}; +} + +export const SubmitAnswersResponse: MessageFns = { + encode(_: SubmitAnswersResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): SubmitAnswersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSubmitAnswersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): SubmitAnswersResponse { + return {}; + }, + + toJSON(_: SubmitAnswersResponse): unknown { + const obj: any = {}; + return obj; + }, + + create(base?: DeepPartial): SubmitAnswersResponse { + return SubmitAnswersResponse.fromPartial(base ?? {}); + }, + fromPartial(_: DeepPartial): SubmitAnswersResponse { + const message = createBaseSubmitAnswersResponse(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create(base?: DeepPartial): T; + fromPartial(object: DeepPartial): T; +}