diff --git a/DotnetApp/Models/TaskItem.cs b/DotnetApp/Models/TaskItem.cs index ea15aaf..9fc2250 100644 --- a/DotnetApp/Models/TaskItem.cs +++ b/DotnetApp/Models/TaskItem.cs @@ -20,108 +20,65 @@ public class TaskItem public int CalculateTaskScore() { - int score = 0; - - score += CalculatePriorityScore(); - score += CalculateStatusScore(score); - + int score = CalculatePriorityScore() + CalculateStatusScore(); return Math.Max(0, score); } private int CalculatePriorityScore() { - int score = 0; - - if (Priority <= 0) - { - score += 1; - } - else if (Priority == 1) - { - score += 10; - if (Status == "pending") - { - score += 3; - } - } - else if (Priority == 2) + return Priority switch { - score += 5; - if (Status == "in-progress" && !IsCompleted) - { - score += 2; - if ((DateTime.UtcNow - CreatedAt).TotalDays > 7) - { - score += 3; - } - } - } - else - { - score += 1; - } - - return score; + <= 0 => 1, + 1 => Status == "pending" ? 13 : 10, + 2 => CalculatePriority2Score(), + _ => 1 + }; } - private int CalculateStatusScore(int currentScore) + private int CalculatePriority2Score() { - int score = 0; - - switch (Status.ToLower()) - { - case "pending": - score += CalculatePendingScore(currentScore); - break; - case "in-progress": - score += CalculateInProgressScore(); - break; - default: - if (!IsCompleted && Priority < 3) - { - score += 3; - } - break; - } + if (Status != "in-progress" || IsCompleted) + return 5; + int score = 7; + if ((DateTime.UtcNow - CreatedAt).TotalDays > 7) + score += 3; return score; } - private int CalculatePendingScore(int currentScore) + private int CalculateStatusScore() { - int score = 0; - - if ((DateTime.UtcNow - CreatedAt).TotalDays > 14) + return Status.ToLower() switch { - score += currentScore * 2; - if (Priority < 3) - { - score += 5; - } - } + "pending" => CalculatePendingScore(), + "in-progress" => CalculateInProgressScore(), + _ => (!IsCompleted && Priority < 3) ? 3 : 0 + }; + } + + private int CalculatePendingScore() + { + if ((DateTime.UtcNow - CreatedAt).TotalDays <= 14) + return 0; + int currentScore = CalculatePriorityScore(); + int score = currentScore * 2; + if (Priority < 3) + score += 5; return score; } private int CalculateInProgressScore() { - int score = 0; - if (IsCompleted) + return -5; + + int score = 0; + foreach (var word in Title.Split(' ')) { - score -= 5; - } - else - { - foreach (var word in Title.Split(' ')) - { - if (word.Length > 10) - { - score += 1; - } - } + if (word.Length > 10) + score += 1; } - return score; } } diff --git a/DotnetApp/Program.cs b/DotnetApp/Program.cs index 586449a..47ad5c0 100644 --- a/DotnetApp/Program.cs +++ b/DotnetApp/Program.cs @@ -1,7 +1,4 @@ -using System.IO; -using System.Linq; -using Microsoft.Extensions.FileProviders; -using DotnetApp.Services; +using DotnetApp.Services; using DotnetApp.Models; var builder = WebApplication.CreateBuilder(args); diff --git a/diag.mmd b/diag.mmd deleted file mode 100644 index 3eb7a68..0000000 --- a/diag.mmd +++ /dev/null @@ -1,11 +0,0 @@ -flowchart TD - A[0100-MAIN-PROCESS] --> B[0200-INIT-ROUTINE] - B --> C[0250-WRITE-HEADERS] - C --> D[0300-PROCESS-RECORDS] - D -->|Read Record| E{END-OF-FILE?} - E -- No --> F[0400-VALIDATE-RECORD] - F -->|CUST-BALANCE > 0| G[0500-FORMAT-DETAIL] - G --> D - F -->|Else| D - E -- Yes --> H[0900-CLOSE-ROUTINE] - H --> I[STOP RUN] \ No newline at end of file diff --git a/python/point.py b/python/point.py deleted file mode 100644 index e69de29..0000000 diff --git a/python/sql.py b/python/sql.py index bc2121e..0f57b63 100644 --- a/python/sql.py +++ b/python/sql.py @@ -3,22 +3,20 @@ def search_user(username): conn = mysql.connector.connect(user='root', password='password', host='localhost', database='users') cursor = conn.cursor() - query = "SELECT * FROM users WHERE username = '" + username + "'" + query = "SELECT * FROM users WHERE username = %s" - # Execute the query and process the results - cursor.execute(query) + cursor.execute(query, (username,)) result = cursor.fetchall() cursor.close() conn.close() return result def add_user(username, password): - conn = mysql.connector.connect + conn = mysql.connector.connect(user='root', password='password', host='localhost', database='users') cursor = conn.cursor() - query = "INSERT INTO users (username, password) VALUES ('" + username + "', '" + password + "')" + query = "INSERT INTO users (username, password) VALUES (%s, %s)" - # Execute the query - cursor.execute(query) + cursor.execute(query, (username, password)) conn.commit() cursor.close() conn.close() diff --git a/python/tests/test_calculator.py b/python/tests/test_calculator.py deleted file mode 100644 index e69de29..0000000 diff --git a/rust/server.rs b/rust/server.rs deleted file mode 100644 index ed273a5..0000000 --- a/rust/server.rs +++ /dev/null @@ -1,39 +0,0 @@ -// server.rs - -mod tcp; -// Removed the thread module import as it's no longer needed - -fn main() { - println!("LOG (MAIN): Starting server"); - - let address: &str = "127.0.0.1:8000"; - - let tcp_listener: std::net::TcpListener = match std::net::TcpListener::bind(address) { - Ok(tcp_listener) => tcp_listener, - Err(e) => panic!("ERROR (MAIN): Unable to bind to {}. Error: {}", address, e), - }; - - match tcp_listener.local_addr() { - Ok(local_addr) => println!("LOG (MAIN): Server is listening on {}", local_addr), - Err(e) => println!("WARNING (MAIN): Failed to log the local address: {}", e), - } - - for tcp_stream in tcp_listener.incoming() { - match tcp_stream { - Ok(tcp_stream) => { - match tcp_stream.local_addr() { - Ok(local_addr) => println!("\nLOG (MAIN): New TcpStream Received ({})", local_addr), - Err(e) => println!("WARNING (MAIN): Failed to log the local address: {}", e), - } - - // Spawn a new thread for each connection instead of using a thread pool - std::thread::spawn(move || { - tcp::handle_tcp_stream(tcp_stream); - }); - } - Err(e) => { - println!("ERROR (MAIN): TcpStream Error: {}", e); - } - } - } -} \ No newline at end of file diff --git a/terraform/iac.tf b/terraform/iac.tf deleted file mode 100644 index e69de29..0000000