wiki:RegularUserLikesStory

Version 1 (modified by 211099, 2 weeks ago) ( diff )

--

Regular User Likes a Story

Authors: 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, created_at)
VALUES (4, 1, CURRENT_TIMESTAMP);

6. The system creates a notification for the writer.

INSERT INTO NOTIFICATION (content, is_read, created_at)
VALUES ('Sara liked your story "The Chronicles of Eldoria"', FALSE, CURRENT_TIMESTAMP);

7. The system creates a notification for the writer.

INSERT INTO CONTENT_TYPE (notification_id, content_type)
VALUES (1, 'like');

8. The system creates a notification for the writer.

INSERT INTO NOTIFY (user_id, story_id, notification_id)
VALUES (2, 1, 1);

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

Note: See TracWiki for help on using the wiki.