Internet Explorer is no longer supported. Many things will still work, but your experience will be degraded and some things won't function. Please use a modern browser such as Edge, Chrome, or Firefox.

Change Script Details

Release23.22
Deployable(none)
Group
StatusActive
Modified6/14/2024 5:40:42 AM by cys-josh

Script Text

--AH:ScriptId=1bf44095-65c3-481e-90e3-fdf5ef18ab5c;80 USE ChooseYourStory IF OBJECT_ID('Homepage_GetHomepage') IS NOT NULL DROP PROCEDURE Homepage_GetHomepage GO CREATE PROCEDURE Homepage_GetHomepage ( @Username VARCHAR(20) ) AS BEGIN SELECT TOP 5 GP.* FROM [MyAdventureGame]..[Games - Published] GP JOIN [MyAdventureGame]..[Games] G ON GP.[Game Id] = G.[Game Id] ORDER BY (Select [MyAdventureGame].[dbo].[Game Ratings - Calculated].[Pop_Adjusted_Rating] from [MyAdventureGame].[dbo].[Game Ratings - Calculated] WHERE [MyAdventureGame].[dbo].[Game Ratings - Calculated].[Game ID] = GP.[Game Id]) DESC (SELECT [Game Id],[Title],[Username],[Date Published] FROM [MyAdventureGame].[dbo].[Games] WHERE [Date Published] >= CURRENT_TIMESTAMP - 30) UNION ALL SELECT * FROM ( SELECT TOP 11 [Game Id],[Title],[Username],[Date Published] FROM [MyAdventureGame].[dbo].[Games] WHERE [Date Published] < CURRENT_TIMESTAMP - 30 ORDER BY [Date Published] DESC) dum SELECT TOP 5 GP.* FROM [MyAdventureGame]..[Games - Published] GP JOIN [MyAdventureGame]..[Games] G ON GP.[Game Id] = G.[Game Id] WHERE [Rating Count] < 50 AND NOT EXISTS(SELECT NULL FROM [MyAdventureGame].[dbo].[Game Ratings] WHERE [MyAdventureGame].[dbo].[Game Ratings].[Game ID] = G.[Game Id] AND [MyAdventureGame].[dbo].[Game Ratings].[Username] = COALESCE(@Username, '')) ORDER BY (CASE WHEN [Rating] >= 5 THEN 1 ELSE 0 END) DESC, [Rating Count] DESC, GP.[First Publish Date] DESC SELECT TOP 2 FP.* FROM [MyAdventureGame]..[Forums_Posts] FP JOIN [MyAdventureGame]..[Forums_Messages] FM ON FP.[Message_Id] = FM.[Message_Id] AND FP.[Left]=1 WHERE FM.[Forum_Id] = 2 ORDER BY [Post_Date] DESC END GO GRANT EXECUTE ON [Homepage_GetHomepage] TO CYS_UserRole