Skip to content

Latest commit

 

History

History
125 lines (101 loc) · 5.26 KB

File metadata and controls

125 lines (101 loc) · 5.26 KB

Current Task: Creators Feature Implementation

Task Overview

Implemented a comprehensive Creators feature for FToolbox to track and analyze Fansly creator statistics, similar to the existing Tags feature.

Completed Work

Backend Implementation

1. Database Models

  • Created Creator model (backend-go/models/creator.go):

    • Stores creator data: ID, username, display name, media likes, post likes, followers, image/video counts
    • Includes deletion tracking and timestamps
  • Created CreatorHistory model (backend-go/models/creator_history.go):

    • Tracks historical snapshots of creator statistics
    • Records changes for media likes, post likes, and followers
    • Enables trend analysis and change visualization

2. Database Migration

  • Updated backend-go/database/migrate.go to include Creator and CreatorHistory models in auto-migration

3. Fansly API Client Refactoring

  • Consolidated multiple calls to contentdiscovery/media/suggestionsnew endpoint
  • Created unified GetSuggestionsData method that returns posts, creators, and suggestions
  • Added FanslyAccount type to represent creator data from API
  • Removed duplicate code and improved API efficiency

4. API Handler

  • Created CreatorHandler (backend-go/handlers/creator_handler.go):
    • GET /api/creators endpoint with:
      • Pagination support (page, limit)
      • Search functionality (by username or display name)
      • Sorting options (followers, mediaLikes, postLikes, updatedAt, change)
      • History inclusion with date range filtering
      • Change calculation from historical data

5. Routes

  • Updated backend-go/routes/routes.go to register the creators endpoint

6. Background Workers

  • Extended tag_discovery.go:

    • Added discoverCreators function to discover new creators during tag discovery
    • Fetches creators from top 5 tags by view count
    • Efficiently reuses API calls already being made for tag discovery
  • Extended tag_updater.go:

    • Added updateCreators function to update creator statistics
    • Updates creators on 24-hour cycle (same as tags)
    • Fetches up to 20 creators per run that need updating
    • Creates history entries with calculated changes
    • Handles deletion detection when creators disappear from API

Frontend Implementation

1. Creators Page

  • Created frontend/src/routes/creators/+page.ts - Page load function with:

    • URL parameter handling for pagination, search, sorting
    • History date range support
    • Error handling and default values
  • Created frontend/src/routes/creators/+page.svelte - Main creators page with:

    • Search functionality
    • Date range picker for history filtering
    • Sortable table columns
    • Expandable rows for history visualization
    • Change indicators with trend icons
    • Pagination controls
    • Responsive design

2. Creator History Component

  • Created frontend/src/lib/components/CreatorHistory.svelte:
    • Multi-series line chart for visualizing creator metrics over time
    • Toggle between viewing all metrics or individual metrics
    • Chart.js integration with proper date handling
    • Data table showing historical values and changes
    • Color-coded metrics (followers: blue, media likes: green, post likes: orange)

3. Navigation

  • Updated frontend/src/lib/components/AppSidebar.svelte:
    • Added Creators menu item with Users icon
    • Maintains active state highlighting

4. Shared Utilities

  • Updated frontend/src/lib/utils.ts with:
    • formatNumber() - Consistent number formatting
    • formatDate() - Date formatting with Unix timestamp support
    • calculateChange() - Calculate change and percentage from history data

Technical Decisions

  1. Reused Existing Patterns: Followed the same architecture as Tags feature for consistency
  2. Extended Workers: Rather than creating new workers, extended existing ones to minimize resource usage
  3. Unified API Calls: Consolidated Fansly API calls to reduce duplication and improve efficiency
  4. 24-Hour Update Cycle: Matches the tag update frequency to maintain consistency
  5. Batch Processing: Limited to 20 creators per update cycle to manage API rate limits

Code Quality

  • All Go code formatted with go fmt
  • All Go code validated with go vet
  • All TypeScript/Svelte code formatted with Prettier
  • All TypeScript/Svelte code validated with ESLint and svelte-check
  • No compilation or linting errors

Recent Updates

Creator Updater Worker Refactoring

  • Created dedicated creator_updater.go file with CreatorUpdaterWorker struct
  • Implemented ProcessCreators function that:
    • Creates new creators with initial history entry
    • Updates existing creators if last check was more than 24 hours ago
    • Handles both creation and updates in a single method
    • Uses database transactions for data consistency
    • Properly tracks changes between updates
  • Removed creator-related code from tag_updater.go
  • Updated tag_discovery.go to use the new CreatorUpdaterWorker

Bug Fixes

  • Fixed tag_handler.go to properly handle the new TagResponseData structure returned by GetTagWithContext

Next Steps (if needed)

  • Add creator request functionality (similar to tag requests)
  • Implement creator search/discovery by username
  • Add export functionality for creator data
  • Consider adding more detailed analytics views