WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Class ProgressRepository

    Data access layer for progress tracking operations.

    ProgressRepository

    Index

    Constructors

    Methods

    • Creates a new user progress record in the database.

      Parameters

      • data: CreateUserProgressDto

        User progress data to create

      Returns Promise<UserProgress>

      Promise resolving to the created progress record

      When user progress already exists (409 CONFLICT) or user not found (404 NOT_FOUND)

    • Retrieves user progress record by user ID.

      Parameters

      • userId: string

        The unique identifier of the user

      Returns Promise<null | UserProgress>

      Promise resolving to user progress or null if not found

      When database operation fails (500 INTERNAL_SERVER_ERROR)

    • Updates user progress record with specified changes.

      Automatically updates the last activity date and handles lesson relationship updates.

      Parameters

      • userId: string

        The unique identifier of the user

      • updates: UpdateUserProgressDto

        Object containing fields to update

      Returns Promise<UserProgress>

      Promise resolving to the updated progress record

      When user progress not found (404 NOT_FOUND) or database operation fails

    • Creates new user progress or updates existing record atomically (upsert operation).

      This method provides atomic create-or-update functionality, ensuring data consistency when the existence of user progress is uncertain.

      Parameters

      • data: CreateUserProgressDto

        User progress data for creation or update

      Returns Promise<UserProgress>

      Promise resolving to the created or updated progress record

      When user not found (404 NOT_FOUND) or database operation fails

    • Creates a new lesson completion record in the database.

      Parameters

      • data: CreateLessonCompletionDto

        Lesson completion data to create

      Returns Promise<LessonCompletion>

      Promise resolving to the created completion record

      When lesson already completed (409 CONFLICT), user/lesson not found (404 NOT_FOUND), or database operation fails

    • Retrieves a specific lesson completion record by user and lesson ID.

      Parameters

      • userId: string

        The unique identifier of the user

      • lessonId: string

        The unique identifier of the lesson

      Returns Promise<null | LessonCompletion>

      Promise resolving to completion record or null if not found

      When database operation fails (500 INTERNAL_SERVER_ERROR)

    • Retrieves paginated list of lesson completions for a specific user.

      Supports pagination, sorting, and filtering options for efficient data retrieval.

      Parameters

      • userId: string

        The unique identifier of the user

      • Optionaloptions: QueryOptions = {}

        Query options including pagination and sorting parameters

      Returns Promise<PaginatedResult<LessonCompletion>>

      Promise resolving to paginated completion results

      When database operation fails (500 INTERNAL_SERVER_ERROR)

    • Creates multiple lesson completion records atomically within a transaction.

      This method is optimized for offline synchronization scenarios, automatically skipping duplicate completions and ensuring data consistency through transaction handling.

      Parameters

      • completions: CreateLessonCompletionDto[]

        Array of lesson completion data to create

      Returns Promise<LessonCompletion[]>

      Promise resolving to array of successfully created completion records

      When database operation fails (500 INTERNAL_SERVER_ERROR)

    • Retrieves comprehensive progress summary with aggregated statistics.

      Calculates lessons completed, courses started, and other analytics data by performing complex queries across multiple related tables. Includes advanced analytics like longest streak, completion percentage, and average score.

      Parameters

      • userId: string

        The unique identifier of the user

      Returns Promise<null | ProgressSummary>

      Promise resolving to progress summary or null if user progress not found

      When database operation fails (500 INTERNAL_SERVER_ERROR)

    • Checks whether a specific lesson has been completed by the user.

      Parameters

      • userId: string

        The unique identifier of the user

      • lessonId: string

        The unique identifier of the lesson

      Returns Promise<boolean>

      Promise resolving to true if lesson is completed, false otherwise

      When database operation fails (500 INTERNAL_SERVER_ERROR)

    • Retrieves aggregated completion statistics for a specific lesson.

      Calculates total completions, average score, and average time spent using database aggregation functions.

      Parameters

      • lessonId: string

        The unique identifier of the lesson

      Returns Promise<
          {
              total_completions: number;
              average_score: null
              | number;
              average_time_spent: null | number;
          },
      >

      Promise resolving to lesson completion statistics

      When database operation fails (500 INTERNAL_SERVER_ERROR)