Fix publish flow and consolidate My Tools view
- Make publish endpoint idempotent: return success if same content already exists instead of VERSION_EXISTS error (fixes retry issues) - Always refresh tools page after publish dialog closes - Consolidate My Tools page to group versions by tool name - Show version count and list instead of separate rows per version - Sum downloads across all versions for accurate totals Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
@@ -602,7 +602,32 @@ def dashboard_tools():
|
||||
token = session.get("auth_token")
|
||||
user = _load_current_publisher() or session.get("user", {})
|
||||
status, payload = _api_get("/api/v1/me/tools", token=token)
|
||||
tools = payload.get("data", []) if status == 200 else []
|
||||
all_tools = payload.get("data", []) if status == 200 else []
|
||||
|
||||
# Consolidate multiple versions into single tool entries
|
||||
# Group by tool name, keep latest version as main, collect all versions
|
||||
tools_by_name = {}
|
||||
for tool in all_tools:
|
||||
name = tool.get("name")
|
||||
if name not in tools_by_name:
|
||||
tools_by_name[name] = {
|
||||
**tool,
|
||||
"versions": [tool.get("version")],
|
||||
"all_downloads": tool.get("downloads", 0),
|
||||
}
|
||||
else:
|
||||
# Add this version to the list
|
||||
tools_by_name[name]["versions"].append(tool.get("version"))
|
||||
tools_by_name[name]["all_downloads"] += tool.get("downloads", 0)
|
||||
# Keep the latest version's data (assuming sorted by published_at desc)
|
||||
# The first one we saw is the latest, so no need to update
|
||||
|
||||
# Convert back to list and sort versions for display
|
||||
tools = list(tools_by_name.values())
|
||||
for tool in tools:
|
||||
tool["versions"].sort(key=lambda v: [int(x) for x in v.split(".")], reverse=True)
|
||||
tool["version_count"] = len(tool["versions"])
|
||||
tool["downloads"] = tool["all_downloads"] # Use total across all versions
|
||||
|
||||
# Load rating/issue data for each tool
|
||||
for tool in tools:
|
||||
|
||||
@@ -69,7 +69,14 @@
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="text-sm text-gray-900">v{{ tool.version }}</span>
|
||||
{% if tool.version_count and tool.version_count > 1 %}
|
||||
<span class="ml-1 text-xs text-gray-500">(+{{ tool.version_count - 1 }} more)</span>
|
||||
<div class="text-xs text-gray-400 mt-1">
|
||||
{{ tool.versions[:3]|join(', ') }}{% if tool.version_count > 3 %}...{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-xs text-gray-500">{{ tool.published_at|timeago }}</p>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||
{{ tool.downloads|format_number }}
|
||||
|
||||
Reference in New Issue
Block a user