package de.assecutor.votianlt.repository;

import de.assecutor.votianlt.model.Comment;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommentRepository extends MongoRepository<Comment, ObjectId> {

    /**
     * Find all comments for a specific task, ordered by creation time descending
     * (newest first)
     */
    List<Comment> findByTaskIdOrderByCreatedAtDesc(ObjectId taskId);

    /**
     * Find all comments for a specific task, ordered by creation time ascending
     * (oldest first)
     */
    List<Comment> findByTaskIdOrderByCreatedAtAsc(ObjectId taskId);

    /**
     * Find comments by who completed them
     */
    List<Comment> findByCompletedByOrderByCreatedAtDesc(String completedBy);

    /**
     * Count comments for a specific task
     */
    long countByTaskId(ObjectId taskId);

    /**
     * Delete all comments for a specific task
     */
    void deleteByTaskId(ObjectId taskId);
}