Skip to content
Open

SQL #191

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
18f19d2
added exercises
s09hilpa Oct 26, 2025
0e22b10
added fav food file
s09hilpa Oct 26, 2025
98936ae
Added second favourite food
s09hilpa Oct 26, 2025
c0d06ae
Added countries
s09hilpa Oct 26, 2025
20e745b
Merge pull request #1 from s09hilpa/git-week1/shilpa
s09hilpa Oct 26, 2025
194c9ec
added files for intro-to-ai
s09hilpa Oct 28, 2025
464bc8f
added about me file
s09hilpa Oct 28, 2025
abcfc9a
Add file Exercice4-aboutme.html
s09hilpa Nov 2, 2025
c7d4ba8
modified Excercise4
s09hilpa Nov 2, 2025
1a00e5b
Merge pull request #2 from s09hilpa/intro-to-ai
s09hilpa Nov 2, 2025
81373db
Add javascript files for week1 assignment
s09hilpa Nov 4, 2025
f47b3cc
updated the corrections
s09hilpa Nov 11, 2025
1b47e68
Merge pull request #3 from s09hilpa/week1-javascript
s09hilpa Nov 11, 2025
4bda1f8
add javascript week 2Assignment
s09hilpa Nov 12, 2025
ec5a075
JS week2 ass
s09hilpa Nov 14, 2025
392a73c
modified changes
s09hilpa Nov 14, 2025
16d85e9
Merge pull request #5 from s09hilpa/Ass-week2-js
s09hilpa Nov 14, 2025
380943c
JS week3 Assignment
s09hilpa Nov 19, 2025
18ceae7
JS Week4 Assignment
s09hilpa Nov 26, 2025
af86bc4
web architecture101 Diagram
s09hilpa Dec 3, 2025
5837b1e
Add HOGWARTS and hyfBay assignments
s09hilpa Jan 8, 2026
e631b66
Practice using Postman
s09hilpa Jan 9, 2026
a65a91e
Agile Assignment
s09hilpa Jan 14, 2026
be1044d
Merge branch 'main' into main
s09hilpa Feb 22, 2026
be79a29
Merge branch 'HackYourFuture-CPH:main' into main
s09hilpa Mar 11, 2026
d06652e
add week1 exercise
s09hilpa Mar 15, 2026
fc644f6
Merge pull request #13 from s09hilpa/week1-advancejs
s09hilpa Mar 15, 2026
e1602c3
Merge pull request #12 from s09hilpa/Agile-Assignment
s09hilpa Mar 15, 2026
82e21e7
Merge pull request #9 from s09hilpa/backend-assignment
s09hilpa Mar 15, 2026
6c577e1
moved to week1
s09hilpa Mar 15, 2026
4b60e58
Move
s09hilpa Mar 16, 2026
d81c2ab
Merge pull request #10 from s09hilpa/postman-ex
s09hilpa Mar 18, 2026
68829f3
add assignment file
s09hilpa Mar 20, 2026
ebabe9d
modified exercise2
s09hilpa Mar 21, 2026
ce213ce
Merge pull request #15 from s09hilpa/week-2-New
s09hilpa Apr 8, 2026
cb6207b
Complete SQL assignment: aggregation, joins, transactions, and security
s09hilpa Apr 22, 2026
1536173
Merge pull request #21 from s09hilpa/week2-database
s09hilpa May 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
node_modules/
.env
.DS_Store
.vscode/
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { teas } from "./teas.js";

const result = teas
.filter((tea) => tea.caffeineLevel !== "none")
.map((tea) => tea.name.toUpperCase());

console.log(result);
23 changes: 23 additions & 0 deletions courses/backend/advanced-javascript/week1-assignment /exercise2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { teas } from "./teas.js";
function inventoryReport(teas) {
const totalTeas = teas.length;
const inStock = teas.filter((tea) => tea.inStock).length;

const outOfStock = teas.filter((tea) => !tea.inStock).length;

const totalInventoryValue = teas.reduce(
(sum, tea) => sum + tea.pricePerGram * tea.stockCount,
0,
);

const averagePrice =
teas.reduce((sum, tea) => sum + tea.pricePerGram, 0) / teas.length;
return {
totalTeas,
inStock,
outOfStock,
totalInventoryValue,
averagePrice,
};
}
console.log(inventoryReport(teas));
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { teas } from "./teas.js";
function lowStockAlert(teas) {
return teas
.filter((tea) => tea.stockCount < 50)
.map((tea) => ({ name: tea.name, stockCount: tea.stockCount }))
.sort((a, b) => a.stockCount - b.stockCount);
}
console.log(lowStockAlert(teas));
15 changes: 15 additions & 0 deletions courses/backend/advanced-javascript/week1-assignment /exercise4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { teas } from "./teas.js";

function teasByOrigin(teas) {
return teas.reduce((group, tea) => {
if (!group[tea.origin]) {
group[tea.origin] = [];
}

group[tea.origin].push(tea.name);

return group;
}, {});
}

console.log(teasByOrigin(teas));
11 changes: 11 additions & 0 deletions courses/backend/advanced-javascript/week1-assignment /exercise5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { teas } from "./teas.js";
function searchTeas(teas, query) {
return teas
.filter((tea) => tea.name.toLowerCase().includes(query.toLowerCase()))
.map((tea) => tea.name)
.sort();
}

console.log(searchTeas(teas, "earl"));
console.log(searchTeas(teas, "dragon"));
console.log(searchTeas(teas, "ch"));
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { teas } from "./teas.js";
const totalValue = teas.reduce((sum, tea) => {
return sum + tea.pricePerGram * tea.stockCount;
}, 0);
console.log("Total inventory value:", totalValue);
12 changes: 12 additions & 0 deletions courses/backend/advanced-javascript/week1-assignment /exercise7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { teas } from "./teas.js";
const countByType = teas.reduce((counts, tea) => {
if (!counts[tea.type]) {
counts[tea.type] = 0;
}

counts[tea.type]++;

return counts;
}, {});

console.log(countByType);
23 changes: 23 additions & 0 deletions courses/backend/advanced-javascript/week1-assignment /teas.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions courses/backend/advanced-javascript/week2-assignment/exercise1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { teas } from "./teas.js";

function stockByCaffeine(teas) {
return teas.reduce((acc, tea) => {
acc[tea.caffeineLevel] = (acc[tea.caffeineLevel] || 0) + tea.stockCount;
return acc;
}, {});
}

console.log(stockByCaffeine(teas));
56 changes: 56 additions & 0 deletions courses/backend/advanced-javascript/week2-assignment/exercise2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { teas } from "./teas.js";

const order = {
id: 1001,
customerId: 42,
items: [
{ teaId: 1, grams: 100 },
{ teaId: 8, grams: 50 },
{ teaId: 3, grams: 200 },
],
};
// Validate
export function validateOrder(order, callback) {
setTimeout(() => {
const errors = order.items
.filter((item) => !teas.find((t) => t.id === item.teaId))
.map((item) => `Tea with id ${item.teaId} not found`);

callback({ valid: errors.length === 0, errors });
}, 200);
}
validateOrder(order, console.log);
// Calculate total
export function calculateTotal(order, callback) {
setTimeout(() => {
let total = 0;
for (const item of order.items) {
const tea = teas.find((t) => t.id === item.teaId);
if (tea) total += tea.pricePerGram * item.grams;
}

callback({ orderId: order.id, total });
}, 300);
}
calculateTotal(order, console.log);

// Check stock
export function checkStock(order, callback) {
setTimeout(() => {
const shortages = [];

for (const item of order.items) {
const tea = teas.find((t) => t.id === item.teaId);
if (tea && tea.stockCount < item.grams) {
shortages.push(`${tea.name} not enough stock`);
}
}

callback({
orderId: order.id,
inStock: shortages.length === 0,
shortages,
});
}, 400);
}
checkStock(order, console.log);
39 changes: 39 additions & 0 deletions courses/backend/advanced-javascript/week2-assignment/exercise3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { teas } from "./teas.js";

import { validateOrder, calculateTotal, checkStock } from "./exercise2.js";

const order = {
id: 1001,
customerId: 42,
items: [
{ teaId: 1, grams: 100 },
{ teaId: 8, grams: 50 },
{ teaId: 3, grams: 200 },
],
};
function processOrder(order) {
console.log("Processing order", order.id);

validateOrder(order, (validation) => {
if (!validation.valid) {
console.log("Validation failed:", validation.errors);
return;
}
console.log("Validation passed");

calculateTotal(order, (pricing) => {
console.log("Total:", pricing.total);

checkStock(order, (stock) => {
if (!stock.inStock) {
console.log("Stock issues:", stock.shortages);
return;
}

console.log("Order processed successfully!");
});
});
});
}

processOrder(order);
41 changes: 41 additions & 0 deletions courses/backend/advanced-javascript/week2-assignment/exercise4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { teas } from "./teas.js";

import fs from "fs";

function generateInventoryReport(callback) {
fs.readFile("./inventory-updates.json", "utf8", (err, data) => {
if (err) {
callback(err, null);
return;
}
const updates = JSON.parse(data);

const changes = updates.reduce((acc, update) => {
acc[update.teaId] = (acc[update.teaId] || 0) + update.change;
return acc;
}, {});

let report = "Inventory Report:\n";

teas.forEach((tea) => {
const change = changes[tea.id] || 0;
const newStock = tea.stockCount + change;

if (change !== 0) {
report += `- ${tea.name}: was ${tea.stockCount}, change ${change >= 0 ? "+" : ""}${change}, now ${newStock}`;
if (newStock < 0) report += " (NEGATIVE!)";
report += "\n";
}
});

callback(null, report);
});
}

generateInventoryReport((err, report) => {
if (err) {
console.error(err);
return;
}
console.log(report);
});
40 changes: 40 additions & 0 deletions courses/backend/advanced-javascript/week2-assignment/exercise5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { teas } from "./teas.js";
function runSequentially(tasks, finalCallback) {
let index = 0;

function next() {
if (index === tasks.length) {
finalCallback();
return;
}

const task = tasks[index];
index++;

task(() => next());
}

next();
}

// Test
const tasks = [
(done) =>
setTimeout(() => {
console.log("Task 1");
done();
}, 300),
(done) =>
setTimeout(() => {
console.log("Task 2");
done();
}, 200),
(done) =>
setTimeout(() => {
console.log("Task 3");
done();
}, 100),
];
runSequentially(tasks, () => {
console.log("All tasks complete!");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{ "teaId": 1, "change": -20, "reason": "sale" },
{ "teaId": 1, "change": 50, "reason": "restock" },
{ "teaId": 8, "change": -10, "reason": "sale" },
{ "teaId": 3, "change": -100, "reason": "sale" },
{ "teaId": 8, "change": 30, "reason": "restock" }
]
24 changes: 24 additions & 0 deletions courses/backend/advanced-javascript/week2-assignment/teas.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading