Skip to content

Hannah N#9

Open
hannahwn wants to merge 2 commits into
HackYourAssignment:mainfrom
hannahwn:main
Open

Hannah N#9
hannahwn wants to merge 2 commits into
HackYourAssignment:mainfrom
hannahwn:main

Conversation

@hannahwn
Copy link
Copy Markdown

@hannahwn hannahwn commented Apr 1, 2026

No description provided.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

📝 HackYourFuture auto grade

Assignment Score: 0 / 100 ✅

Status: ✅ Passed
Minimum score to pass: 0
🧪 The auto grade is experimental and still being improved

Test Details

@remarcmij remarcmij self-assigned this Apr 1, 2026
Copy link
Copy Markdown

@remarcmij remarcmij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hannahwn, some minor issues, but overall this looks good to me.

Comment thread task-1/queries.sql

SELECT title,published_year FROM books b
WHERE b.genre = "Science Fiction"
ORDER BY b.published_year ASC ;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For better readability, add a space after a comma.
  2. If you have only one table, there can be no confusion as to which field belongs to which table. You therefore do not need to prefix the field names with the table name (or alias):
SELECT title, published_year FROM books
WHERE genre = "Science Fiction"
ORDER BY published_year ASC;

Comment thread task-1/queries.sql
-- **Question 2** — Show every book published before 1950. Display the title and year only.

SELECT title,published_year FROM books b
WHERE b.published_year < 1950;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment thread task-1/queries.sql

SELECT b.title,a.first_name || ' ' || a.last_name AS author
FROM books b
JOIN authors a ON b.author_id = a.id;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you indeed need to prefix the field name id with the table name because both tables have an id field. Strictly speaking, that is the only field that needs a prefix. But your version with table prefixes is preferred and more robust than the minimal version shown below. That version makes assumptions about the uniqueness of some fields, which may not hold in the future if more fields are added.

SELECT title, first_name || ' ' || last_name AS author
FROM books
JOIN authors a ON author_id = a.id;

Comment thread task-2/setup.sql
Comment on lines +1 to +5
CREATE TABLE decks(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
description TEXT
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be consistent with indentation:

Suggested change
CREATE TABLE decks(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
description TEXT
);
CREATE TABLE decks(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
description TEXT
);

Comment thread task-2/migrate.js
console.log(`Added card: ${card.question}`);
}

console.log("Migration done! All decks and cards are in the database.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine.

Comment thread task-2/src/database.js
@@ -21,47 +21,108 @@ const db = new Database(DB_FILE);

export function getAllDecks() {
// TODO: return all rows from the decks table
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the TODO comments once they are done.

Comment thread task-2/src/database.js
Comment on lines +24 to +31
try{

const decks = db.prepare("SELECT * FROM decks").all();

return decks;}
catch(err){
throw new Error(`Failed to get all decks: ${err.message}`);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not necessary to create try/catch blocks here. But if you do, make sure that you format them correctly (Prettier should do this automatically, if your VS Code is configured correctly).

  try {
    const decks = db.prepare("SELECT * FROM decks").all();
    return decks;
  } catch(err){
    throw new Error(`Failed to get all decks: ${err.message}`);
  }

Comment thread task-2/src/database.js

return result.changes > 0;
}catch(err){
throw new Error(`Failed to delete deck with id ${id}: ${err.message}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id variable in the catch block is undefined.

Comment thread task-2/src/database.js
try{
// TODO: return all card rows whose deckId matches
throw new Error('Not implemented');
return db.prepare("SELECT id, question, answer, learned, deck_id AS deckId FROM cards WHERE deck_id = ?").all(deckId);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are returning learned as a number. The JSON version returned it as a boolean.

@remarcmij remarcmij added the Reviewed This assignment has been reivewed by a mentor and a feedback has been provided label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed This assignment has been reivewed by a mentor and a feedback has been provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants