Skip to content

fix: Merging dev fixes into main #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
10 changes: 7 additions & 3 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ jobs:
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Determine Tag Name Based on Branch
id: determine_tag
run: echo "tagname=${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref || 'default' }}" >> $GITHUB_OUTPUT

- name: Build Docker Image and optionally push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ inputs.dockerfile }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || 'latest' }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}
tags: |
${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || 'latest' }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
48 changes: 48 additions & 0 deletions .github/workflows/test_research_assistant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Unit Tests - Research Assistant

on:
push:
branches: [main, dev]
paths:
- 'ResearchAssistant/**'
pull_request:
branches: [main, dev]
types:
- opened
- ready_for_review
- reopened
- synchronize
paths:
- 'ResearchAssistant/**'

jobs:
test_research_assistant:
name: Research Assistant Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Backend Dependencies
run: |
cd ResearchAssistant/App
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install coverage pytest pytest-cov pytest-asyncio

- name: Run Backend Tests with Coverage
run: |
cd ResearchAssistant/App
python -m pytest -vv --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing --cov-fail-under=80 --junitxml=coverage-junit.xml
- uses: actions/upload-artifact@v4
with:
name: research-assistant-coverage
path: |
ResearchAssistant/App/coverage.xml
ResearchAssistant/App/coverage-junit.xml
ResearchAssistant/App/htmlcov/
80 changes: 58 additions & 22 deletions ClientAdvisor/App/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,35 +1588,72 @@ def get_users():
if len(rows) <= 6:
# update ClientMeetings,Assets,Retirement tables sample data to current date
cursor = conn.cursor()
cursor.execute(
"""select DATEDIFF(d,CAST(max(StartTime) AS Date),CAST(GETDATE() AS Date)) + 3 as ndays from ClientMeetings"""
)
rows = cursor.fetchall()
ndays = 0
for row in rows:
ndays = row["ndays"]
sql_stmt1 = f"UPDATE ClientMeetings SET StartTime = dateadd(day,{ndays},StartTime), EndTime = dateadd(day,{ndays},EndTime)"
cursor.execute(sql_stmt1)
conn.commit()
nmonths = int(ndays / 30)
if nmonths > 0:
sql_stmt1 = (
f"UPDATE Assets SET AssetDate = dateadd(MONTH,{nmonths},AssetDate)"
combined_stmt = """
WITH MaxDates AS (
SELECT
MAX(CAST(StartTime AS Date)) AS MaxClientMeetingDate,
MAX(AssetDate) AS MaxAssetDate,
MAX(StatusDate) AS MaxStatusDate
FROM
(SELECT StartTime, NULL AS AssetDate, NULL AS StatusDate FROM ClientMeetings
UNION ALL
SELECT NULL AS StartTime, AssetDate, NULL AS StatusDate FROM Assets
UNION ALL
SELECT NULL AS StartTime, NULL AS AssetDate, StatusDate FROM Retirement) AS Combined
),
Today AS (
SELECT GETDATE() AS TodayDate
),
DaysDifference AS (
SELECT
DATEDIFF(DAY, MaxClientMeetingDate, TodayDate) + 3 AS ClientMeetingDaysDifference,
DATEDIFF(DAY, MaxAssetDate, TodayDate) - 30 AS AssetDaysDifference,
DATEDIFF(DAY, MaxStatusDate, TodayDate) - 30 AS StatusDaysDifference
FROM MaxDates, Today
)
cursor.execute(sql_stmt1)
SELECT
ClientMeetingDaysDifference,
AssetDaysDifference / 30 AS AssetMonthsDifference,
StatusDaysDifference / 30 AS StatusMonthsDifference
FROM DaysDifference
"""
cursor.execute(combined_stmt)
date_diff_rows = cursor.fetchall()

client_days = (
date_diff_rows[0]["ClientMeetingDaysDifference"]
if date_diff_rows
else 0
)
asset_months = (
int(date_diff_rows[0]["AssetMonthsDifference"]) if date_diff_rows else 0
)
status_months = (
int(date_diff_rows[0]["StatusMonthsDifference"])
if date_diff_rows
else 0
)

# Update ClientMeetings
if client_days > 0:
client_update_stmt = f"UPDATE ClientMeetings SET StartTime = DATEADD(day, {client_days}, StartTime), EndTime = DATEADD(day, {client_days}, EndTime)"
cursor.execute(client_update_stmt)
conn.commit()

sql_stmt1 = f"UPDATE Retirement SET StatusDate = dateadd(MONTH,{nmonths},StatusDate)"
cursor.execute(sql_stmt1)
# Update Assets
if asset_months > 0:
asset_update_stmt = f"UPDATE Assets SET AssetDate = DATEADD(month, {asset_months}, AssetDate)"
cursor.execute(asset_update_stmt)
conn.commit()

cursor = conn.cursor()
cursor.execute(sql_stmt)
rows = cursor.fetchall()
# Update Retirement
if status_months > 0:
retire_update_stmt = f"UPDATE Retirement SET StatusDate = DATEADD(month, {status_months}, StatusDate)"
cursor.execute(retire_update_stmt)
conn.commit()

users = []
for row in rows:
# print(row)
user = {
"ClientId": row["ClientId"],
"ClientName": row["Client"],
Expand All @@ -1631,7 +1668,6 @@ def get_users():
"ClientSummary": row["ClientSummary"],
}
users.append(user)
# print(users)

return jsonify(users)

Expand Down
54 changes: 35 additions & 19 deletions ClientAdvisor/App/frontend/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,31 +201,47 @@ export const selectUser = async (options: ClientIdRequest): Promise<Response> =>
return new Response(null, { status: 500, statusText: 'Internal Server Error' });
}
};

function isLastObjectNotEmpty(arr:any)
{
if (arr.length === 0) return false;
// Handle empty array case
const lastObj = arr[arr.length - 1];
return Object.keys(lastObj).length > 0;
}
export const historyUpdate = async (messages: ChatMessage[], convId: string): Promise<Response> => {
const response = await fetch('/history/update', {
method: 'POST',
body: JSON.stringify({
conversation_id: convId,
messages: messages
}),
headers: {
'Content-Type': 'application/json'
}
})
.then(async res => {
return res
if(isLastObjectNotEmpty(messages)){
const response = await fetch('/history/update', {
method: 'POST',
body: JSON.stringify({
conversation_id: convId,
messages: messages
}),
headers: {
'Content-Type': 'application/json'
}
})
.catch(_err => {
console.error('There was an issue fetching your data.')
.then(async res => {
return res
})
.catch(_err => {
console.error('There was an issue fetching your data.')
const errRes: Response = {
...new Response(),
ok: false,
status: 500
}
return errRes
})
return response
}
else{
const errRes: Response = {
...new Response(),
ok: false,
status: 500
}
return errRes
})
return response
return errRes
}
}

export const historyDelete = async (convId: string): Promise<Response> => {
Expand Down Expand Up @@ -425,4 +441,4 @@ export const historyMessageFeedback = async (messageId: string, feedback: string

// const data = await response.text();
// console.log('Response:', data);
// };
// };
4 changes: 4 additions & 0 deletions ClientAdvisor/App/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ async def test_get_users_success(client):
{
"ClientId": 1,
"ndays": 10,
"ClientMeetingDaysDifference": 1,
"AssetMonthsDifference": 1,
"StatusMonthsDifference": 1,
"DaysDifference": 1,
"Client": "Client A",
"Email": "clienta@example.com",
"AssetValue": "1,000,000",
Expand Down
Loading