wiki:RegularUserLikesStory

Version 3 (modified by 211099, 13 days ago) ( diff )

--

Regular User Likes a Story

Actor: Regular User

A regular user likes a published story on the platform, and the writer receives a notification about it.

1. The regular user browses the platform and opens a published story.

2. The system displays the story details along with the current like count.

SELECT s.story_id, s.short_description, COUNT(l.user_id) AS total_likes
FROM STORY s
LEFT JOIN LIKES l ON s.story_id = l.story_id
WHERE s.story_id = 1
GROUP BY s.story_id;

3. The user clicks the "Like" button on the story.

4. The system checks if the user has already liked the story to prevent duplicates.

SELECT * FROM LIKES
WHERE user_id = 4 AND story_id = 1;

5. The system inserts a new like record.

INSERT INTO LIKES (user_id, story_id, liked_at)
VALUES (4, 1, CURRENT_TIMESTAMP);

6. The system creates a notification for the writer.

INSERT INTO NOTIFICATION (notification_content, content_type, is_read, user_id, story_id, notification_created_at)
VALUES ('Sara liked your story "The Chronicles of Eldoria"', 'like', FALSE, 2, 1, CURRENT_TIMESTAMP);

7. The system updates the like count displayed on the story page.

Note: See TracWiki for help on using the wiki.