From 9f7b5a836c8aeb83b66e0b41b8533443b5e99380 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sun, 20 Aug 2023 12:36:34 +0300 Subject: fix: change map history from timestamp to date Former-commit-id: 8a46950e919891f380dda5502e40434383c91245 --- backend/database/history.sql | 522 +++++++++++++++++++++---------------------- backend/database/init.sql | 2 +- 2 files changed, 262 insertions(+), 262 deletions(-) (limited to 'backend/database') diff --git a/backend/database/history.sql b/backend/database/history.sql index 320d72f..b30d10d 100644 --- a/backend/database/history.sql +++ b/backend/database/history.sql @@ -1,279 +1,279 @@ INSERT INTO map_history(map_id,category_id,user_name,score_count,record_date) VALUES -- Portal 2 Singleplayer -- 1 -(3,1,'slmid1995',3,'2011-10-05 00:00:00'), -(3,1,'LookLikeAKango',1,'2011-10-06 00:00:00'), -(3,1,'Bananasaurus Rex',0,'2011-10-24 00:00:00'), -(4,1,'Tyronis',1,'2011-10-05 00:00:00'), -(4,1,'Krzyhau',0,'2019-05-10 00:00:00'), -(5,1,'LookLikeAKango',2,'2011-10-05 00:00:00'), -(5,1,'Jetwash',1,'2013-12-03 00:00:00'), -(6,1,'Stimich',4,'2011-10-08 00:00:00'), -(6,1,'aepaePolakrn',3,'2011-10-19 00:00:00'), -(6,1,'Krzyhau',2,'2020-10-10 00:00:00'), -(9,1,'slmid1995',4,'2011-10-05 00:00:00'), -(9,1,'Jokie',3,'2011-10-05 00:00:00'), -(9,1,'Tyronis',2,'2011-10-05 00:00:00'), -(9,1,'sicklebrick',0,'2013-03-13 00:00:00'), +(3,1,'slmid1995',3,'2011-10-05'), +(3,1,'LookLikeAKango',1,'2011-10-06'), +(3,1,'Bananasaurus Rex',0,'2011-10-24'), +(4,1,'Tyronis',1,'2011-10-05'), +(4,1,'Krzyhau',0,'2019-05-10'), +(5,1,'LookLikeAKango',2,'2011-10-05'), +(5,1,'Jetwash',1,'2013-12-03'), +(6,1,'Stimich',4,'2011-10-08'), +(6,1,'aepaePolakrn',3,'2011-10-19'), +(6,1,'Krzyhau',2,'2020-10-10'), +(9,1,'slmid1995',4,'2011-10-05'), +(9,1,'Jokie',3,'2011-10-05'), +(9,1,'Tyronis',2,'2011-10-05'), +(9,1,'sicklebrick',0,'2013-03-13'), -- 2 -(10,1,'Paraxade0',2,'2011-04-21 00:00:00'), -(10,1,'PerOculos',0,'2011-04-21 00:00:00'), -(11,1,'Tyronis',2,'2011-10-05 00:00:00'), -(11,1,'Krzyhau',0,'2018-06-09 00:00:00'), -(12,1,'slmid1995',2,'2011-10-04 00:00:00'), -(13,1,'LookLikeAKango',3,'2011-10-05 00:00:00'), -(13,1,'Imanex',2,'2011-12-08 00:00:00'), -(13,1,'jyjey',0,'2012-08-22 00:00:00'), -(15,1,'Tyronis',2,'2011-10-05 00:00:00'), -(16,1,'LookLikeAKango',2,'2011-10-05 00:00:00'), -(16,1,'jyjey',0,'2012-08-25 00:00:00'), -(17,1,'rocoty',2,'2011-10-05 00:00:00'), -(17,1,'Nidboj132',0,'2023-02-05 00:00:00'), +(10,1,'Paraxade0',2,'2011-04-21'), +(10,1,'PerOculos',0,'2011-04-21'), +(11,1,'Tyronis',2,'2011-10-05'), +(11,1,'Krzyhau',0,'2018-06-09'), +(12,1,'slmid1995',2,'2011-10-04'), +(13,1,'LookLikeAKango',3,'2011-10-05'), +(13,1,'Imanex',2,'2011-12-08'), +(13,1,'jyjey',0,'2012-08-22'), +(15,1,'Tyronis',2,'2011-10-05'), +(16,1,'LookLikeAKango',2,'2011-10-05'), +(16,1,'jyjey',0,'2012-08-25'), +(17,1,'rocoty',2,'2011-10-05'), +(17,1,'Nidboj132',0,'2023-02-05'), -- 3 -(18,1,'The Last Tofus',5,'2011-05-08 00:00:00'), -(18,1,'Schlepian',4,'2011-10-08 00:00:00'), -(18,1,'szeimartin',3,'2013-10-08 00:00:00'), -(18,1,'Krzyhau',2,'2020-05-15 00:00:00'), -(18,1,'Krzyhau',0,'2022-07-02 00:00:00'), -(19,1,'LookLikeAKango',2,'2011-10-06 00:00:00'), -(20,1,'Djinndrache',5,'2011-10-20 00:00:00'), -(20,1,'Schlepian',4,'2011-10-30 00:00:00'), -(20,1,'Jetwash',3,'2014-09-04 00:00:00'), -(20,1,'Krzyhau',2,'2022-04-24 00:00:00'), -(21,1,'LookLikeAKango',4,'2011-10-06 00:00:00'), -(21,1,'ncla',2,'2011-10-30 00:00:00'), -(21,1,'PerOculos',0,'2019-07-08 00:00:00'), -(22,1,'Tyronis',0,'2011-10-05 00:00:00'), -(23,1,'LookLikeAKango',2,'2011-10-06 00:00:00'), -(23,1,'Krzyhau',0,'2018-08-01 00:00:00'), -(24,1,'LeviHB',0,'2011-04-30 00:00:00'), -(25,1,'Tyronis',0,'2011-10-06 00:00:00'), -(26,1,'Schlepian',3,'2011-10-30 00:00:00'), -(26,1,'Tyronis',2,'2012-01-08 00:00:00'), -(26,1,'PerOculos',0,'2016-06-08 00:00:00'), +(18,1,'The Last Tofus',5,'2011-05-08'), +(18,1,'Schlepian',4,'2011-10-08'), +(18,1,'szeimartin',3,'2013-10-08'), +(18,1,'Krzyhau',2,'2020-05-15'), +(18,1,'Krzyhau',0,'2022-07-02'), +(19,1,'LookLikeAKango',2,'2011-10-06'), +(20,1,'Djinndrache',5,'2011-10-20'), +(20,1,'Schlepian',4,'2011-10-30'), +(20,1,'Jetwash',3,'2014-09-04'), +(20,1,'Krzyhau',2,'2022-04-24'), +(21,1,'LookLikeAKango',4,'2011-10-06'), +(21,1,'ncla',2,'2011-10-30'), +(21,1,'PerOculos',0,'2019-07-08'), +(22,1,'Tyronis',0,'2011-10-05'), +(23,1,'LookLikeAKango',2,'2011-10-06'), +(23,1,'Krzyhau',0,'2018-08-01'), +(24,1,'LeviHB',0,'2011-04-30'), +(25,1,'Tyronis',0,'2011-10-06'), +(26,1,'Schlepian',3,'2011-10-30'), +(26,1,'Tyronis',2,'2012-01-08'), +(26,1,'PerOculos',0,'2016-06-08'), -- 4 -(27,1,'LeviHB',2,'2011-05-01 00:00:00'), -(27,1,'PerOculos',0,'2020-07-13 00:00:00'), -(28,1,'LeviHB',7,'2011-05-01 00:00:00'), -(28,1,'Andy M.J.',2,'2011-10-07 00:00:00'), -(28,1,'Krzyhau',0,'2018-05-19 00:00:00'), -(29,1,'LeviHB',0,'2011-05-01 00:00:00'), -(30,1,'Schlepian',2,'2011-10-30 00:00:00'), -(31,1,'Tyronis',0,'2011-10-06 00:00:00'), +(27,1,'LeviHB',2,'2011-05-01'), +(27,1,'PerOculos',0,'2020-07-13'), +(28,1,'LeviHB',7,'2011-05-01'), +(28,1,'Andy M.J.',2,'2011-10-07'), +(28,1,'Krzyhau',0,'2018-05-19'), +(29,1,'LeviHB',0,'2011-05-01'), +(30,1,'Schlepian',2,'2011-10-30'), +(31,1,'Tyronis',0,'2011-10-06'), -- 5 -(32,1,'Tyronis',6,'2011-10-21 00:00:00'), -(32,1,'Nidboj132',5,'2022-04-24 00:00:00'), -(33,1,'Tyronis',7,'2011-10-06 00:00:00'), -(33,1,'ISimmo',5,'2011-11-02 00:00:00'), -(33,1,'PerOculos',4,'2017-05-30 00:00:00'), -(34,1,'Schlepian',3,'2011-11-01 00:00:00'), -(34,1,'Krzyhau',2,'2020-10-14 00:00:00'), -(34,1,'zach',0,'2022-11-02 00:00:00'), -(35,1,'Krank',2,'2012-07-28 00:00:00'), +(32,1,'Tyronis',6,'2011-10-21'), +(32,1,'Nidboj132',5,'2022-04-24'), +(33,1,'Tyronis',7,'2011-10-06'), +(33,1,'ISimmo',5,'2011-11-02'), +(33,1,'PerOculos',4,'2017-05-30'), +(34,1,'Schlepian',3,'2011-11-01'), +(34,1,'Krzyhau',2,'2020-10-14'), +(34,1,'zach',0,'2022-11-02'), +(35,1,'Krank',2,'2012-07-28'), -- 6 -(36,1,'Tyronis',6,'2011-10-06 00:00:00'), -(36,1,'CalmlyFrenetic',5,'2011-10-09 00:00:00'), -(36,1,'sicklebrick',4,'2012-09-13 00:00:00'), -(36,1,'Nidboj132',2,'2023-03-04 00:00:00'), -(37,1,'LookLikeAKango',7,'2011-10-06 00:00:00'), -(37,1,'Schlepian',6,'2011-11-01 00:00:00'), -(37,1,'Tyronis',5,'2012-01-28 00:00:00'), -(37,1,'Nidboj132',4,'2021-08-22 00:00:00'), -(38,1,'Andy M.J.',2,'2011-10-06 00:00:00'), -(38,1,'Sanguine Dagger',0,'2012-03-19 00:00:00'), -(39,1,'Lambda Core',6,'2011-05-13 00:00:00'), -(39,1,'The Last Tofus',5,'2011-05-13 00:00:00'), -(39,1,'LookLikeAKango',4,'2011-10-16 00:00:00'), -(39,1,'Kittaye',3,'2013-03-25 00:00:00'), -(40,1,'LookLikeAKango',7,'2011-10-07 00:00:00'), -(40,1,'Schlepian',6,'2011-11-05 00:00:00'), -(40,1,'Kittaye',4,'2013-04-01 00:00:00'), -(40,1,'Kittaye',3,'2014-09-13 00:00:00'), -(40,1,'szeimartin',2,'2014-09-13 00:00:00'), -(40,1,'Kittaye',0,'2014-09-15 00:00:00'), -(41,1,'CalmlyFrenetic',7,'2011-10-09 00:00:00'), -(41,1,'Jaso',6,'2011-10-11 00:00:00'), -(41,1,'Krank',5,'2012-07-17 00:00:00'), +(36,1,'Tyronis',6,'2011-10-06'), +(36,1,'CalmlyFrenetic',5,'2011-10-09'), +(36,1,'sicklebrick',4,'2012-09-13'), +(36,1,'Nidboj132',2,'2023-03-04'), +(37,1,'LookLikeAKango',7,'2011-10-06'), +(37,1,'Schlepian',6,'2011-11-01'), +(37,1,'Tyronis',5,'2012-01-28'), +(37,1,'Nidboj132',4,'2021-08-22'), +(38,1,'Andy M.J.',2,'2011-10-06'), +(38,1,'Sanguine Dagger',0,'2012-03-19'), +(39,1,'Lambda Core',6,'2011-05-13'), +(39,1,'The Last Tofus',5,'2011-05-13'), +(39,1,'LookLikeAKango',4,'2011-10-16'), +(39,1,'Kittaye',3,'2013-03-25'), +(40,1,'LookLikeAKango',7,'2011-10-07'), +(40,1,'Schlepian',6,'2011-11-05'), +(40,1,'Kittaye',4,'2013-04-01'), +(40,1,'Kittaye',3,'2014-09-13'), +(40,1,'szeimartin',2,'2014-09-13'), +(40,1,'Kittaye',0,'2014-09-15'), +(41,1,'CalmlyFrenetic',7,'2011-10-09'), +(41,1,'Jaso',6,'2011-10-11'), +(41,1,'Krank',5,'2012-07-17'), -- 7 -(42,1,'LookLikeAKango',4,'2011-05-17 00:00:00'), -(42,1,'ISimmo',2,'2011-11-07 00:00:00'), -(43,1,'lmao4ever',5,'2011-10-30 00:00:00'), -(43,1,'Jaso',2,'2011-11-09 00:00:00'), -(43,1,'feliser',0,'2022-06-26 00:00:00'), -(44,1,'LookLikeAKango',18,'2011-10-07 00:00:00'), -(44,1,'Tyronis',13,'2011-10-30 00:00:00'), -(44,1,'Tyronis',12,'2011-11-10 00:00:00'), -(44,1,'Jetwash',11,'2017-06-12 00:00:00'), -(44,1,'Krzyhau',9,'2022-01-02 00:00:00'), -(45,1,'LookLikeAKango',23,'2011-10-08 00:00:00'), -(45,1,'CalmlyFrenetic',22,'2011-10-09 00:00:00'), -(45,1,'cgreactor',17,'2011-10-09 00:00:00'), -(45,1,'CalmlyFrenetic',16,'2011-10-10 00:00:00'), -(45,1,'LookLikeAKango',15,'2011-10-19 00:00:00'), -(45,1,'Jaso',12,'2012-07-19 00:00:00'), -(45,1,'Krank',10,'2013-01-31 00:00:00'), -(45,1,'Kittaye',7,'2013-04-04 00:00:00'), -(45,1,'PerOculos',4,'2014-09-13 00:00:00'), +(42,1,'LookLikeAKango',4,'2011-05-17'), +(42,1,'ISimmo',2,'2011-11-07'), +(43,1,'lmao4ever',5,'2011-10-30'), +(43,1,'Jaso',2,'2011-11-09'), +(43,1,'feliser',0,'2022-06-26'), +(44,1,'LookLikeAKango',18,'2011-10-07'), +(44,1,'Tyronis',13,'2011-10-30'), +(44,1,'Tyronis',12,'2011-11-10'), +(44,1,'Jetwash',11,'2017-06-12'), +(44,1,'Krzyhau',9,'2022-01-02'), +(45,1,'LookLikeAKango',23,'2011-10-08'), +(45,1,'CalmlyFrenetic',22,'2011-10-09'), +(45,1,'cgreactor',17,'2011-10-09'), +(45,1,'CalmlyFrenetic',16,'2011-10-10'), +(45,1,'LookLikeAKango',15,'2011-10-19'), +(45,1,'Jaso',12,'2012-07-19'), +(45,1,'Krank',10,'2013-01-31'), +(45,1,'Kittaye',7,'2013-04-04'), +(45,1,'PerOculos',4,'2014-09-13'), -- 8 -(46,1,'sparkle1princess',6,'2012-03-24 00:00:00'), -(46,1,'Krzyhau',2,'2019-11-21 00:00:00'), -(47,1,'holydevel',2,'2011-10-06 00:00:00'), -(47,1,'JesusCatFace',0,'2015-01-16 00:00:00'), -(48,1,'LookLikeAKango',5,'2011-10-08 00:00:00'), -(48,1,'Tyronis',2,'2011-10-08 00:00:00'), -(48,1,'adzicents',0,'2011-10-09 00:00:00'), -(49,1,'adzicents',4,'2011-10-07 00:00:00'), -(49,1,'Schlepian',2,'2011-10-08 00:00:00'), -(49,1,'Nidboj132',0,'2022-09-26 00:00:00'), -(50,1,'LookLikeAKango',4,'2011-10-08 00:00:00'), -(50,1,'Tyronis',2,'2011-10-11 00:00:00'), -(50,1,'sicklebrick',0,'2013-03-20 00:00:00'), -(51,1,'Andy M.J.',3,'2011-10-08 00:00:00'), -(51,1,'LookLikeAKango',2,'2011-10-20 00:00:00'), -(52,1,'Jaso',0,'2011-10-10 00:00:00'), -(53,1,'LookLikeAKango',9,'2011-10-08 00:00:00'), -(53,1,'LookLikeAKango',2,'2011-10-20 00:00:00'), -(53,1,'Schlepian',0,'2011-11-06 00:00:00'), -(54,1,'LookLikeAKango',7,'2011-06-01 00:00:00'), -(54,1,'Jaso',6,'2011-10-09 00:00:00'), -(54,1,'Schlepian',5,'2011-11-06 00:00:00'), -(54,1,'Spyrunite',4,'2012-08-30 00:00:00'), -(54,1,'Krzyhau',3,'2019-04-22 00:00:00'), -(55,1,'LookLikeAKango',7,'2011-10-08 00:00:00'), -(55,1,'CalmlyFrenetic',3,'2011-10-09 00:00:00'), -(55,1,'Jaso',2,'2011-11-26 00:00:00'), -(55,1,'PerOculos',0,'2021-02-06 00:00:00'), -(56,1,'CalmlyFrenetic',9,'2011-10-08 00:00:00'), -(56,1,'LookLikeAKango',5,'2011-10-09 00:00:00'), -(56,1,'CalmlyFrenetic',4,'2011-10-09 00:00:00'), -(56,1,'Jetwash',2,'2014-09-05 00:00:00'), +(46,1,'sparkle1princess',6,'2012-03-24'), +(46,1,'Krzyhau',2,'2019-11-21'), +(47,1,'holydevel',2,'2011-10-06'), +(47,1,'JesusCatFace',0,'2015-01-16'), +(48,1,'LookLikeAKango',5,'2011-10-08'), +(48,1,'Tyronis',2,'2011-10-08'), +(48,1,'adzicents',0,'2011-10-09'), +(49,1,'adzicents',4,'2011-10-07'), +(49,1,'Schlepian',2,'2011-10-08'), +(49,1,'Nidboj132',0,'2022-09-26'), +(50,1,'LookLikeAKango',4,'2011-10-08'), +(50,1,'Tyronis',2,'2011-10-11'), +(50,1,'sicklebrick',0,'2013-03-20'), +(51,1,'Andy M.J.',3,'2011-10-08'), +(51,1,'LookLikeAKango',2,'2011-10-20'), +(52,1,'Jaso',0,'2011-10-10'), +(53,1,'LookLikeAKango',9,'2011-10-08'), +(53,1,'LookLikeAKango',2,'2011-10-20'), +(53,1,'Schlepian',0,'2011-11-06'), +(54,1,'LookLikeAKango',7,'2011-06-01'), +(54,1,'Jaso',6,'2011-10-09'), +(54,1,'Schlepian',5,'2011-11-06'), +(54,1,'Spyrunite',4,'2012-08-30'), +(54,1,'Krzyhau',3,'2019-04-22'), +(55,1,'LookLikeAKango',7,'2011-10-08'), +(55,1,'CalmlyFrenetic',3,'2011-10-09'), +(55,1,'Jaso',2,'2011-11-26'), +(55,1,'PerOculos',0,'2021-02-06'), +(56,1,'CalmlyFrenetic',9,'2011-10-08'), +(56,1,'LookLikeAKango',5,'2011-10-09'), +(56,1,'CalmlyFrenetic',4,'2011-10-09'), +(56,1,'Jetwash',2,'2014-09-05'), -- 9 -(57,1,'JNS',7,'2011-07-21 00:00:00'), -(57,1,'Krank',5,'2012-07-29 00:00:00'), -(57,1,'Krzyhau',0,'2017-10-29 00:00:00'), -(58,1,'Stimich',2,'2011-10-11 00:00:00'), -(59,1,'Isimmo',7,'2011-11-04 00:00:00'), -(59,1,'sicklebrick',6,'2013-03-20 00:00:00'), -(60,1,'CalmlyFrenetic',7,'2011-10-19 00:00:00'), -(60,1,'Tyronis',6,'2011-11-01 00:00:00'), +(57,1,'JNS',7,'2011-07-21'), +(57,1,'Krank',5,'2012-07-29'), +(57,1,'Krzyhau',0,'2017-10-29'), +(58,1,'Stimich',2,'2011-10-11'), +(59,1,'Isimmo',7,'2011-11-04'), +(59,1,'sicklebrick',6,'2013-03-20'), +(60,1,'CalmlyFrenetic',7,'2011-10-19'), +(60,1,'Tyronis',6,'2011-11-01'), -- Portal 2 Cooperative -- 1 -(63,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01 00:00:00'), -(64,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(64,1,'Chubfish & Exhale',2,'2011-11-01 00:00:00'), -(65,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(65,1,'Nidboj132 & Oryn',3,'2022-02-03 00:00:00'), -(66,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(66,1,'Schlepian & Chubfish',2,'2011-10-01 00:00:00'), -(67,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01 00:00:00'), -(68,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01 00:00:00'), +(63,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01'), +(64,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(64,1,'Chubfish & Exhale',2,'2011-11-01'), +(65,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(65,1,'Nidboj132 & Oryn',3,'2022-02-03'), +(66,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(66,1,'Schlepian & Chubfish',2,'2011-10-01'), +(67,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01'), +(68,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01'), -- 2 -(69,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(70,1,'Mathias123961 & Sir Spawn Alot',6,'2011-08-01 00:00:00'), -(70,1,'Schlepian & Chubfish',4,'2011-10-01 00:00:00'), -(70,1,'Gocnak & z1mb0bw4y',2,'2012-08-03 00:00:00'), -(70,1,'DM_ & VEGA',0,'2017-10-01 00:00:00'), -(71,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(71,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01 00:00:00'), -(72,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(72,1,'Schlepian & LongJohnDickWeed',2,'2011-10-01 00:00:00'), -(73,1,'Stimich & HiTMaRkS',9,'2011-05-09 00:00:00'), -(73,1,'Mathias123961 & Sir Spawn Alot',8,'2011-08-01 00:00:00'), -(73,1,'Schlepian & Lemonsunshine',7,'2011-11-01 00:00:00'), -(73,1,'DM_ & LsDK_',6,'2018-01-01 00:00:00'), -(73,1,'Krzyhau & Klooger',4,'2018-11-01 00:00:00'), -(74,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01 00:00:00'), -(74,1,'Stimich & Pitkakorva',7,'2011-10-11 00:00:00'), -(74,1,'Schlepian & Isimmo',3,'2011-10-28 00:00:00'), -(74,1,'Zypeh & szeimartin',2,'2013-11-01 00:00:00'), -(75,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01 00:00:00'), -(75,1,'Schlepian & Urination',4,'2011-10-01 00:00:00'), -(75,1,'Schlepian & Lemonsunshine',2,'2012-02-01 00:00:00'), -(75,1,'DM_ & follon',0,'2015-04-01 00:00:00'), -(76,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(76,1,'Chubfish & Exhale',0,'2011-12-01 00:00:00'), +(69,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(70,1,'Mathias123961 & Sir Spawn Alot',6,'2011-08-01'), +(70,1,'Schlepian & Chubfish',4,'2011-10-01'), +(70,1,'Gocnak & z1mb0bw4y',2,'2012-08-03'), +(70,1,'DM_ & VEGA',0,'2017-10-01'), +(71,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(71,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01'), +(72,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(72,1,'Schlepian & LongJohnDickWeed',2,'2011-10-01'), +(73,1,'Stimich & HiTMaRkS',9,'2011-05-09'), +(73,1,'Mathias123961 & Sir Spawn Alot',8,'2011-08-01'), +(73,1,'Schlepian & Lemonsunshine',7,'2011-11-01'), +(73,1,'DM_ & LsDK_',6,'2018-01-01'), +(73,1,'Krzyhau & Klooger',4,'2018-11-01'), +(74,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01'), +(74,1,'Stimich & Pitkakorva',7,'2011-10-11'), +(74,1,'Schlepian & Isimmo',3,'2011-10-28'), +(74,1,'Zypeh & szeimartin',2,'2013-11-01'), +(75,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01'), +(75,1,'Schlepian & Urination',4,'2011-10-01'), +(75,1,'Schlepian & Lemonsunshine',2,'2012-02-01'), +(75,1,'DM_ & follon',0,'2015-04-01'), +(76,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(76,1,'Chubfish & Exhale',0,'2011-12-01'), -- 3 -(77,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(78,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(78,1,'DM_ & marK',3,'2016-11-01 00:00:00'), -(78,1,'Nidboj132 & Oryn',2,'2021-09-04 00:00:00'), -(79,1,'ganonscrub & ?',5,'2011-04-01 00:00:00'), -(79,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(79,1,'Chubfish & Exhale',2,'2012-08-04 00:00:00'), -(80,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01 00:00:00'), -(80,1,'Chubfish & Exhale',4,'2011-12-01 00:00:00'), -(81,1,'Mathias123961 & Sir Spawn Alot',7,'2011-08-01 00:00:00'), -(81,1,'Schlepian & Lemonsunshine',6,'2011-10-01 00:00:00'), -(81,1,'takz & dawn',5,'2011-11-01 00:00:00'), -(81,1,'Nidboj132 & Oryn',4,'2021-03-25 00:00:00'), -(82,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(83,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01 00:00:00'), -(83,1,'Schlepian & Lemonsunshine',2,'2011-10-01 00:00:00'), -(83,1,'Chubfish & Exhale',0,'2011-12-01 00:00:00'), -(84,1,'Mathias123961 & Sir Spawn Alot',6,'2011-08-01 00:00:00'), -(84,1,'Schlepian & Chubfish',4,'2011-10-01 00:00:00'), -(84,1,'Chubfish & Exhale',2,'2012-01-01 00:00:00'), -(84,1,'DM_ & wS',0,'2015-05-01 00:00:00'), +(77,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(78,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(78,1,'DM_ & marK',3,'2016-11-01'), +(78,1,'Nidboj132 & Oryn',2,'2021-09-04'), +(79,1,'ganonscrub & ?',5,'2011-04-01'), +(79,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(79,1,'Chubfish & Exhale',2,'2012-08-04'), +(80,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01'), +(80,1,'Chubfish & Exhale',4,'2011-12-01'), +(81,1,'Mathias123961 & Sir Spawn Alot',7,'2011-08-01'), +(81,1,'Schlepian & Lemonsunshine',6,'2011-10-01'), +(81,1,'takz & dawn',5,'2011-11-01'), +(81,1,'Nidboj132 & Oryn',4,'2021-03-25'), +(82,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(83,1,'Mathias123961 & Sir Spawn Alot',5,'2011-08-01'), +(83,1,'Schlepian & Lemonsunshine',2,'2011-10-01'), +(83,1,'Chubfish & Exhale',0,'2011-12-01'), +(84,1,'Mathias123961 & Sir Spawn Alot',6,'2011-08-01'), +(84,1,'Schlepian & Chubfish',4,'2011-10-01'), +(84,1,'Chubfish & Exhale',2,'2012-01-01'), +(84,1,'DM_ & wS',0,'2015-05-01'), -- 4 -(85,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(85,1,'Chubfish & Exhale',0,'2011-10-01 00:00:00'), -(86,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(86,1,'Chubfish & Exhale',0,'2011-12-01 00:00:00'), -(87,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01 00:00:00'), -(87,1,'Schlepian & Gopherdude',2,'2011-10-01 00:00:00'), -(87,1,'DM_ & follon',0,'2015-04-01 00:00:00'), -(88,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(88,1,'Schlepian & Gopherdude',0,'2011-10-01 00:00:00'), -(89,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01 00:00:00'), -(90,1,'Mathias123961 & Sir Spawn Alot',4,'2011-09-01 00:00:00'), -(90,1,'Schlepian & Urination',2,'2011-10-01 00:00:00'), -(90,1,'Klooger & Jetwash',0,'2016-08-01 00:00:00'), -(91,1,'Mathias123961 & Sir Spawn Alot',2,'2011-08-01 00:00:00'), -(91,1,'Undead & Zypeh',0,'2013-05-19 00:00:00'), -(92,1,'txx478 & ?',5,'2011-05-01 00:00:00'), -(92,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01 00:00:00'), -(92,1,'Schlepian & Gopherdude',2,'2011-10-01 00:00:00'), -(92,1,'ncla & takz',0,'2012-02-01 00:00:00'), -(93,1,'Mathias123961 & Sir Spawn Alot',2,'2011-08-01 00:00:00'), -(93,1,'Schlepian & Gopherdude',0,'2011-10-01 00:00:00'), +(85,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(85,1,'Chubfish & Exhale',0,'2011-10-01'), +(86,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(86,1,'Chubfish & Exhale',0,'2011-12-01'), +(87,1,'Mathias123961 & Sir Spawn Alot',3,'2011-08-01'), +(87,1,'Schlepian & Gopherdude',2,'2011-10-01'), +(87,1,'DM_ & follon',0,'2015-04-01'), +(88,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(88,1,'Schlepian & Gopherdude',0,'2011-10-01'), +(89,1,'Mathias123961 & Sir Spawn Alot',0,'2011-08-01'), +(90,1,'Mathias123961 & Sir Spawn Alot',4,'2011-09-01'), +(90,1,'Schlepian & Urination',2,'2011-10-01'), +(90,1,'Klooger & Jetwash',0,'2016-08-01'), +(91,1,'Mathias123961 & Sir Spawn Alot',2,'2011-08-01'), +(91,1,'Undead & Zypeh',0,'2013-05-19'), +(92,1,'txx478 & ?',5,'2011-05-01'), +(92,1,'Mathias123961 & Sir Spawn Alot',4,'2011-08-01'), +(92,1,'Schlepian & Gopherdude',2,'2011-10-01'), +(92,1,'ncla & takz',0,'2012-02-01'), +(93,1,'Mathias123961 & Sir Spawn Alot',2,'2011-08-01'), +(93,1,'Schlepian & Gopherdude',0,'2011-10-01'), -- 5 -(94,1,'Chubfish & Exhale',2,'2011-10-01 00:00:00'), -(94,1,'Klooger & Imanex',0,'2013-08-01 00:00:00'), -(95,1,'Schlepian & Issimoi',2,'2011-10-01 00:00:00'), -(96,1,'ThePortalPatrol & ?',4,'2011-04-01 00:00:00'), -(96,1,'sparkle1princess & Zypeh',2,'2014-01-01 00:00:00'), -(97,1,'Stimich & HiTMaRkS',7,'2011-05-13 00:00:00'), -(97,1,'Schlepian & Lemonsunshine',4,'2011-10-01 00:00:00'), -(97,1,'DM_ & wS',2,'2014-05-01 00:00:00'), -(98,1,'Imanex & 00svo',0,'2011-11-01 00:00:00'), -(99,1,'Schlepian & Gopherdude',3,'2011-10-01 00:00:00'), -(99,1,'Imanex & Klooger',2,'2013-08-01 00:00:00'), -(99,1,'DM_ & wS',0,'2015-05-01 00:00:00'), -(100,1,'Schlepian & Bananasaurus Rex',0,'2011-10-01 00:00:00'), -(101,1,'Chubfish & Exhale',2,'2011-12-01 00:00:00'), -(101,1,'DM_ & follon',0,'2015-04-01 00:00:00'), +(94,1,'Chubfish & Exhale',2,'2011-10-01'), +(94,1,'Klooger & Imanex',0,'2013-08-01'), +(95,1,'Schlepian & Issimoi',2,'2011-10-01'), +(96,1,'ThePortalPatrol & ?',4,'2011-04-01'), +(96,1,'sparkle1princess & Zypeh',2,'2014-01-01'), +(97,1,'Stimich & HiTMaRkS',7,'2011-05-13'), +(97,1,'Schlepian & Lemonsunshine',4,'2011-10-01'), +(97,1,'DM_ & wS',2,'2014-05-01'), +(98,1,'Imanex & 00svo',0,'2011-11-01'), +(99,1,'Schlepian & Gopherdude',3,'2011-10-01'), +(99,1,'Imanex & Klooger',2,'2013-08-01'), +(99,1,'DM_ & wS',0,'2015-05-01'), +(100,1,'Schlepian & Bananasaurus Rex',0,'2011-10-01'), +(101,1,'Chubfish & Exhale',2,'2011-12-01'), +(101,1,'DM_ & follon',0,'2015-04-01'), -- 6 -(102,1,'dawn & takz',3,'2011-11-18 00:00:00'), -(102,1,'Chubfish & Exhale',2,'2012-01-01 00:00:00'), -(102,1,'Imanex & Klooger',0,'2013-08-01 00:00:00'), -(103,1,'Schlepian & Lemonsunshine',0,'2011-10-01 00:00:00'), -(104,1,'Schlepian & Lemonsunshine',0,'2011-10-01 00:00:00'), -(105,1,'Blaizerazer & ?',8,'2011-10-01 00:00:00'), -(105,1,'Schlepian & Lemonsunshine',5,'2011-11-01 00:00:00'), -(105,1,'Imanex & Klooger',4,'2013-08-01 00:00:00'), -(105,1,'DM_ & wS',3,'2014-05-01 00:00:00'), -(105,1,'DM_ & follon',2,'2015-04-01 00:00:00'), -(106,1,'Schlepian & Bananasaurus Rex',4,'2011-10-01 00:00:00'), -(106,1,'Gig & takz',3,'2012-06-01 00:00:00'), -(106,1,'Imanex & Klooger',0,'2013-06-01 00:00:00'), -(107,1,'Chubfish & Exhale',2,'2011-10-01 00:00:00'), -(107,1,'DM_ & follon',0,'2015-04-01 00:00:00'), -(108,1,'DaFox & P',0,'2011-12-01 00:00:00'), -(109,1,'Schlepian & Tyronis',5,'2011-10-01 00:00:00'), -(109,1,'Chubfish & Exhale',0,'2011-12-01 00:00:00'), -(110,1,'Tyronis & mr.bob806',15,'2011-10-01 00:00:00'), -(110,1,'Schlepian & Chubfish',6,'2011-11-01 00:00:00'), -(110,1,'00svo & z1mb0bw4y',5,'2012-08-08 00:00:00'), -(110,1,'00svo & z1mb0bw4y',4,'2012-08-10 00:00:00'), -(110,1,'Klooger & z1mb0bw4y',2,'2014-02-01 00:00:00'), -(110,1,'DM_ & follon',0,'2015-04-01 00:00:00'); \ No newline at end of file +(102,1,'dawn & takz',3,'2011-11-18'), +(102,1,'Chubfish & Exhale',2,'2012-01-01'), +(102,1,'Imanex & Klooger',0,'2013-08-01'), +(103,1,'Schlepian & Lemonsunshine',0,'2011-10-01'), +(104,1,'Schlepian & Lemonsunshine',0,'2011-10-01'), +(105,1,'Blaizerazer & ?',8,'2011-10-01'), +(105,1,'Schlepian & Lemonsunshine',5,'2011-11-01'), +(105,1,'Imanex & Klooger',4,'2013-08-01'), +(105,1,'DM_ & wS',3,'2014-05-01'), +(105,1,'DM_ & follon',2,'2015-04-01'), +(106,1,'Schlepian & Bananasaurus Rex',4,'2011-10-01'), +(106,1,'Gig & takz',3,'2012-06-01'), +(106,1,'Imanex & Klooger',0,'2013-06-01'), +(107,1,'Chubfish & Exhale',2,'2011-10-01'), +(107,1,'DM_ & follon',0,'2015-04-01'), +(108,1,'DaFox & P',0,'2011-12-01'), +(109,1,'Schlepian & Tyronis',5,'2011-10-01'), +(109,1,'Chubfish & Exhale',0,'2011-12-01'), +(110,1,'Tyronis & mr.bob806',15,'2011-10-01'), +(110,1,'Schlepian & Chubfish',6,'2011-11-01'), +(110,1,'00svo & z1mb0bw4y',5,'2012-08-08'), +(110,1,'00svo & z1mb0bw4y',4,'2012-08-10'), +(110,1,'Klooger & z1mb0bw4y',2,'2014-02-01'), +(110,1,'DM_ & follon',0,'2015-04-01'); \ No newline at end of file diff --git a/backend/database/init.sql b/backend/database/init.sql index 50e7c15..11d4944 100644 --- a/backend/database/init.sql +++ b/backend/database/init.sql @@ -59,7 +59,7 @@ CREATE TABLE map_history ( category_id SMALLINT NOT NULL, user_name TEXT NOT NULL, score_count SMALLINT NOT NULL, - record_date TIMESTAMP NOT NULL, + record_date DATE NOT NULL, PRIMARY KEY (id), FOREIGN KEY (category_id) REFERENCES categories(id), FOREIGN KEY (map_id) REFERENCES maps(id), -- cgit v1.2.3 From ca973edc28b5fe543c583217896590f4a2e98897 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Thu, 24 Aug 2023 22:34:05 +0300 Subject: fix: mod flag for easy check (#49) Former-commit-id: 06ee23ee9659834252d3cb5c3c255797e9f93b62 --- .gitignore | 3 +- backend/controllers/modController.go | 44 +++++----------- backend/controllers/userController.go | 95 +++++++++++++++++------------------ backend/database/init.sql | 15 +++++- backend/middleware/auth.go | 13 +++-- backend/models/models.go | 14 +++++- 6 files changed, 95 insertions(+), 89 deletions(-) (limited to 'backend/database') diff --git a/.gitignore b/.gitignore index 1434a43..10d4fda 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .vscode *.sh *.txt -*.dem \ No newline at end of file +*.dem +*.json \ No newline at end of file diff --git a/backend/controllers/modController.go b/backend/controllers/modController.go index 7ce5cb4..7acdb5d 100644 --- a/backend/controllers/modController.go +++ b/backend/controllers/modController.go @@ -49,18 +49,13 @@ type EditMapImageRequest struct { // @Router /maps/{id}/summary [post] func CreateMapSummary(c *gin.Context) { // Check if user exists - user, exists := c.Get("user") + _, exists := c.Get("user") if !exists { c.JSON(http.StatusUnauthorized, models.ErrorResponse("User not logged in.")) return } - var moderator bool - for _, title := range user.(models.User).Titles { - if title == "Moderator" { - moderator = true - } - } - if !moderator { + mod, exists := c.Get("mod") + if !exists || !mod.(bool) { c.JSON(http.StatusUnauthorized, models.ErrorResponse("Insufficient permissions.")) return } @@ -135,18 +130,13 @@ func CreateMapSummary(c *gin.Context) { // @Router /maps/{id}/summary [put] func EditMapSummary(c *gin.Context) { // Check if user exists - user, exists := c.Get("user") + _, exists := c.Get("user") if !exists { c.JSON(http.StatusUnauthorized, models.ErrorResponse("User not logged in.")) return } - var moderator bool - for _, title := range user.(models.User).Titles { - if title == "Moderator" { - moderator = true - } - } - if !moderator { + mod, exists := c.Get("mod") + if !exists || !mod.(bool) { c.JSON(http.StatusUnauthorized, models.ErrorResponse("Insufficient permissions.")) return } @@ -221,18 +211,13 @@ func EditMapSummary(c *gin.Context) { // @Router /maps/{id}/summary [delete] func DeleteMapSummary(c *gin.Context) { // Check if user exists - user, exists := c.Get("user") + _, exists := c.Get("user") if !exists { c.JSON(http.StatusUnauthorized, models.ErrorResponse("User not logged in.")) return } - var moderator bool - for _, title := range user.(models.User).Titles { - if title == "Moderator" { - moderator = true - } - } - if !moderator { + mod, exists := c.Get("mod") + if !exists || !mod.(bool) { c.JSON(http.StatusUnauthorized, models.ErrorResponse("Insufficient permissions.")) return } @@ -311,18 +296,13 @@ func DeleteMapSummary(c *gin.Context) { // @Router /maps/{id}/image [put] func EditMapImage(c *gin.Context) { // Check if user exists - user, exists := c.Get("user") + _, exists := c.Get("user") if !exists { c.JSON(http.StatusUnauthorized, models.ErrorResponse("User not logged in.")) return } - var moderator bool - for _, title := range user.(models.User).Titles { - if title == "Moderator" { - moderator = true - } - } - if !moderator { + mod, exists := c.Get("mod") + if !exists || !mod.(bool) { c.JSON(http.StatusUnauthorized, models.ErrorResponse("Insufficient permissions.")) return } diff --git a/backend/controllers/userController.go b/backend/controllers/userController.go index 0dae155..64f144a 100644 --- a/backend/controllers/userController.go +++ b/backend/controllers/userController.go @@ -17,8 +17,39 @@ type ProfileResponse struct { UserName string `json:"user_name"` AvatarLink string `json:"avatar_link"` CountryCode string `json:"country_code"` - ScoresSP []ScoreResponse `json:"scores_sp"` - ScoresMP []ScoreResponse `json:"scores_mp"` + Titles []models.Title `json:"titles"` + Links models.Links `json:"links"` + Rankings ProfileRankings `json:"rankings"` + Records ProfileRecords `json:"records"` +} + +type ProfileRankings struct { + Overall ProfileRankingsDetails `json:"overall"` + Singleplayer ProfileRankingsDetails `json:"singleplayer"` + Cooperative ProfileRankingsDetails `json:"cooperative"` +} + +type ProfileRankingsDetails struct { + Rank int `json:"rank"` + CompletionCount int `json:"completion_count"` + CompletionTotal int `json:"completion_total"` +} + +type ProfileRecords struct { + P2Singleplayer ProfileRecordsDetails `json:"portal2_singleplayer"` + P2Cooperative ProfileRecordsDetails `json:"portal2_cooperative"` +} + +type ProfileRecordsDetails struct { + MapID int `json:"map_id"` + Scores []ProfileScores `json:"scores"` +} + +type ProfileScores struct { + DemoID string `json:"demo_id"` + ScoreCount int `json:"score_count"` + ScoreTime int `json:"score_time"` + Date time.Time `json:"date"` } type ScoreResponse struct { @@ -44,58 +75,22 @@ func Profile(c *gin.Context) { c.JSON(http.StatusUnauthorized, models.ErrorResponse("User not logged in.")) return } - // Retrieve singleplayer records - var scoresSP []ScoreResponse - sql := `SELECT id, map_id, score_count, score_time, demo_id, record_date FROM records_sp WHERE user_id = $1 ORDER BY map_id` + // Get user titles + titles := []models.Title{} + sql := `SELECT t.title_name, t.title_color FROM titles t + INNER JOIN user_titles ut ON t.id=ut.title_id WHERE ut.user_id = $1` rows, err := database.DB.Query(sql, user.(models.User).SteamID) if err != nil { c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) return } - var recordsSP []models.RecordSP - for rows.Next() { - var mapID int - var record models.RecordSP - rows.Scan(&record.RecordID, &mapID, &record.ScoreCount, &record.ScoreTime, &record.DemoID, &record.RecordDate) - // More than one record in one map - if len(scoresSP) != 0 && mapID == scoresSP[len(scoresSP)-1].MapID { - scoresSP[len(scoresSP)-1].Records = append(scoresSP[len(scoresSP)-1].Records.([]models.RecordSP), record) - continue - } - // New map - recordsSP = []models.RecordSP{} - recordsSP = append(recordsSP, record) - scoresSP = append(scoresSP, ScoreResponse{ - MapID: mapID, - Records: recordsSP, - }) - } - // Retrieve multiplayer records - var scoresMP []ScoreResponse - sql = `SELECT id, map_id, host_id, partner_id, score_count, score_time, host_demo_id, partner_demo_id, record_date FROM records_mp - WHERE host_id = $1 OR partner_id = $2 ORDER BY map_id` - rows, err = database.DB.Query(sql, user.(models.User).SteamID, user.(models.User).SteamID) - if err != nil { - c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) - return - } - var recordsMP []models.RecordMP for rows.Next() { - var mapID int - var record models.RecordMP - rows.Scan(&record.RecordID, &mapID, &record.HostID, &record.PartnerID, &record.ScoreCount, &record.ScoreTime, &record.HostDemoID, &record.PartnerDemoID, &record.RecordDate) - // More than one record in one map - if len(scoresMP) != 0 && mapID == scoresMP[len(scoresMP)-1].MapID { - scoresMP[len(scoresMP)-1].Records = append(scoresMP[len(scoresMP)-1].Records.([]models.RecordMP), record) - continue + var title models.Title + if err := rows.Scan(&title.Name, &title.Color); err != nil { + c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) + return } - // New map - recordsMP = []models.RecordMP{} - recordsMP = append(recordsMP, record) - scoresMP = append(scoresMP, ScoreResponse{ - MapID: mapID, - Records: recordsMP, - }) + titles = append(titles, title) } c.JSON(http.StatusOK, models.Response{ Success: true, @@ -106,8 +101,10 @@ func Profile(c *gin.Context) { UserName: user.(models.User).UserName, AvatarLink: user.(models.User).AvatarLink, CountryCode: user.(models.User).CountryCode, - ScoresSP: scoresSP, - ScoresMP: scoresMP, + Titles: user.(models.User).Titles, + Links: models.Links{}, + Rankings: ProfileRankings{}, + Records: ProfileRecords{}, }, }) return diff --git a/backend/database/init.sql b/backend/database/init.sql index 11d4944..25de872 100644 --- a/backend/database/init.sql +++ b/backend/database/init.sql @@ -3,6 +3,10 @@ CREATE TABLE users ( user_name TEXT NOT NULL, avatar_link TEXT NOT NULL, country_code CHAR(2) NOT NULL, + p2sr TEXT NOT NULL DEFAULT '-', + steam TEXT NOT NULL DEFAULT '-', + youtube TEXT NOT NULL DEFAULT '-', + twitch TEXT NOT NULL DEFAULT '-', created_at TIMESTAMP NOT NULL DEFAULT now(), updated_at TIMESTAMP NOT NULL DEFAULT now(), PRIMARY KEY (steam_id) @@ -117,9 +121,16 @@ CREATE TABLE records_mp ( ); CREATE TABLE titles ( - user_id TEXT, + id SERIAL, title_name TEXT NOT NULL, - PRIMARY KEY (user_id), + title_color CHAR(6) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE user_titles ( + title_id INT NOT NULL, + user_id TEXT NOT NULL, + FOREIGN KEY (title_id) REFERENCES titles(id), FOREIGN KEY (user_id) REFERENCES users(steam_id) ); diff --git a/backend/middleware/auth.go b/backend/middleware/auth.go index 6a057da..e2c84fa 100644 --- a/backend/middleware/auth.go +++ b/backend/middleware/auth.go @@ -44,14 +44,19 @@ func CheckAuth(c *gin.Context) { return } // Get user titles from DB - user.Titles = []string{} - rows, _ := database.DB.Query(`SELECT title_name FROM titles t INNER JOIN user_titles ut ON t.id=ut.title_id WHERE ut.user_id = $1`, user.SteamID) + var moderator bool + user.Titles = []models.Title{} + rows, _ := database.DB.Query(`SELECT t.title_name, t.title_color FROM titles t INNER JOIN user_titles ut ON t.id=ut.title_id WHERE ut.user_id = $1`, user.SteamID) for rows.Next() { - var title string - rows.Scan(&title) + var title models.Title + rows.Scan(&title.Name, &title.Color) + if title.Name == "Moderator" { + moderator = true + } user.Titles = append(user.Titles, title) } c.Set("user", user) + c.Set("mod", moderator) c.Next() } else { c.Next() diff --git a/backend/models/models.go b/backend/models/models.go index e21ba6a..f124db5 100644 --- a/backend/models/models.go +++ b/backend/models/models.go @@ -25,7 +25,7 @@ type User struct { CountryCode string `json:"country_code"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` - Titles []string `json:"titles"` + Titles []Title `json:"titles"` } type UserShort struct { @@ -92,6 +92,18 @@ type Category struct { Name string `json:"name"` } +type Title struct { + Name string `json:"name"` + Color string `json:"color"` +} + +type Links struct { + P2SR string `json:"p2sr"` + Steam string `json:"stream"` + YouTube string `json:"youtube"` + Twitch string `json:"twitch"` +} + type RecordSP struct { RecordID int `json:"record_id"` Placement int `json:"placement"` -- cgit v1.2.3 From 12ce00fdcc24b9c4e710156e56469acf10a30c27 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Wed, 30 Aug 2023 17:14:41 +0300 Subject: fix: change disabled maps Former-commit-id: ed6aca7192bd4d142107983cf0cda5efc14e0609 --- backend/database/maps.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backend/database') diff --git a/backend/database/maps.sql b/backend/database/maps.sql index 50689e2..637d2c2 100644 --- a/backend/database/maps.sql +++ b/backend/database/maps.sql @@ -15,7 +15,7 @@ INSERT INTO maps(game_id, chapter_id, name, description, showcase, is_disabled) (1,2,'Laser Stairs','','',false), (1,2,'Dual Lasers','','',false), (1,2,'Laser Over Goo','','',false), -(1,2,'Catapult Intro','','',true), +(1,2,'Catapult Intro','','',false), (1,2,'Trust Fling','','',false), (1,2,'Pit Flings','','',false), (1,2,'Fizzler Intro','','',false), @@ -71,7 +71,7 @@ INSERT INTO maps(game_id, chapter_id, name, description, showcase, is_disabled) (1,9,'Finale 4','','',false), -- Portal 2 Cooperative -- 0 -(2,10,'Calibration','','',false), +(2,10,'Calibration','','',true), (2,10,'Hub','','',true), -- 1 (2,11,'Doors','','',false), -- cgit v1.2.3 From 69c5423f7954b641109166e03ad0ab174b3d55c6 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 2 Sep 2023 11:09:42 +0300 Subject: feat: testing logging system (#55) Former-commit-id: d8c5fda30ab08b42218aead1febdf83200948763 --- backend/api/routes.go | 2 + backend/database/init.sql | 10 ++++ backend/handlers/login.go | 4 ++ backend/handlers/logs.go | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 backend/handlers/logs.go (limited to 'backend/database') diff --git a/backend/api/routes.go b/backend/api/routes.go index 4dd8660..ac622d4 100644 --- a/backend/api/routes.go +++ b/backend/api/routes.go @@ -36,5 +36,7 @@ func InitRoutes(router *gin.Engine) { v1.GET("/games", handlers.FetchGames) v1.GET("/games/:id", handlers.FetchChapters) v1.GET("/chapters/:id", handlers.FetchChapterMaps) + v1.GET("/logs/score", handlers.ScoreLogs) + v1.GET("/logs/mod", CheckAuth, handlers.ModLogs) } } diff --git a/backend/database/init.sql b/backend/database/init.sql index 25de872..abace5c 100644 --- a/backend/database/init.sql +++ b/backend/database/init.sql @@ -139,3 +139,13 @@ CREATE TABLE countries ( country_name TEXT NOT NULL, PRIMARY KEY (country_code) ); + +CREATE TABLE logs ( + id SERIAL, + user_id TEXT NOT NULL, + type TEXT NOT NULL, + description TEXT NOT NULL, + date TIMESTAMP NOT NULL DEFAULT now(), + PRIMARY KEY (id), + FOREIGN KEY (user_id) REFERENCES users(steam_id) +); \ No newline at end of file diff --git a/backend/handlers/login.go b/backend/handlers/login.go index 4b151c2..80f697e 100644 --- a/backend/handlers/login.go +++ b/backend/handlers/login.go @@ -38,6 +38,7 @@ func Login(c *gin.Context) { default: steamID, err := openID.ValidateAndGetId() if err != nil { + CreateLog(steamID, LogTypeLogin, LogDescriptionLoginFailValidate) c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) return } @@ -48,6 +49,7 @@ func Login(c *gin.Context) { if checkSteamID == 0 { user, err := GetPlayerSummaries(steamID, os.Getenv("API_KEY")) if err != nil { + CreateLog(steamID, LogTypeLogin, LogDescriptionLoginFailSummary) c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) return } @@ -77,10 +79,12 @@ func Login(c *gin.Context) { // Sign and get the complete encoded token as a string using the secret tokenString, err := token.SignedString([]byte(os.Getenv("SECRET_KEY"))) if err != nil { + CreateLog(steamID, LogTypeLogin, LogDescriptionLoginFailToken) c.JSON(http.StatusBadRequest, models.ErrorResponse("Failed to generate token.")) return } c.SetCookie("token", tokenString, 3600*24*30, "/", "", true, true) + CreateLog(steamID, LogTypeLogin, LogDescriptionLoginSuccess) c.Redirect(http.StatusTemporaryRedirect, "/") // c.JSON(http.StatusOK, models.Response{ // Success: true, diff --git a/backend/handlers/logs.go b/backend/handlers/logs.go new file mode 100644 index 0000000..2b5713d --- /dev/null +++ b/backend/handlers/logs.go @@ -0,0 +1,114 @@ +package handlers + +import ( + "fmt" + "net/http" + + "github.com/gin-gonic/gin" + "github.com/pektezol/leastportalshub/backend/database" + "github.com/pektezol/leastportalshub/backend/models" +) + +const ( + LogTypeMod string = "Mod" + LogTypeScore string = "Score" + LogTypeLogin string = "Login" + + LogDescriptionLoginSuccess string = "Success" + LogDescriptionLoginFailToken string = "TokenFail" + LogDescriptionLoginFailValidate string = "ValidateFail" + LogDescriptionLoginFailSummary string = "SummaryFail" +) + +type Log struct { + User models.UserShort `json:"user"` + Type string `json:"type"` + Description string `json:"description"` +} + +type LogsResponse struct { + Logs []LogsResponseDetails `json:"logs"` +} + +type LogsResponseDetails struct { + User models.UserShort `json:"user"` + Log string `json:"detail"` +} + +func ModLogs(c *gin.Context) { + mod, exists := c.Get("mod") + if !exists || !mod.(bool) { + c.JSON(http.StatusUnauthorized, models.ErrorResponse("Insufficient permissions.")) + return + } + response := LogsResponse{Logs: []LogsResponseDetails{}} + sql := `SELECT u.user_name, l.user_id, l.type, l.description + FROM logs l INNER JOIN users u ON l.user_id = u.steam_id WHERE type != 'Score'` + rows, err := database.DB.Query(sql) + if err != nil { + c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) + return + } + for rows.Next() { + log := Log{} + err = rows.Scan(log.User.UserName, log.User.SteamID, log.Type, log.Description) + if err != nil { + c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) + return + } + detail := fmt.Sprintf("%s.%s", log.Type, log.Description) + response.Logs = append(response.Logs, LogsResponseDetails{ + User: models.UserShort{ + SteamID: log.User.SteamID, + UserName: log.User.UserName, + }, + Log: detail, + }) + } + c.JSON(http.StatusOK, models.Response{ + Success: true, + Message: "Successfully retrieved logs.", + Data: response, + }) +} + +func ScoreLogs(c *gin.Context) { + response := LogsResponse{Logs: []LogsResponseDetails{}} + sql := `SELECT u.user_name, l.user_id, l.type, l.description + FROM logs l INNER JOIN users u ON l.user_id = u.steam_id WHERE type = 'Score'` + rows, err := database.DB.Query(sql) + if err != nil { + c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) + return + } + for rows.Next() { + log := Log{} + err = rows.Scan(log.User.UserName, log.User.SteamID, log.Type, log.Description) + if err != nil { + c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) + return + } + detail := fmt.Sprintf("%s.%s", log.Type, log.Description) + response.Logs = append(response.Logs, LogsResponseDetails{ + User: models.UserShort{ + SteamID: log.User.SteamID, + UserName: log.User.UserName, + }, + Log: detail, + }) + } + c.JSON(http.StatusOK, models.Response{ + Success: true, + Message: "Successfully retrieved score logs.", + Data: response, + }) +} + +func CreateLog(user_id string, log_type string, log_description string) (err error) { + sql := `INSERT INTO logs (user_id, "type", description) VALUES($1, $2, $3)` + _, err = database.DB.Exec(sql) + if err != nil { + return err + } + return nil +} -- cgit v1.2.3