-
Notifications
You must be signed in to change notification settings - Fork 0
RSS 기반 포스팅 업데이트 및 스케쥴러 구현 #20
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
Open
pilyang
wants to merge
7
commits into
main
Choose a base branch
from
feat/rss-fetch-postings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
25947b5
fix: database connection string and add PostingTags helper function
pilyang 1bee54a
feat: add RSS feed fetching and posting creation functionality
pilyang abbf5cb
feat: add scheduler for periodic RSS feed syncing
pilyang c02e86f
feat: integrate RSS fetching functionality into main application
pilyang 4448532
chore: add dependencies for RSS parsing and scheduling
pilyang 061faba
docs: update CLAUDE.md with testing guidance and architecture info
pilyang 0a0507a
fix: update database field reference in test utils
pilyang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# CLAUDE.md | ||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
||
## Commands | ||
- **Build**: `go build -o techbloghub-server ./cmd/main.go` | ||
- **Run Tests**: `go test ./...` | ||
- **Single Test**: `go test -v ./path/to/package -run TestName` | ||
- **Start Dev DB**: `./script/dev-db.sh` | ||
- **Start Test DB**: `./script/test-db.sh` | ||
- **Create Migration**: `./script/create_migration.sh migration_name` | ||
- **Stop Test Containers**: `docker stop test-tbh-postgres` | ||
|
||
## Code Style | ||
- **Imports**: Standard library first, third-party next, internal packages last | ||
- **Error Handling**: Always check errors with `if err != nil`, return errors up the call stack | ||
- **Naming**: camelCase for private, PascalCase for exported; lowercase package names | ||
- **Testing**: Use testify for assertions, TransactionalTest for DB tests | ||
- **Structure**: HTTP handlers in internal/http/handler/, DB operations with EntGo ORM | ||
- **Comments**: Document public functions, Korean comments acceptable | ||
- **Formatting**: Always run `go fmt ./...` before committing | ||
|
||
## Architecture | ||
- HTTP routing via Gin framework | ||
- Database access via EntGo ORM | ||
- Soft delete via SoftDeleteMixin | ||
- Pagination support via TechbloghubPaging | ||
- RSS feed processing with gofeed parser | ||
|
||
## Testing | ||
1. **Database Test Setup**: | ||
- Start test database: `./script/test-db.sh` | ||
- Clean up after tests: `docker stop test-tbh-postgres` | ||
|
||
2. **Running Tests**: | ||
- Run specific package tests: `go test -v ./internal/package/...` | ||
- Run all tests: `go test ./...` | ||
|
||
3. **Test Structure**: | ||
- Use `testutils.TransactionalTest` for database tests | ||
- Create test data using the EntGo client | ||
- When testing entities, always include all required fields | ||
- Remember to set all required fields when creating test data (e.g., Company requires name, logo_url, blog_url) | ||
|
||
4. **Test Assertions**: | ||
- Use `assert.NoError()` to check for successful operations | ||
- Use `assert.Error()` to verify expected errors | ||
- Use `assert.Equal()` to compare expected vs. actual values | ||
- Use `assert.Contains()` to check error message contents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package handler | ||
|
||
import ( | ||
"net/http" | ||
"strconv" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/techbloghub/server/ent" | ||
"github.com/techbloghub/server/internal/rss" | ||
) | ||
|
||
type RssSyncResponse struct { | ||
Status string `json:"status"` | ||
Count int `json:"count"` | ||
CompanyID int `json:"company_id,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
} | ||
|
||
// SyncCompanyRSSFeed syncs postings from a specific company's RSS feed | ||
func SyncCompanyRSSFeed(client *ent.Client) gin.HandlerFunc { | ||
return func(c *gin.Context) { | ||
companyID, err := strconv.Atoi(c.Param("company_id")) | ||
if err != nil { | ||
c.JSON(http.StatusBadRequest, RssSyncResponse{ | ||
Status: "error", | ||
Message: "Invalid company ID", | ||
}) | ||
return | ||
} | ||
|
||
count, err := rss.SyncCompanyRSSFeed(c.Request.Context(), client, companyID) | ||
if err != nil { | ||
c.JSON(http.StatusInternalServerError, RssSyncResponse{ | ||
Status: "error", | ||
CompanyID: companyID, | ||
Message: err.Error(), | ||
}) | ||
return | ||
} | ||
|
||
c.JSON(http.StatusOK, RssSyncResponse{ | ||
Status: "success", | ||
Count: count, | ||
CompanyID: companyID, | ||
Message: "RSS feed sync completed successfully", | ||
}) | ||
} | ||
} | ||
|
||
// SyncAllRSSFeeds syncs postings from all companies with RSS feeds | ||
func SyncAllRSSFeeds(client *ent.Client) gin.HandlerFunc { | ||
return func(c *gin.Context) { | ||
count, err := rss.SyncAllCompanyFeeds(c.Request.Context(), client) | ||
if err != nil { | ||
c.JSON(http.StatusInternalServerError, RssSyncResponse{ | ||
Status: "error", | ||
Message: err.Error(), | ||
}) | ||
return | ||
} | ||
|
||
c.JSON(http.StatusOK, RssSyncResponse{ | ||
Status: "success", | ||
Count: count, | ||
Message: "All RSS feeds synced successfully", | ||
}) | ||
} | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
상수화...?!