Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
113 changes: 35 additions & 78 deletions DotnetApp/Models/TaskItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
5 changes: 1 addition & 4 deletions DotnetApp/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
11 changes: 0 additions & 11 deletions diag.mmd

This file was deleted.

Empty file removed python/point.py
Empty file.
12 changes: 5 additions & 7 deletions python/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Check failure

Code scanning / SonarCloud

Credentials should not be hard-coded High

Revoke and change this password, as it is compromised. See more on SonarQube Cloud
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()
Expand Down
Empty file removed python/tests/test_calculator.py
Empty file.
39 changes: 0 additions & 39 deletions rust/server.rs

This file was deleted.

Empty file removed terraform/iac.tf
Empty file.