Skip to content

Commit

Permalink
rename multi option data "rank" to "order"
Browse files Browse the repository at this point in the history
  • Loading branch information
KavikaPalletenne committed Nov 5, 2024
1 parent f491684 commit 1bfb005
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions backend/migrations/20240406031400_create_questions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CREATE TABLE multi_option_question_options (
id BIGINT PRIMARY KEY,
text TEXT NOT NULL,
question_id BIGINT NOT NULL,
order INTEGER NOT NULL,
CONSTRAINT FK_multi_option_question_options_questions
FOREIGN KEY(question_id)
REFERENCES questions(id)
Expand Down
6 changes: 3 additions & 3 deletions backend/server/src/models/question.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub struct MultiOptionData {
#[derive(Deserialize, Serialize)]
pub struct MultiOptionQuestionOption {
id: i32,
rank: i32,
order: i32,
text: String,
}

Expand Down Expand Up @@ -95,11 +95,11 @@ impl QuestionData {
| Self::DropDown(data)
| Self::Ranking(data) => {
let mut query_builder =
QueryBuilder::new("INSERT INTO multi_option_question_options (id, text, question_id, rank)");
QueryBuilder::new("INSERT INTO multi_option_question_options (id, text, question_id, order)");

query_builder.push_values(data.options, |mut b, option| {
let id = snowflake_generator.real_time_generate();
b.push_bind(id).push_bind(option.text).push_bind(question_id).push_bind(option.rank);
b.push_bind(id).push_bind(option.text).push_bind(question_id).push_bind(option.order);
});

let query = query_builder.build();
Expand Down

0 comments on commit 1bfb005

Please sign in to comment.