Skip to content

Commit

Permalink
Merge pull request swanchain#8 from swanchain/fix/overview-cplist-api
Browse files Browse the repository at this point in the history
fix overview cplist api
  • Loading branch information
alphaflows authored Jun 7, 2024
2 parents 0c9b995 + 8b5aed8 commit b945a99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions backend/router/computing_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_provider_dashboard_overview():
response = Response(constant.STATUS_FAILED)

try:
dashboard_overview_key = "dashboard-overview-v2"
dashboard_overview_key = "dashboard-overview-v2-"
if overview_res := redis_client.get(dashboard_overview_key):
response.data = json.loads(overview_res)
else:
Expand Down Expand Up @@ -88,7 +88,7 @@ def get_provider_dashboard_overview():
"active_applications": active_applications,
}
response.data.update(all_machines_info)
redis_client.set(dashboard_overview_key, json.dumps(response.data), ex=300)
redis_client.set(dashboard_overview_key, json.dumps(response.data), ex=60)

# t4 = time.time()
# logging.debug(f"t4, cost time: {t4-t3}")
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_provider_dashboard_cplist():
# providers_query = providers_query.offset(offset)


dashboard_cplist_key = "dashboard-cplist-all-v2"
dashboard_cplist_key = "dashboard-cplist-all-v2-"
if providers_res := redis_client.get(dashboard_cplist_key):
# do filter result by search_string
providers_all = json.loads(providers_res)
Expand Down
20 changes: 9 additions & 11 deletions backend/service/computing_provider_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import time
from decimal import Decimal, ROUND_DOWN
from sqlalchemy.sql import and_, not_
from sqlalchemy.sql import and_, not_, or_
from sqlalchemy import desc

import requests
Expand Down Expand Up @@ -203,8 +203,10 @@ def get_cp_alive_jobs(node_id):
# not_(Job.status.ilike(r'%Submitted%')),
# not_(Job.status.ilike(r'%claimed%')),
# not_(Job.status.ilike(r'%released%')),
Job.status.ilike(r'%Running%'),
Job.status.ilike(r'%deployToK8s%'),
or_(
Job.status.ilike(r'%Running%'),
Job.status.ilike(r'%deployToK8s%')
),
Job.job_result_uri.isnot(None)
).count()
return count
Expand All @@ -227,14 +229,10 @@ def get_active_cp_alive_jobs_count(search_string=None):
Job.node_id == CPAccount.node_id
).filter(
CPAccount.online==True,
# not_(Job.status.ilike(r'%Cancel%')),
# not_(Job.status.ilike(r'%Complete%')),
# not_(Job.status.ilike(r'%Failed%')),
# not_(Job.status.ilike(r'%Submitted%')),
# not_(Job.status.ilike(r'%claimed%')),
# not_(Job.status.ilike(r'%released%')),
Job.status.ilike(r'%Running%'),
Job.status.ilike(r'%deployToK8s%'),
or_(
Job.status.ilike(r'%Running%'),
Job.status.ilike(r'%deployToK8s%')
),
Job.job_result_uri.isnot(None)
)

Expand Down

0 comments on commit b945a99

Please sign in to comment.