-
Notifications
You must be signed in to change notification settings - Fork 2
feat(marketplace): add item metrics tracking and favorites system #39
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,11 @@ on: | |
| description: "Services to build (comma-separated: gateway,api,worker,portal,all)" | ||
| required: false | ||
| default: "all" | ||
| portal_branch: | ||
| description: "Branch for portal submodule" | ||
| required: false | ||
| default: "dev" | ||
| type: string | ||
| push: | ||
| description: "Push images to registry" | ||
| required: false | ||
|
|
@@ -93,11 +98,13 @@ jobs: | |
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Update portal submodule to dev branch | ||
| - name: Update portal submodule to target branch | ||
| run: | | ||
| BRANCH="${{ inputs.portal_branch || 'dev' }}" | ||
| cd portal | ||
| git fetch origin '+refs/heads/dev:refs/remotes/origin/dev' | ||
| git checkout -B dev origin/dev | ||
| git fetch origin "+refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH}" | ||
| git checkout -B "${BRANCH}" "origin/${BRANCH}" | ||
| echo "portal submodule branch: ${BRANCH}" | ||
|
Comment on lines
+101
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scope the portal submodule checkout to portal builds only. This step currently runs for every matrix service. Non-portal builds can fail due to portal branch issues even when Suggested fix - name: Update portal submodule to target branch
+ if: matrix.service == 'portal'
run: |
BRANCH="${{ inputs.portal_branch || 'dev' }}"
cd portal
git fetch origin "+refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH}"
git checkout -B "${BRANCH}" "origin/${BRANCH}"🤖 Prompt for AI Agents |
||
| echo "portal submodule commit: $(git rev-parse HEAD)" | ||
|
|
||
| - name: Set up QEMU | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| SWAG_VERSION := v1.16.6 | ||
| SWAG := go run github.com/swaggo/swag/cmd/swag@$(SWAG_VERSION) | ||
|
|
||
| .PHONY: run dev swagger-serve swagger swagger-check | ||
|
|
||
| run: | ||
| go run ./cmd/api | ||
|
|
||
| dev: swagger run | ||
|
|
||
| swagger-serve: swagger run | ||
|
|
||
| swagger: | ||
| $(SWAG) init -g cmd/api/main.go -o docs --parseDependency --parseInternal | ||
|
|
||
| swagger-check: | ||
| $(SWAG) fmt -d ./cmd/api,./internal |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,6 +191,7 @@ func main() { | |
| marketplace.GET("/items/new", recommendHandler.GetNewAndNoteworthy) | ||
| } | ||
| api.GET("/items/:id/similar", searchHandler.FindSimilar) | ||
| api.POST("/items/:id/behavior", recommendHandler.LogBehavior) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find the recommend handler file
fd -t f "recommend" server/ --type f | head -20Repository: XDfield/costrict-web Length of output: 147 🏁 Script executed: # Search for LogBehavior handler implementation
rg -t go "LogBehavior" server/ -A 20Repository: XDfield/costrict-web Length of output: 18071 🏁 Script executed: # Look at the main.go file around line 194 to understand middleware context
sed -n '180,210p' server/cmd/api/main.goRepository: XDfield/costrict-web Length of output: 1328 🏁 Script executed: # Search for behavior types and validation
rg -t go "behavior" server/internal/services/ -i -A 5 | head -50Repository: XDfield/costrict-web Length of output: 3844 🏁 Script executed: # Check ActionType definition and allowed values
rg -t go "ActionType" server/internal/models/ -A 3 | head -40Repository: XDfield/costrict-web Length of output: 1548 🏁 Script executed: # Search for install_count and preview_count updates mentioned in review
rg -t go "install_count|preview_count" server/ -B 3 -A 3Repository: XDfield/costrict-web Length of output: 7128 🏁 Script executed: # Check if there's rate-limiting middleware applied
rg -t go "rate|throttle|limit" server/cmd/api/main.go -iRepository: XDfield/costrict-web Length of output: 46 🏁 Script executed: # Look for any behavior logging logic related to counters
rg -t go "LogBehavior" server/internal/services/behavior_service.go -A 40Repository: XDfield/costrict-web Length of output: 2094 🏁 Script executed: # Check the full middleware setup for the public api group
sed -n '150,200p' server/cmd/api/main.goRepository: XDfield/costrict-web Length of output: 2273 🏁 Script executed: # Verify there's no validation of ActionType values anywhere
rg -t go "ActionType" server/internal/handlers/recommend.go -B 5 -A 10Repository: XDfield/costrict-web Length of output: 1197 Do not expose a generic behavior endpoint as public without per-action validation and rate-limiting. This endpoint accepts any arbitrary 🤖 Prompt for AI Agents |
||
| api.GET("/items/:id/stats", recommendHandler.GetItemStats) | ||
|
|
||
| // All routes below require authentication | ||
|
|
@@ -247,7 +248,8 @@ func main() { | |
| authed.PUT("/items/:id/transfer", handlers.TransferItemToRepo) | ||
| authed.POST("/items/:id/scan", handlers.TriggerItemScan) | ||
| authed.POST("/scan-jobs/:id/cancel", handlers.CancelScanJob) | ||
| authed.POST("/items/:id/behavior", recommendHandler.LogBehavior) | ||
| authed.POST("/items/:id/favorite", recommendHandler.FavoriteItem) | ||
| authed.DELETE("/items/:id/favorite", recommendHandler.UnfavoriteItem) | ||
|
|
||
| authed.POST("/artifacts/upload", handlers.UploadArtifact) | ||
| authed.DELETE("/artifacts/:id", handlers.DeleteArtifact) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,8 @@ func main() { | |
| &models.CapabilityVersion{}, | ||
| &models.CapabilityAsset{}, | ||
| &models.CapabilityArtifact{}, | ||
| &models.BehaviorLog{}, | ||
| &models.ItemFavorite{}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Don’t let This PR already introduces the favorites schema via goose, but 🤖 Prompt for AI Agents |
||
| &models.SecurityScan{}, | ||
| &models.ScanJob{}, | ||
| &models.Device{}, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate
portal_branchbefore using it in git commands.workflow_dispatchinput is user-provided. Without validation, malformed values can break the run and increase command-safety risk.Suggested hardening
run: | BRANCH="${{ inputs.portal_branch || 'dev' }}" + if ! git check-ref-format --branch "$BRANCH" >/dev/null 2>&1; then + echo "Invalid portal_branch: $BRANCH" >&2 + exit 1 + fi cd portal git fetch origin "+refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH}" git checkout -B "${BRANCH}" "origin/${BRANCH}"📝 Committable suggestion
🤖 Prompt for AI Agents