Changes between Initial Version and Version 1 of RegularUserLikesStory


Ignore:
Timestamp:
03/05/26 14:57:33 (2 weeks ago)
Author:
211099
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RegularUserLikesStory

    v1 v1  
     1==  Regular User Likes a Story
     2
     3=== Authors: **Regular User**
     4A regular user likes a published story on the platform, and the writer receives a notification about it.
     5
     6**1.** The regular user browses the platform and opens a published story.
     7
     8**2.** The system displays the story details along with the current like count.
     9{{{#!sql
     10SELECT s.story_id, s.short_description, COUNT(l.user_id) AS total_likes
     11FROM STORY s
     12LEFT JOIN LIKES l ON s.story_id = l.story_id
     13WHERE s.story_id = 1
     14GROUP BY s.story_id;
     15}}}
     16
     17**3.** The user clicks the "Like" button on the story.
     18
     19**4.** The system checks if the user has already liked the story to prevent duplicates.
     20{{{#!sql
     21SELECT * FROM LIKES
     22WHERE user_id = 4 AND story_id = 1;
     23}}}
     24
     25**5.**  The system inserts a new like record.
     26{{{#!sql
     27INSERT INTO LIKES (user_id, story_id, created_at)
     28VALUES (4, 1, CURRENT_TIMESTAMP);
     29}}}
     30
     31**6.** The system creates a notification for the writer.
     32{{{#!sql
     33INSERT INTO NOTIFICATION (content, is_read, created_at)
     34VALUES ('Sara liked your story "The Chronicles of Eldoria"', FALSE, CURRENT_TIMESTAMP);
     35}}}
     36
     37**7.** The system creates a notification for the writer.
     38{{{#!sql
     39INSERT INTO CONTENT_TYPE (notification_id, content_type)
     40VALUES (1, 'like');
     41}}}
     42
     43**8.** The system creates a notification for the writer.
     44{{{#!sql
     45INSERT INTO NOTIFY (user_id, story_id, notification_id)
     46VALUES (2, 1, 1);
     47}}}
     48
     49**9.** The system updates the like count displayed on the story page.