Updated community sentiment
This commit is contained in:
@@ -1,22 +1,108 @@
|
||||
-- Insert 20 dummy jokes with various sentiments
|
||||
INSERT INTO jokes (joke, contributor, created_date, approved, sentiment_score, sentiment_label) VALUES
|
||||
('Why don''t scientists trust atoms? Because they make up everything!', 'ScienceFan', '2024-01-15 10:30:00', 1, 0.75, '😊 Positive'),
|
||||
('I told my wife she was drawing her eyebrows too high. She looked surprised.', 'Joker123', '2024-01-16 14:20:00', 1, 0.35, '😊 Positive'),
|
||||
('Why did the scarecrow win an award? He was outstanding in his field!', 'FarmLife', '2024-01-17 09:15:00', 1, 0.65, '😊 Positive'),
|
||||
('What do you call a fish with no eyes? Fsh!', 'MarineBio', '2024-01-18 16:45:00', 1, 0.25, '😊 Positive'),
|
||||
('I''m reading a book on anti-gravity. It''s impossible to put down!', 'PhysicsNerd', '2024-01-19 11:30:00', 1, 0.45, '😊 Positive'),
|
||||
('Why did the computer go to the doctor? Because it had a virus.', 'TechSupport', '2024-01-20 13:10:00', 1, 0.05, '😐 Neutral'),
|
||||
('What do you call a bear with no teeth? A gummy bear.', 'WildlifeFan', '2024-01-21 15:25:00', 1, 0.08, '😐 Neutral'),
|
||||
('Why did the bicycle fall over? Because it was two-tired.', 'Cyclist', '2024-01-22 10:00:00', 1, -0.02, '😐 Neutral'),
|
||||
('What do you call a sleeping bull? A bulldozer.', 'Cowboy', '2024-01-23 14:35:00', 1, 0.03, '😐 Neutral'),
|
||||
('Why did the math book look so sad? Because it had too many problems.', 'Student', '2024-01-24 09:50:00', 1, -0.05, '😐 Neutral'),
|
||||
('I used to play piano by ear, but now I use my hands.', 'Musician', '2024-01-25 12:15:00', 1, -0.15, '😒 Negative'),
|
||||
('I told my computer I needed a break, and now it won''t stop sending me Kit-Kat ads.', 'OfficeWorker', '2024-01-26 16:30:00', 1, -0.25, '😒 Negative'),
|
||||
('Parallel lines have so much in common. It''s a shame they''ll never meet.', 'MathTeacher', '2024-01-27 11:40:00', 1, -0.35, '😒 Negative'),
|
||||
('My wife told me to stop impersonating a flamingo. I had to put my foot down.', 'Husband', '2024-01-28 14:55:00', 1, -0.20, '😒 Negative'),
|
||||
('I told my girlfriend she drew her eyebrows too high. She seemed surprised.', 'Boyfriend', '2024-01-29 10:10:00', 1, -0.30, '😒 Negative'),
|
||||
('What''s orange and sounds like a parrot? A carrot!', 'Vegetarian', '2024-01-30 13:20:00', 1, 0.85, '😊 Positive'),
|
||||
('Why don''t eggs tell jokes? They''d crack each other up!', 'Chef', '2024-01-31 15:45:00', 1, 0.90, '😊 Positive'),
|
||||
('I invented a new word: Plagiarism!', 'Writer', '2024-02-01 09:30:00', 1, 0.78, '😊 Positive'),
|
||||
('Why did the golfer bring two pairs of pants? In case he got a hole in one!', 'Golfer', '2024-02-02 12:15:00', 1, 0.82, '😊 Positive'),
|
||||
('What do you call a fake noodle? An impasta!', 'ItalianFood', '2024-02-03 14:40:00', 1, 0.88, '😊 Positive');
|
||||
-- Enhanced Joke Bot Database Schema with User Identification
|
||||
-- Version 4.0 - User Analytics Edition
|
||||
|
||||
-- Drop existing tables if they exist (clean slate)
|
||||
DROP TABLE IF EXISTS user_sentiments;
|
||||
DROP TABLE IF EXISTS jokes;
|
||||
|
||||
-- Create jokes table
|
||||
CREATE TABLE jokes (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
joke TEXT NOT NULL,
|
||||
contributor TEXT NOT NULL,
|
||||
created_date TEXT NOT NULL,
|
||||
approved BOOLEAN DEFAULT 0,
|
||||
sentiment_score REAL DEFAULT 0.0,
|
||||
sentiment_label TEXT DEFAULT '😐 Neutral'
|
||||
);
|
||||
|
||||
-- Create user_sentiments table with user identification
|
||||
CREATE TABLE user_sentiments (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
joke_id INTEGER NOT NULL,
|
||||
user_sentiment TEXT CHECK(user_sentiment IN ('up', 'down', 'neutral')) DEFAULT 'neutral',
|
||||
user_identifier TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (joke_id) REFERENCES jokes(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Insert sample jokes with approval status
|
||||
INSERT INTO jokes (joke, contributor, created_date, approved) VALUES
|
||||
('Why don''t scientists trust atoms? Because they make up everything!', 'ScienceFan', '2024-01-15 10:30:00', 1),
|
||||
('I told my wife she was drawing her eyebrows too high. She looked surprised.', 'Joker123', '2024-01-16 14:20:00', 1),
|
||||
('Why did the scarecrow win an award? He was outstanding in his field!', 'FarmLife', '2024-01-17 09:15:00', 1),
|
||||
('What do you call a fish with no eyes? Fsh!', 'MarineBio', '2024-01-18 16:45:00', 1),
|
||||
('I''m reading a book on anti-gravity. It''s impossible to put down!', 'PhysicsNerd', '2024-01-19 11:30:00', 1),
|
||||
('Why did the computer go to the doctor? Because it had a virus.', 'TechSupport', '2024-01-20 13:10:00', 1),
|
||||
('What do you call a bear with no teeth? A gummy bear.', 'WildlifeFan', '2024-01-21 15:25:00', 1),
|
||||
('Why did the bicycle fall over? Because it was two-tired.', 'Cyclist', '2024-01-22 10:00:00', 1),
|
||||
('What do you call a sleeping bull? A bulldozer.', 'Cowboy', '2024-01-23 14:35:00', 1),
|
||||
('Why did the math book look so sad? Because it had too many problems.', 'Student', '2024-01-24 09:50:00', 1);
|
||||
|
||||
-- Insert sample user sentiments with user identifiers
|
||||
INSERT INTO user_sentiments (joke_id, user_sentiment, user_identifier) VALUES
|
||||
(1, 'up', 'ComedyFan'),
|
||||
(1, 'up', 'JokeLover'),
|
||||
(1, 'neutral', 'CritiqueMaster'),
|
||||
(1, 'up', 'FunnyPerson'),
|
||||
(2, 'down', 'SeriousReader'),
|
||||
(2, 'up', 'HappyViewer'),
|
||||
(2, 'neutral', 'NeutralObserver'),
|
||||
(3, 'up', 'ComedyFan'),
|
||||
(3, 'up', 'JokeLover'),
|
||||
(3, 'up', 'FunnyPerson'),
|
||||
(3, 'down', 'CritiqueMaster'),
|
||||
(4, 'neutral', 'FishExpert'),
|
||||
(4, 'down', 'GrammarNazi'),
|
||||
(4, 'up', 'PunLover'),
|
||||
(5, 'up', 'ScienceGeek'),
|
||||
(5, 'up', 'BookWorm'),
|
||||
(5, 'neutral', 'Skeptic'),
|
||||
(6, 'up', 'TechEnthusiast'),
|
||||
(6, 'down', 'ComputerHater'),
|
||||
(7, 'up', 'AnimalLover'),
|
||||
(7, 'up', 'WordPlayFan'),
|
||||
(8, 'up', 'CyclingFan'),
|
||||
(8, 'neutral', 'BikeNovice'),
|
||||
(9, 'up', 'FarmKid'),
|
||||
(9, 'down', 'CitySlicker'),
|
||||
(10, 'neutral', 'MathStudent'),
|
||||
(10, 'up', 'ProblemSolver');
|
||||
|
||||
-- Verification queries
|
||||
SELECT '✅ Database setup complete!' as status;
|
||||
|
||||
-- Show joke counts
|
||||
SELECT 'Total jokes in database:' as info, COUNT(*) as count FROM jokes;
|
||||
|
||||
-- Show sentiment distribution
|
||||
SELECT
|
||||
'Sentiment Distribution:' as info,
|
||||
user_sentiment,
|
||||
COUNT(*) as count
|
||||
FROM user_sentiments
|
||||
GROUP BY user_sentiment
|
||||
ORDER BY count DESC;
|
||||
|
||||
-- Show most active users
|
||||
SELECT
|
||||
'Most Active Users:' as info,
|
||||
user_identifier,
|
||||
COUNT(*) as ratings_given
|
||||
FROM user_sentiments
|
||||
GROUP BY user_identifier
|
||||
ORDER BY ratings_given DESC
|
||||
LIMIT 5;
|
||||
|
||||
-- Show community positivity by joke
|
||||
SELECT
|
||||
'Community Positivity by Joke:' as info,
|
||||
j.joke,
|
||||
ROUND(AVG(CASE WHEN us.user_sentiment = 'up' THEN 1.0
|
||||
WHEN us.user_sentiment = 'down' THEN 0.0
|
||||
ELSE 0.5 END) * 100, 1) as positivity_percent,
|
||||
COUNT(*) as total_ratings
|
||||
FROM jokes j
|
||||
JOIN user_sentiments us ON j.id = us.joke_id
|
||||
GROUP BY j.id, j.joke
|
||||
ORDER BY positivity_percent DESC;
|
||||
Reference in New Issue
Block a user