Skip to content

Commit a6723ab

Browse files
Fixed the maintainability code quality issues
1 parent 79badcb commit a6723ab

17 files changed

Lines changed: 20 additions & 154 deletions

File tree

src/backend/common/database/cosmosdb.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,6 @@ async def update_batch_entry(
352352
batch["file_count"] = file_count
353353

354354
await self.batch_container.replace_item(item=batch_id, body=batch)
355-
# if isinstance(status, ProcessStatus):
356-
# self.logger.info(f"Updated batch {batch_id} to status {status.value}")
357-
# else:
358-
# self.logger.info(f"Updated batch {batch_id} to status {status}")
359355

360356
return batch
361357
except Exception as e:

src/backend/common/storage/blob_azure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def upload_file(
5252
raise
5353
try:
5454
# Upload the file
55-
upload_results = blob_client.upload_blob( # noqa: F841
55+
blob_client.upload_blob(
5656
file_content,
5757
content_type=content_type,
5858
metadata=metadata,

src/backend/sql_agents/convert_script.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ async def convert_script(
6666

6767
# orchestrate the chat
6868
current_migration = "No migration"
69-
is_complete: bool = False
70-
while not is_complete:
69+
while True:
7170
await comms_manager.group_chat.add_chat_message(
7271
ChatMessageContent(role=AuthorRole.USER, content=source_script)
7372
)
@@ -274,10 +273,8 @@ async def convert_script(
274273
break
275274

276275
if comms_manager.group_chat.is_complete:
277-
is_complete = True
278-
279-
break
280-
276+
break
277+
281278
migrated_query = current_migration
282279

283280
# Handle the case where migration failed and current_migration is None

src/backend/sql_agents/helpers/comms_manager.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,3 @@ async def cleanup(self):
270270

271271
except Exception as e:
272272
self.logger.error("Error during cleanup: %s", str(e))
273-
274-
def __del__(self):
275-
"""Destructor to ensure cleanup if not explicitly called."""
276-
try:
277-
# Only attempt cleanup if there's an active event loop
278-
loop = asyncio.get_running_loop()
279-
if loop and not loop.is_closed():
280-
# Schedule cleanup as a task
281-
loop.create_task(self.cleanup())
282-
except RuntimeError:
283-
# No event loop running, can't clean up asynchronously
284-
self.logger.warning("No event loop available for cleanup in destructor")
285-
except Exception as e:
286-
self.logger.error("Error in destructor cleanup: %s", str(e))

src/backend/sql_agents/tools/src/Program.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using Microsoft.SqlServer.TransactSql.ScriptDom;
56
using Newtonsoft.Json;
67

@@ -42,18 +43,14 @@ static void Main(string[] args)
4243

4344
IList<ParseError> errors = ParseSqlQuery(sqlQuery);
4445

45-
var errorList = new List<Dictionary<string, object>>();
46-
47-
foreach (var error in errors)
48-
{
49-
var errorDict = new Dictionary<string, object>
46+
var errorList = errors
47+
.Select(error => new Dictionary<string, object>
5048
{
5149
{ "Line", error.Line },
5250
{ "Column", error.Column },
5351
{ "Error", error.Message }
54-
};
55-
errorList.Add(errorDict);
56-
}
52+
})
53+
.ToList();
5754

5855
string jsonOutput = JsonConvert.SerializeObject(errorList, Formatting.Indented);
5956
Console.WriteLine(jsonOutput);

src/frontend/frontend_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dotenv import load_dotenv
55
from fastapi import FastAPI
66
from fastapi.middleware.cors import CORSMiddleware
7-
from fastapi.responses import FileResponse, HTMLResponse
7+
from fastapi.responses import FileResponse
88
from fastapi.staticfiles import StaticFiles
99

1010
# Load environment variables from .env file

src/frontend/src/components/batchHistoryPanel.tsx

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState, useEffect, useRef } from "react";
2-
3-
import { useDispatch, useSelector } from 'react-redux';
2+
import { useDispatch } from 'react-redux';
43
import { Card, Spinner, Tooltip } from "@fluentui/react-components";
54
import { useNavigate } from "react-router-dom";
65
import ConfirmationDialog from "../commonComponents/ConfirmationDialog/confirmationDialogue";
@@ -21,7 +20,7 @@ interface BatchHistoryItem {
2120
status: string;
2221
}
2322
const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
24-
const headers = {}
23+
const headers = {};
2524
const [batchHistory, setBatchHistory] = useState<BatchHistoryItem[]>([]);
2625
const [loading, setLoading] = useState(false);
2726
const [error, setError] = useState<string | null>(null);
@@ -81,46 +80,6 @@ const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
8180
}
8281
};
8382

84-
// Function to categorize batches
85-
const categorizeBatches = () => {
86-
const now = new Date();
87-
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
88-
89-
// Get start of "Today", "Past 7 days", and "Past 30 days" in LOCAL time
90-
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate());
91-
const past7DaysStart = new Date(todayStart);
92-
const past30DaysStart = new Date(todayStart);
93-
94-
past7DaysStart.setDate(todayStart.getDate() - 7);
95-
past30DaysStart.setDate(todayStart.getDate() - 30);
96-
97-
const todayBatches: BatchHistoryItem[] = [];
98-
const past7DaysBatches: BatchHistoryItem[] = [];
99-
const past30DaysBatches: BatchHistoryItem[] = [];
100-
101-
batchHistory.forEach(batch => {
102-
// Convert UTC timestamp to user's local date
103-
const updatedAtUTC = new Date(batch.created_at);
104-
const updatedAtLocal = new Date(updatedAtUTC.toLocaleString("en-US", { timeZone: userTimeZone }));
105-
106-
// Extract only the local **date** part for comparison
107-
const updatedDate = new Date(updatedAtLocal.getFullYear(), updatedAtLocal.getMonth(), updatedAtLocal.getDate());
108-
109-
// Categorize based on **exact day comparison**
110-
if (updatedDate.getTime() === todayStart.getTime()) {
111-
todayBatches.push(batch);
112-
} else if (updatedDate.getTime() >= past7DaysStart.getTime()) {
113-
past7DaysBatches.push(batch);
114-
} else if (updatedDate.getTime() >= past30DaysStart.getTime()) {
115-
past30DaysBatches.push(batch);
116-
}
117-
});
118-
119-
return { todayBatches, past7DaysBatches, past30DaysBatches };
120-
};
121-
122-
// const { todayBatches, past7DaysBatches, past30DaysBatches } = categorizeBatches();
123-
12483
const deleteBatchFromHistory = (batchId: string) => {
12584
// Get the current URL path
12685
const currentPath = window.location.pathname;

src/frontend/src/components/bottomBar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Button, Card, Dropdown, DropdownProps, Option } from "@fluentui/react-components"
2-
import React, { useState } from "react"
3-
import { useNavigate } from "react-router-dom"
2+
import React from "react"
43

54
// Define possible upload states
65
const UploadState = {

src/frontend/src/components/uploadButton.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const FileUploadZone: React.FC<FileUploadZoneProps> = ({
6868
const [uploadIntervals, setUploadIntervals] = useState<{ [key: string]: ReturnType<typeof setTimeout> }>({});
6969
const [showCancelDialog, setShowCancelDialog] = useState(false);
7070
const [showLogoCancelDialog, setShowLogoCancelDialog] = useState(false);
71-
const [uploadState, setUploadState] = useState<'IDLE' | 'UPLOADING' | 'COMPLETED'>('IDLE');
7271
const [batchId, setBatchId] = useState<string>(uuidv4());
7372
const [allUploadsComplete, setAllUploadsComplete] = useState(false);
7473
const [fileLimitExceeded, setFileLimitExceeded] = useState(false);
@@ -98,7 +97,6 @@ const FileUploadZone: React.FC<FileUploadZoneProps> = ({
9897
}
9998
}
10099

101-
setUploadState(newState);
102100
onUploadStateChange?.(newState);
103101
}, [uploadingFiles, onUploadStateChange]);
104102

@@ -280,7 +278,6 @@ const FileUploadZone: React.FC<FileUploadZoneProps> = ({
280278
Object.values(uploadIntervals).forEach(interval => clearInterval(interval));
281279
setUploadIntervals({});
282280
setUploadingFiles([]);
283-
setUploadState('IDLE');
284281
onUploadStateChange?.('IDLE');
285282
setShowCancelDialog(false);
286283
setShowLogoCancelDialog(false);

src/frontend/src/main.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const Main = () => {
5050
const baseURL = config.API_URL.replace(/\/api$/, ''); // Remove '/api' if it appears at the end
5151
console.log('Checking connection to:', baseURL);
5252
try {
53-
const response = await fetch(`${baseURL}/health`);
53+
await fetch(`${baseURL}/health`);
5454
} catch (error) {
5555
console.error('Error connecting to backend:', error);
5656
}

0 commit comments

Comments
 (0)