Advertisement
YuvalGai

Untitled

Sep 8th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.68 KB | None | 0 0
  1.  
  2. select
  3. INTERVAL_DATE
  4. ,ARENA_GROUP
  5. ,CURRENT_ARENA_INDEX
  6. ,TROPHY_GROUP
  7. ,TROPHY_GROUP_2
  8. ,ARENA
  9. ,ARENA_TIERS
  10. ,ARENA_RANKS
  11. ,LTV_GROUP
  12. ,IS_PAYER
  13. ,LO_ENTRY_TROPHY_MODE
  14. ,LO_ENTRY_TROPHY_GAIN
  15. ,LO_ENTRY_TROPHY_LOSS
  16. ,LO_ENTRY_MODIFIER_TYPE1
  17. ,PVP_MODE
  18. ,MATCH_TYPE_ID
  19. ,MATCH_TYPE
  20. ,MATCH_MODE
  21. ,MODIFIER_1
  22. ,MODIFIER_2
  23. ,MATCH_MODIFIER_3
  24. ,MATCH_SUB_TYPE
  25. ,RESOURCE_SUB_TYPE
  26. ,BOOSTER_NAME
  27. ,RIVAL_RESOURCE_SUB_TYPE
  28. ,RUMBLE_SIZE
  29. ,RIVAL_BOOSTER_NAME
  30. ,ROUNDS_CNT
  31. ,IS_PRIVATE
  32. ,IS_MC_MATCH
  33. ,IS_RIVAL_BOT
  34. ,TURN_INDEX
  35. ,APP_VERSION
  36. ,SOLO_TYPE
  37. ,MUTATION_OPTIONS
  38. ,MUTATIONS_PICK
  39. ,ROUNDS
  40. ,MATCH_SCORE
  41. ,RIVAL_MATCH_SCORE
  42. ,MATCH_DURATION_MINS
  43. ,BOOSTER_ACTIVATIONS
  44. ,RESYNCS
  45. ,RESYNC_MATCHES
  46. ,ERROR_RESYNCS
  47. ,ERROR_RESYNC_MATCHES
  48. ,CONCEDED_MATCHES
  49. ,CONCEDED_MATCHES_1_10
  50. ,CONCEDED_MATCHES_10_60
  51. ,CONCEDED_MATCHES_AFTER_60SEC
  52. ,OOT
  53. ,OOT_MATCHES
  54. ,MATCHES
  55. ,USERS
  56. ,WINS
  57. ,AVG_MATCH_RANK
  58. ,AGIANST_BOT_MATCHES
  59. ,TOTAL_SECONDS_PLAYED_IN_SEGMENT
  60. ,TOTAL_BOOSTER_ACTIVATIONS_IN_SEGMENT
  61. ,TOTAL_FOURS
  62. ,TOTAL_FIVES
  63. ,MATCH_MAKING_FOUND_TIME
  64. ,PICK_NM
  65. ,PICKS
  66. ,MATCH_ID
  67. ,USER_ID
  68. ,to_timestamp(INTERVAL_DATE) as LAST_UPDATED_DT
  69. ,current_timestamp() as DW_INSERT_DT
  70. from
  71. (
  72. SELECT
  73. match_end_date AS INTERVAL_DATE,
  74. match_id,
  75. user_id,
  76. arena_group,
  77. current_arena_index,
  78. CASE
  79. WHEN trophies_cnt < 1500 THEN '0-1500'
  80. WHEN trophies_cnt < 3800 THEN '1500-3800'
  81. WHEN trophies_cnt < 8000 THEN '3800-8000'
  82. WHEN trophies_cnt < 17000 THEN '8000-17000'
  83. WHEN trophies_cnt < 30000 THEN '17000-30000'
  84. ELSE '30000+'
  85. END AS trophy_group,
  86. CASE
  87. WHEN trophies_cnt < 125 THEN '0-125'
  88. WHEN trophies_cnt < 1400 THEN '125-1400'
  89. WHEN trophies_cnt < 2000 THEN '1400-2000'
  90. WHEN trophies_cnt < 3800 THEN '2000-3800'
  91. WHEN trophies_cnt < 4500 THEN '3800-4500'
  92. WHEN trophies_cnt < 5500 THEN '4500-5500'
  93. WHEN trophies_cnt < 7000 THEN '5500-7000'
  94. WHEN trophies_cnt < 10000 THEN '7000-10000'
  95. WHEN trophies_cnt < 13000 THEN '10000-13000'
  96. WHEN trophies_cnt < 16000 THEN '13000-16000'
  97. WHEN trophies_cnt < 20000 THEN '16000-20000'
  98. WHEN trophies_cnt < 30000 THEN '20000-30000'
  99. WHEN trophies_cnt >= 30000 THEN '30000+'
  100. END AS trophy_group_2,
  101. case when trophies_cnt<50 then '0_spotlight_Stars'
  102. when trophies_cnt<300 then '1_Jungle_Jam'
  103. when trophies_cnt<500 then '2_Dustville_Duel'
  104. when trophies_cnt<800 then '3_FireWorks_Festival'
  105. when trophies_cnt<1100 then '4_Crystal_cave'
  106. when trophies_cnt<1400 then '5_Laser_Matches'
  107. when trophies_cnt<1700 then '6_Funcky_Tiles'
  108. when trophies_cnt<2000 then '7_Plunder_Pirates'
  109. when trophies_cnt<2300 then '8_Sugar_Rush'
  110. when trophies_cnt<2600 then '9_Cloud_City'
  111. when trophies_cnt<2900 then '10_Vegas_Views'
  112. when trophies_cnt<3200 then '11_Bombs_Away'
  113. when trophies_cnt<3500 then '12_Tribal_Trouble'
  114. when trophies_cnt<3800 then '13_Color_Crystals'
  115. when trophies_cnt<4500 then '14_Challenger_1'
  116. when trophies_cnt<5500 then '15_Challenger_2'
  117. when trophies_cnt<7000 then '16_Challenger_3'
  118. when trophies_cnt<10000 then '17_Master_1'
  119. when trophies_cnt<13000 then '18_Master_2'
  120. when trophies_cnt<16000 then '19_Master_3'
  121. when trophies_cnt<20000 then '20_Grand_Master_1'
  122. when trophies_cnt<25000 then '21_Grand_Master_2'
  123. when trophies_cnt<30000 then '22_Grand_Master_3'
  124.  
  125. when trophies_cnt<32000 then '23_Legend_1'
  126. when trophies_cnt<34000 then '24_Legend_2'
  127. when trophies_cnt<36000 then '25_Legend_3'
  128. when trophies_cnt<38000 then '26_Legend_4'
  129. when trophies_cnt<40000 then '27_Legend_5'
  130.  
  131. when trophies_cnt<43000 then '28_Supreme_Legend_1'
  132. when trophies_cnt<46000 then '29_Supreme_Legend_2'
  133. when trophies_cnt<50000 then '30_Supreme_Legend_3'
  134. when trophies_cnt<55000 then '31_Supreme_Legend_4'
  135. when trophies_cnt<60000 then '32_Supreme_Legend_5'
  136.  
  137. when trophies_cnt<70000 then '33_Ultimate_Legend_1'
  138. when trophies_cnt<85000 then '34_Ultimate_Legend_2'
  139. when trophies_cnt<105000 then '35_Ultimate_Legend_3'
  140. when trophies_cnt<130000 then '36_Ultimate_Legend_4'
  141. else '37_Ultimate_Legend_5' end as arena,
  142.  
  143. case when trophies_cnt<3800 then '00_Studio'
  144. when trophies_cnt<7000 then '01_Challenger'
  145. when trophies_cnt<16000 then '02_Master'
  146. when trophies_cnt<30000 then '03_Grand_Master'
  147. when trophies_cnt<40000 then '04_Legends'
  148. when trophies_cnt<43000 then '05_Supreme_Legend'
  149. else '06_Ultimate_Legend' end as arena_tiers,
  150.  
  151. case when trophies_cnt<3800 then '00_Studio'
  152. when trophies_cnt<30000 then '01_Masters'
  153. else '03_Legends_league' end as arena_ranks,
  154. ltv_group,
  155. is_payer,
  156. lo_entry_trophy_mode,
  157. lo_entry_trophy_gain,
  158. lo_entry_trophy_loss,
  159. lo_entry_modifier_type1,
  160. pvp_mode,
  161. MATCH_TYPE_ID,
  162. CASE
  163. WHEN is_random_mixer = TRUE THEN 'Daily_Random_Mixer'
  164. ELSE match_type
  165. END AS MATCH_TYPE,
  166. MATCH_MODE,
  167. MODIFIER_1,
  168. MODIFIER_2,
  169. match_modifier_3,
  170. concat(
  171. MATCH_SUB_TYPE,
  172. '-',
  173. MATCH_MODE,
  174. '+',
  175. MODIFIER_1,
  176. '-',
  177. MODIFIER_2,
  178. '-',
  179. match_modifier_3
  180. ) AS match_sub_type,
  181. RESOURCE_SUB_TYPE,
  182. BOOSTER_NAME,
  183. RIVAL_RESOURCE_SUB_TYPE,
  184. RUMBLE_SIZE,
  185. CASE
  186. WHEN PVP_MODE NOT LIKE 'PvP' THEN 'No Rival(Solo/Rumble)'
  187. ELSE RIVAL_BOOSTER_NAME
  188. END RIVAL_BOOSTER_NAME,
  189. rounds_cnt,
  190. is_private,
  191. is_mc_match,
  192. is_rival_bot,
  193. turn_index,
  194. app_version,
  195. CASE
  196. when LO_EVENT_ID like '%-mc-%' then 'MC'
  197. when LO_EVENT_ID like '%cosmic%' then 'cosmic'
  198. when LO_EVENT_ID like '%rally%' then 'rally'
  199. when LO_EVENT_ID like '%heist%' then 'heist'
  200. end Solo_Type,
  201. mutation_options,
  202. mutations_pick,
  203. to_varchar(mutations_pick [0]) pick0,
  204. to_varchar(mutations_pick [1]) pick1,
  205. to_varchar(mutations_pick [2]) pick2,
  206. to_varchar(mutations_pick [3]) pick3,
  207. to_varchar(mutations_pick [4]) pick4,
  208. to_varchar(mutations_pick [5]) pick5,
  209. to_varchar(mutations_pick [6]) pick6,
  210. to_varchar(mutations_pick [7]) pick7,
  211. to_varchar(mutations_pick [8]) pick8,
  212. to_varchar(mutations_pick [9]) pick9,
  213. SUM(ROUNDS_CNT) AS ROUNDS,
  214. SUM(MATCH_SCORE) AS MATCH_SCORE,
  215. SUM(rival_MATCH_SCORE) AS rival_MATCH_SCORE,
  216. SUM(MATCH_DURATION_SEC) / 60 AS MATCH_DURATION_MINS,
  217. SUM(ABILITY_ACTIVATED_CNT) AS BOOSTER_ACTIVATIONS,
  218. SUM(ifnull(CS_RESYNCS, 0)) AS RESYNCS,
  219. COUNT(
  220. DISTINCT CASE
  221. WHEN CS_RESYNCS > 0 THEN concat(match_id, user_id, rematch_cnt)
  222. END
  223. ) AS RESYNC_MATCHES,
  224. SUM(ifnull(ERROR_RESYNCS, 0)) AS ERROR_RESYNCS,
  225. COUNT(
  226. DISTINCT CASE
  227. WHEN ERROR_RESYNCS > 0 THEN concat(match_id, user_id, rematch_cnt)
  228. END
  229. ) AS ERROR_RESYNC_MATCHES,
  230. SUM(
  231. CASE
  232. WHEN is_conceded = 1
  233. AND is_won = 0
  234. AND match_duration_sec = 0 THEN 1
  235. END
  236. ) AS CONCEDED_MATCHES,
  237. SUM(
  238. CASE
  239. WHEN is_conceded = 1
  240. AND is_won = 0
  241. AND match_duration_sec BETWEEN 1
  242. AND 10 THEN 1
  243. END
  244. ) AS CONCEDED_MATCHES_1_10,
  245. SUM(
  246. CASE
  247. WHEN is_conceded = 1
  248. AND is_won = 0
  249. AND match_duration_sec BETWEEN 10
  250. AND 60 THEN 1
  251. END
  252. ) AS CONCEDED_MATCHES_10_60,
  253. SUM(
  254. CASE
  255. WHEN is_conceded = 1
  256. AND is_won = 0
  257. AND match_duration_sec > 60 THEN 1
  258. END
  259. ) AS CONCEDED_MATCHES_AFTER_60sec,
  260. SUM(ifnull(rival_played_out_of_time, 0)) AS OOT,
  261. COUNT(
  262. DISTINCT CASE
  263. WHEN rival_played_out_of_time > 0 THEN concat(match_id, user_id, rematch_cnt)
  264. END
  265. ) AS OOT_MATCHES,
  266. COUNT(DISTINCT concat(match_id, user_id, rematch_cnt)) AS MATCHES,
  267. count(distinct user_id) users,
  268. SUM(is_won) AS wins,
  269. AVG(MATCH_RANK) AS AVG_MATCH_RANK,
  270. sum(is_rival_bot) AS agianst_bot_MATCHES,
  271. sum(MATCH_DURATION_SEC) as total_seconds_played_in_segment,
  272. sum(ability_activated_cnt) as total_booster_activations_in_segment,
  273. sum(four_matched_cnt) as total_fours,
  274. sum(five_matched_cnt) as total_fives,
  275. sum(match_making_found_time) as match_making_found_time
  276. FROM
  277. MATCH_MASTERS.PROD.F_USER_MATCH a
  278. left join (
  279. SELECT
  280. *
  281. FROM
  282. (
  283. SELECT
  284. *,CASE
  285. WHEN lo_entry_ts IS NULL THEN lo_entry_update_ts
  286. ELSE lo_entry_ts
  287. END lo_entry_ts2,
  288. ROW_NUMBER() OVER (
  289. partition BY lo_entry_id
  290. ORDER BY
  291. lo_entry_ts2 DESC
  292. ) rn
  293. FROM
  294. MATCH_MASTERS.PROD.F_LIVEOPS_CALENDAR
  295. )
  296. WHERE 1=1
  297. AND rn = 1
  298. AND date(DERIVED_TSTAMP) >= current_date-91
  299. ) b on a.calendar_entry_id = b.lo_entry_id
  300. WHERE
  301. is_bot = FALSE
  302. AND MATCH_END_DATE >= current_date-91
  303. AND match_mode = 'mutation-lab-pvp-mode'
  304. GROUP BY ALL
  305. )
  306.  
  307. UNPIVOT(
  308. picks FOR pick_nm IN (
  309. pick0,
  310. pick1,
  311. pick2,
  312. pick3,
  313. pick4,
  314. pick5,
  315. pick6,
  316. pick7,
  317. pick8,
  318. pick9
  319. ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement