Compare commits
	
		
			4 commits
		
	
	
		
			3530b4d140
			...
			b9c8cf5b05
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						b9c8cf5b05 | ||
| 
							 | 
						43668dc8d3 | ||
| 
							 | 
						9425d585bf | ||
| 
							 | 
						e0310d0410 | 
					 5 changed files with 41 additions and 9 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -27,3 +27,4 @@ krusty.sqlite3
 | 
			
		|||
 | 
			
		||||
*.sqlite3
 | 
			
		||||
*.db
 | 
			
		||||
*.tar.gz
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS orders (
 | 
			
		|||
-- Recipes for all the cookies (essentially a list of cookies)
 | 
			
		||||
CREATE TABLE IF NOT EXISTS recipes (
 | 
			
		||||
  recipe_id int PRIMARY KEY,
 | 
			
		||||
  recipe_name varchar(100) -- Cookie name
 | 
			
		||||
  recipe_name varchar(100) UNIQUE -- Cookie name
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
-- "The company has a raw materials warehouse in which 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
-- Inserts here
 | 
			
		||||
INSERT OR IGNORE INTO
 | 
			
		||||
  customers (customer_id, customer_name, customer_address)
 | 
			
		||||
INSERT
 | 
			
		||||
OR IGNORE INTO customers (customer_id, customer_name, customer_address)
 | 
			
		||||
VALUES
 | 
			
		||||
  (1, 'Bjudkakor AB', 'Ystad'),
 | 
			
		||||
  (2, 'Finkakor AB', 'Helsingborg'),
 | 
			
		||||
| 
						 | 
				
			
			@ -11,8 +11,8 @@ VALUES
 | 
			
		|||
  (7, 'Skånekakor AB', 'Perstorp'),
 | 
			
		||||
  (8, 'Småbröd AB', 'Malmö');
 | 
			
		||||
 | 
			
		||||
INSERT INTO
 | 
			
		||||
  recipes (recipe_name)
 | 
			
		||||
INSERT
 | 
			
		||||
OR IGNORE INTO recipes (recipe_name)
 | 
			
		||||
VALUES
 | 
			
		||||
  ('Nut ring'),
 | 
			
		||||
  ('Nut cookie'),
 | 
			
		||||
| 
						 | 
				
			
			@ -20,3 +20,26 @@ VALUES
 | 
			
		|||
  ('Tango'),
 | 
			
		||||
  ('Almond delight'),
 | 
			
		||||
  ('Berliner');
 | 
			
		||||
 | 
			
		||||
INSERT
 | 
			
		||||
OR IGNORE INTO ingredients (ingredient_name, amount, unit)
 | 
			
		||||
VALUES
 | 
			
		||||
  ('Bread crumbs', 500000, 'g'),
 | 
			
		||||
  ('Butter', 500000, 'g'),
 | 
			
		||||
  ('Chocolate', 500000, 'g'),
 | 
			
		||||
  ('Chopped almonds', 500000, 'g'),
 | 
			
		||||
  ('Cinnamon', 500000, 'g'),
 | 
			
		||||
  ('Egg whites', 500000, 'ml'),
 | 
			
		||||
  ('Eggs', 500000, 'g'),
 | 
			
		||||
  ('Fine-ground nuts', 500000, 'g'),
 | 
			
		||||
  ('Flour', 500000, 'g'),
 | 
			
		||||
  ('Ground, roasted nuts', 500000, 'g'),
 | 
			
		||||
  ('Icing sugar', 500000, 'g'),
 | 
			
		||||
  ('Marzipan', 500000, 'g'),
 | 
			
		||||
  ('Potato starch', 500000, 'g'),
 | 
			
		||||
  ('Roasted, chopped nuts', 500000, 'g'),
 | 
			
		||||
  ('Sodium bicarbonate', 500000, 'g'),
 | 
			
		||||
  ('Sugar', 500000, 'g'),
 | 
			
		||||
  ('Vanilla', 500000, 'g'),
 | 
			
		||||
  ('Vanilla sugar', 500000, 'g'),
 | 
			
		||||
  ('Wheat flour', 500000, 'g');
 | 
			
		||||
| 
						 | 
				
			
			@ -22,8 +22,8 @@ public class Database {
 | 
			
		|||
	// "jdbc:sqlite:<filename>.sqlite3" to use a file-based database instead.
 | 
			
		||||
	// Nore that ":memory:" is an **SQLite specific** magic string that tells the
 | 
			
		||||
	// underlying SQLite engine to store the database in memory.
 | 
			
		||||
	// private static final String jdbcString = "jdbc:sqlite::memory:";
 | 
			
		||||
	private static final String jdbcString = "jdbc:sqlite:krusty.db";
 | 
			
		||||
	private static final String jdbcString = "jdbc:sqlite::memory:";
 | 
			
		||||
	// private static final String jdbcString = "jdbc:sqlite:krusty.db";
 | 
			
		||||
	private Connection conn = null;
 | 
			
		||||
 | 
			
		||||
	public String getCustomers(Request req, Response res) {
 | 
			
		||||
| 
						 | 
				
			
			@ -34,11 +34,14 @@ public class Database {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public String getRawMaterials(Request req, Response res) {
 | 
			
		||||
		return "{}";
 | 
			
		||||
		String result = selectQuery("ingredients", "raw-materials", "ingredient_name", "amount", "unit");
 | 
			
		||||
		result = result.replaceAll("ingredient_name", "name");
 | 
			
		||||
		return result;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getCookies(Request req, Response res) {
 | 
			
		||||
		String result = selectQuery("recipes", "cookies", "recipe_name");
 | 
			
		||||
		result = result.replaceAll("recipe_name", "name");
 | 
			
		||||
		return result;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								makefile
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								makefile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -17,4 +17,9 @@ migrate:
 | 
			
		|||
	sqlite3 app/krusty.db < app/Migrations/create-schema.sql
 | 
			
		||||
	sqlite3 app/krusty.db < app/Migrations/initial-data.sql
 | 
			
		||||
 | 
			
		||||
GITHASH := $(shell git rev-parse --short HEAD)
 | 
			
		||||
# Tar everything that isnt gitignored
 | 
			
		||||
release:
 | 
			
		||||
	git ls-files -z | xargs -0 tar -czf krusty-imbus_$(GITHASH).tar.gz
 | 
			
		||||
 | 
			
		||||
.PHONY: run clean test build
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue