Skip to content

Commit

Permalink
Merge pull request #60 from TeoMeWhy/feat/dota
Browse files Browse the repository at this point in the history
Feat/dota
  • Loading branch information
TeoCalvo authored Aug 17, 2023
2 parents 689f299 + 1317a7a commit cd82867
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/03.silver/dota/feature_store/etl/players_hero.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
WITH tb_matches_players AS (
SELECT
*
FROM silver.dota.matches_players
WHERE dtMatch >= '{date}' - INTERVAL {window} DAY
AND dtMatch < '{date}'
),

tb_players_hero AS (
SELECT
'{date}' AS dtReference,
idPlayer,
idHero,
count(distinct idMatch) AS nrFreqPlayerHero,
avg(flWin) AS pctWinRatePlayerHero,
avg(nrGoldMinute) AS nrGoldMinutePlayerHero,
avg(nrXpMinute) AS nrXpMinutePlayerHero
FROM tb_matches_players
GROUP BY dtReference, idPlayer, idHero
),

tb_hero AS (
SELECT idHero,
avg(flWin) AS pctWinRateHero,
avg(nrGoldMinute) AS nrGoldMinuteHero,
avg(nrXpMinute) AS nrXpMinuteHero
FROM tb_matches_players
GROUP BY idHero
)

SELECT t1.*,
t1.pctWinRatePlayerHero / t2.pctWinRateHero AS pctRateWinRatePlayerHero,
t1.nrGoldMinutePlayerHero / t2.nrGoldMinuteHero AS pctRateGoldMinutePlayerHero,
t1.nrXpMinutePlayerHero / t2.nrXpMinuteHero AS pctRateXpMinutePlayerHero

FROM tb_players_hero AS t1

LEFT JOIN tb_hero AS t2
ON t1.idHero = t2.idHero
75 changes: 75 additions & 0 deletions src/06.workflows/data4u_dota.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,81 @@
"existing_cluster_id": "0809-155233-nc569ju7",
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "fs_players_hero_30",
"depends_on": [
{
"task_key": "silver_matches_players"
}
],
"notebook_task": {
"notebook_path": "src/03.silver/dota/feature_store/fs_ingestao",
"base_parameters": {
"table": "players_hero",
"window": "30",
"description": "Feature Store de jogadores profissionais com suas estatísticas sumarizadas em nível de herói (D30)",
"id_fields": "dtReference,idPlayer,idHero",
"partition_fields": "dtReference",
"date_start": "{{start_date}}",
"date_stop": "{{start_date}}",
"monthly": "False"
},
"source": "GIT"
},
"existing_cluster_id": "0809-155233-nc569ju7",
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "fs_players_hero_90",
"depends_on": [
{
"task_key": "silver_matches_players"
}
],
"notebook_task": {
"notebook_path": "src/03.silver/dota/feature_store/fs_ingestao",
"base_parameters": {
"table": "players_hero",
"window": "90",
"description": "Feature Store de jogadores profissionais com suas estatísticas sumarizadas em nível de herói (D90)",
"id_fields": "dtReference,idPlayer,idHero",
"partition_fields": "dtReference",
"date_start": "{{start_date}}",
"date_stop": "{{start_date}}",
"monthly": "False"
},
"source": "GIT"
},
"existing_cluster_id": "0809-155233-nc569ju7",
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "fs_players_hero_180",
"depends_on": [
{
"task_key": "silver_matches_players"
}
],
"notebook_task": {
"notebook_path": "src/03.silver/dota/feature_store/fs_ingestao",
"base_parameters": {
"table": "players_hero",
"window": "180",
"description": "Feature Store de jogadores profissionais com suas estatísticas sumarizadas em nível de herói (D180)",
"id_fields": "dtReference,idPlayer,idHero",
"partition_fields": "dtReference",
"date_start": "{{start_date}}",
"date_stop": "{{start_date}}",
"monthly": "False"
},
"source": "GIT"
},
"existing_cluster_id": "0809-155233-nc569ju7",
"timeout_seconds": 0,
"email_notifications": {}
}
],
"git_source": {
Expand Down

0 comments on commit cd82867

Please sign in to comment.