Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MVarshini committed Dec 9, 2024
1 parent 69e6bdc commit a089841
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 47 deletions.
2 changes: 1 addition & 1 deletion backend/app/api/v1/commons/hce.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ async def getData(
jobs[["group"]] = jobs[["group"]].fillna(0)
jobs.fillna("", inplace=True)
if len(jobs) == 0:
return jobs
return {"data": jobs, "total": 0}
return {"data": jobs, "total": response["total"]}
2 changes: 1 addition & 1 deletion backend/app/api/v1/commons/ocm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def getData(
tasks = [item["_source"] for item in response["data"]]
jobs = pd.json_normalize(tasks)
if len(jobs) == 0:
return jobs
return {"data":jobs,"total": 0}

if "buildUrl" not in jobs.columns:
jobs.insert(len(jobs.columns), "buildUrl", "")
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/v1/commons/ocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def getData(
tasks = [item["_source"] for item in response["data"]]
jobs = pd.json_normalize(tasks)
if len(jobs) == 0:
return jobs
return {"data": jbs, "total": 0}
jobs[
["masterNodesCount", "workerNodesCount", "infraNodesCount", "totalNodesCount"]
] = jobs[
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/v1/commons/quay.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def getData(
tasks = [item["_source"] for item in response["data"]]
jobs = pd.json_normalize(tasks)
if len(jobs) == 0:
return {"data": jobs, "total": response["total"]}
return {"data": jbs, "total": 0}

jobs[
["masterNodesCount", "workerNodesCount", "infraNodesCount", "totalNodesCount"]
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/v1/commons/telco.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ async def getData(

jobs = pd.json_normalize(mapped_list)
if len(jobs) == 0:
return jobs
return {'data':jobs, 'total': 0}

return {"data": jobs, "total": response["total"]}
9 changes: 4 additions & 5 deletions backend/app/api/v1/endpoints/cpt/cptJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ async def jobs(
description="End date for searching jobs, format: 'YYYY-MM-DD'",
examples=["2020-11-15"],
),
pretty: bool = Query(False, description="Output contet in pretty format."),
pretty: bool = Query(False, description="Output content in pretty format."),
size: int = Query(None, description="Number of jobs to fetch"),
offset: int = Query(None, description="Offset Number to fetch jobs from"),
totalJobs: int = Query(None, description="Offset Number to fetch jobs from"),
totalJobs: int = Query(None, description="Total number of jobs"),
):
if start_date is None:
start_date = datetime.utcnow().date()
Expand Down Expand Up @@ -87,12 +87,11 @@ async def jobs(
except Exception as e:
print(f"Error fetching data for product {product}: {e}")

num = 0 if totalJobs is None else int(totalJobs)
# on first hit, totalJobs is 0
if totalJobs == 0:
for product in total_dict:
total += int(total_dict[product])

totalJobs = max(total, num)
totalJobs = total
response = {
"startDate": start_date.__str__(),
"endDate": end_date.__str__(),
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/v1/endpoints/cpt/maps/hce.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


################################################################
# This will return a Dictionary with from HCE required by the CPT
# This will return a Dictionary from HCE required by the CPT
# endpoint, it contians totalJobs and a Dataframe with the following columns:
# "ciSystem"
# "uuid"
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/v1/endpoints/ocm/ocmJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def jobs(
description="End date for searching jobs, format: 'YYYY-MM-DD'",
examples=["2020-11-15"],
),
pretty: bool = Query(False, description="Output contet in pretty format."),
pretty: bool = Query(False, description="Output content in pretty format."),
size: int = Query(None, description="Number of jobs to fetch"),
offset: int = Query(None, description="Offset Number to fetch jobs from"),
):
Expand Down
4 changes: 2 additions & 2 deletions backend/app/api/v1/endpoints/ocp/ocpJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@router.get(
"/api/v1/ocp/jobs",
summary="Returns a job list",
description="Returns a list of jobs in the specified dates of requested size. \
description="Returns a list of jobs in the specified dates. \
If not dates are provided the API will default the values. \
`startDate`: will be set to the day of the request minus 5 days.\
`endDate`: will be set to the day of the request.",
Expand All @@ -32,7 +32,7 @@ async def jobs(
description="End date for searching jobs, format: 'YYYY-MM-DD'",
examples=["2020-11-15"],
),
pretty: bool = Query(False, description="Output contet in pretty format."),
pretty: bool = Query(False, description="Output content in pretty format."),
size: int = Query(None, description="Number of jobs to fetch"),
offset: int = Query(None, description="Offset Number to fetch jobs from"),
):
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/v1/endpoints/quay/quayJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def jobs(
description="End date for searching jobs, format: 'YYYY-MM-DD'",
examples=["2020-11-15"],
),
pretty: bool = Query(False, description="Output contet in pretty format."),
pretty: bool = Query(False, description="Output content in pretty format."),
size: int = Query(None, description="Number of jobs to fetch"),
offset: int = Query(None, description="Offset Number to fetch jobs from"),
):
Expand Down
31 changes: 0 additions & 31 deletions backend/app/services/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,34 +98,22 @@ async def post(
response = await self.prev_es.search(
index=self.prev_index + "*",
body=jsonable_encoder(query),
<<<<<<< HEAD
size=size,
)
previous_results = {
"data": response["hits"]["hits"],
"total": response["hits"]["total"]["value"],
}

=======
size=size)
previous_results = {"data":response['hits']['hits'], "total":response['hits']["total"]["value"]}
>>>>>>> 9385645 (pagination params)
else:
response = await self.prev_es.search(
index=self.prev_index + "*",
body=jsonable_encoder(query),
<<<<<<< HEAD
size=size,
)
previous_results = {
"data": response["hits"]["hits"],
"total": response["hits"]["total"]["value"],
}

=======
size=size)
previous_results = {"data":response['hits']['hits'], "total":response['hits']["total"]["value"]}
>>>>>>> 9385645 (pagination params)
# previous_results = await self.scan_indices(self.prev_es, self.prev_index, query, timestamp_field, start_date, new_end_date, size)
if self.prev_es and self.new_es:
self.new_index = self.new_index_prefix + (
Expand All @@ -152,32 +140,22 @@ async def post(
response = await self.new_es.search(
index=self.new_index + "*",
body=jsonable_encoder(query),
<<<<<<< HEAD
size=size,
)

new_results = {
"data": response["hits"]["hits"],
"total": response["hits"]["total"]["value"],
}

=======
size=size)
new_results = {"data":response['hits']['hits'],"total":response['hits']['total']['value']}
>>>>>>> 9385645 (pagination params)
else:
response = await self.new_es.search(
index=self.new_index + "*",
body=jsonable_encoder(query),
<<<<<<< HEAD
size=size,
)

new_results = {
"data": response["hits"]["hits"],
"total": response["hits"]["total"]["value"],
}

# new_results = await self.scan_indices(self.new_es, self.new_index, query, timestamp_field, new_start_date, end_date, size)
unique_data = await self.remove_duplicates(
previous_results["data"]
Expand All @@ -189,16 +167,7 @@ async def post(
if ("total" in previous_results)
else 0 + new_results["total"] if ("total" in new_results) else 0
)

return {"data": unique_data, "total": totalVal}
=======
size=size)
new_results = {"data":response['hits']['hits'],"total":response['hits']['total']['value']}
# new_results = await self.scan_indices(self.new_es, self.new_index, query, timestamp_field, new_start_date, end_date, size)
unique_data = await self.remove_duplicates(previous_results["data"] if("data" in previous_results) else [] + new_results["data"] if("data" in new_results) else[])
totalVal = previous_results["total"] if("total" in previous_results) else 0 + new_results["total"] if("total" in new_results) else 0
return ({"data":unique_data, "total": totalVal})
>>>>>>> 9385645 (pagination params)
else:
if start_date and end_date:
query["query"]["bool"]["filter"]["range"][timestamp_field][
Expand Down
1 change: 0 additions & 1 deletion frontend/src/actions/homeActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const fetchOCPJobsData =
payload: {
total: response.data.total,
offset: response.data.offset,
// currProd: response.data.currProd,
},
});

Expand Down

0 comments on commit a089841

Please sign in to comment.