mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
add sorting of creators too
This commit is contained in:
@@ -192,6 +192,8 @@ async def get_store_creators(
|
||||
description=creator.description,
|
||||
avatar_url=creator.avatar_url,
|
||||
num_agents=creator.num_agents,
|
||||
agent_rating=creator.agent_rating,
|
||||
agent_runs=creator.agent_runs,
|
||||
)
|
||||
for creator in creators
|
||||
]
|
||||
|
||||
@@ -71,6 +71,8 @@ class Creator(pydantic.BaseModel):
|
||||
description: str
|
||||
avatar_url: str
|
||||
num_agents: int
|
||||
agent_rating: float
|
||||
agent_runs: int
|
||||
|
||||
|
||||
class CreatorsResponse(pydantic.BaseModel):
|
||||
|
||||
@@ -83,13 +83,13 @@ function SearchResults({
|
||||
};
|
||||
|
||||
const handleSortChange = (sortValue: string) => {
|
||||
|
||||
let sortBy = "recent";
|
||||
if (sortValue === "runs") {
|
||||
sortBy = "runs";
|
||||
} else if (sortValue === "rating") {
|
||||
sortBy = "rating";
|
||||
sortBy = "rating";
|
||||
}
|
||||
|
||||
const sortedAgents = [...agents].sort((a, b) => {
|
||||
if (sortBy === "runs") {
|
||||
return b.runs - a.runs;
|
||||
@@ -99,7 +99,20 @@ function SearchResults({
|
||||
return new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime();
|
||||
}
|
||||
});
|
||||
|
||||
const sortedCreators = [...creators].sort((a, b) => {
|
||||
if (sortBy === "runs") {
|
||||
return b.agent_runs - a.agent_runs;
|
||||
} else if (sortBy === "rating") {
|
||||
return b.agent_rating - a.agent_rating;
|
||||
} else {
|
||||
// Creators don't have updated_at, sort by number of agents as fallback
|
||||
return b.num_agents - a.num_agents;
|
||||
}
|
||||
});
|
||||
|
||||
setAgents(sortedAgents);
|
||||
setCreators(sortedCreators);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -393,6 +393,8 @@ export type Creator = {
|
||||
description: string;
|
||||
avatar_url: string;
|
||||
num_agents: number;
|
||||
agent_rating: number;
|
||||
agent_runs: number;
|
||||
};
|
||||
|
||||
export type CreatorsResponse = {
|
||||
|
||||
Reference in New Issue
Block a user