diff options
| author | Bobby <[email protected]> | 2026-02-06 17:45:55 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-02-06 17:45:55 +0530 |
| commit | 2da45b9fbf74d365951e37a4152f30e76caaeb98 (patch) | |
| tree | 8fc9b5f02d37194c136e7f757f1e37c21825094c /utils | |
| parent | 8cb229a3bc07387067ca76a34c05b44ff7a3039a (diff) | |
| download | metachan-2da45b9fbf74d365951e37a4152f30e76caaeb98.tar.xz metachan-2da45b9fbf74d365951e37a4152f30e76caaeb98.zip | |
Refactor task management and producer synchronization
- Updated TaskManager to utilize repositories for database operations, improving separation of concerns.
- Enhanced logging functionality by replacing logger.Log with logger.Infof, logger.Warnf, and logger.Errorf for better readability and consistency.
- Simplified ProducerSync function by removing unnecessary pagination logic and directly fetching producer data.
- Introduced helper functions for calculating progress and managing task statuses.
- Added new service for fetching and saving anime data, integrating multiple data sources (Jikan, Anilist, MALsync, TMDB, TVDB, Aniskip).
- Created new types for task management and improved overall code organization.
- Removed deprecated database calls and replaced them with repository methods for better maintainability.
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/api/malsync/malsync.go | 2 | ||||
| -rw-r--r-- | utils/logger/logger.go | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/utils/api/malsync/malsync.go b/utils/api/malsync/malsync.go index 1ee479c..9509707 100644 --- a/utils/api/malsync/malsync.go +++ b/utils/api/malsync/malsync.go @@ -88,7 +88,6 @@ func (c *client) makeRequest(ctx context.Context, url string) ([]byte, error) { switch response.StatusCode { case http.StatusNotFound: - // Not found is not an error, return nil return nil, nil case http.StatusTooManyRequests: retryAfter := c.getRetryAfterDuration(response) @@ -131,7 +130,6 @@ func GetAnimeByMALID(malID int) (*types.MalsyncAnimeResponse, error) { return nil, errors.New("failed to fetch anime data from Malsync API") } - // Handle 404 case where makeRequest returns nil, nil if bytes == nil { return nil, nil } diff --git a/utils/logger/logger.go b/utils/logger/logger.go index 41e7f1e..f1c94e7 100644 --- a/utils/logger/logger.go +++ b/utils/logger/logger.go @@ -131,7 +131,7 @@ func log(levelLabel LogLevel, zapLevel zapcore.Level, prefix string, msg any) { message := fmt.Sprint(msg) colored := colorMessage(levelLabel, message) + fullMessage := formatPrefix(prefix) + colored - loggerInstance.Check(zapLevel, colored). - Write(zap.String("prefix", formatPrefix(prefix))) + loggerInstance.Log(zapLevel, fullMessage) } |
