Fix first user metric aggregate insert
This commit is contained in:
parent
69ecc78db0
commit
d67220aa5e
@ -107,8 +107,10 @@ func (r *MySQLRepository) applyDailyUserGroup(ctx context.Context, tx *sql.Tx, k
|
|||||||
_, err = tx.ExecContext(ctx, `
|
_, err = tx.ExecContext(ctx, `
|
||||||
INSERT INTO country_dashboard_daily_metric (
|
INSERT INTO country_dashboard_daily_metric (
|
||||||
stat_date, date_number, sys_origin, country_code, country_name, refreshed_at
|
stat_date, date_number, sys_origin, country_code, country_name, refreshed_at
|
||||||
) VALUES (?, ?, ?, ?, ?, NOW())
|
, `+column+`
|
||||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + ?, country_name = VALUES(country_name), refreshed_at = NOW()
|
) VALUES (?, ?, ?, ?, ?, NOW(), ?)
|
||||||
|
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + VALUES(`+column+`),
|
||||||
|
country_name = VALUES(country_name), refreshed_at = NOW()
|
||||||
`, key.day, dateNumber(key.day), key.sysOrigin, key.countryCode, key.countryName, inserted)
|
`, key.day, dateNumber(key.day), key.sysOrigin, key.countryCode, key.countryName, inserted)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -127,8 +129,10 @@ func (r *MySQLRepository) applyPeriodUserGroup(ctx context.Context, tx *sql.Tx,
|
|||||||
INSERT INTO country_dashboard_period_metric (
|
INSERT INTO country_dashboard_period_metric (
|
||||||
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
||||||
sys_origin, country_code, country_name, refreshed_at
|
sys_origin, country_code, country_name, refreshed_at
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
|
, `+column+`
|
||||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + ?, country_name = VALUES(country_name), refreshed_at = NOW()
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)
|
||||||
|
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + VALUES(`+column+`),
|
||||||
|
country_name = VALUES(country_name), refreshed_at = NOW()
|
||||||
`, key.periodType, key.periodKey, key.statTimezone, key.periodName, ptrOrNil(key.startDate), ptrOrNil(key.endDate),
|
`, key.periodType, key.periodKey, key.statTimezone, key.periodName, ptrOrNil(key.startDate), ptrOrNil(key.endDate),
|
||||||
key.sysOrigin, key.countryCode, key.countryName, inserted)
|
key.sysOrigin, key.countryCode, key.countryName, inserted)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@ -23,8 +23,10 @@ func (r *MySQLRepository) applyDailyUserMetric(ctx context.Context, tx *sql.Tx,
|
|||||||
_, err = tx.ExecContext(ctx, `
|
_, err = tx.ExecContext(ctx, `
|
||||||
INSERT INTO country_dashboard_daily_metric (
|
INSERT INTO country_dashboard_daily_metric (
|
||||||
stat_date, date_number, sys_origin, country_code, country_name, refreshed_at
|
stat_date, date_number, sys_origin, country_code, country_name, refreshed_at
|
||||||
) VALUES (?, ?, ?, ?, ?, NOW())
|
, `+column+`
|
||||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + 1, country_name = VALUES(country_name), refreshed_at = NOW()
|
) VALUES (?, ?, ?, ?, ?, NOW(), 1)
|
||||||
|
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + VALUES(`+column+`),
|
||||||
|
country_name = VALUES(country_name), refreshed_at = NOW()
|
||||||
`, day, dashboard.DateNumber(day), c.SysOrigin, c.Country.Code, c.Country.Name)
|
`, day, dashboard.DateNumber(day), c.SysOrigin, c.Country.Code, c.Country.Name)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -45,8 +47,10 @@ func (r *MySQLRepository) applyPeriodUserMetric(ctx context.Context, tx *sql.Tx,
|
|||||||
INSERT INTO country_dashboard_period_metric (
|
INSERT INTO country_dashboard_period_metric (
|
||||||
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
||||||
sys_origin, country_code, country_name, refreshed_at
|
sys_origin, country_code, country_name, refreshed_at
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
|
, `+column+`
|
||||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + 1, country_name = VALUES(country_name), refreshed_at = NOW()
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), 1)
|
||||||
|
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + VALUES(`+column+`),
|
||||||
|
country_name = VALUES(country_name), refreshed_at = NOW()
|
||||||
`, window.Type, window.Key, statTimezone, window.Name, window.StartDate, window.EndDate,
|
`, window.Type, window.Key, statTimezone, window.Name, window.StartDate, window.EndDate,
|
||||||
c.SysOrigin, c.Country.Code, c.Country.Name)
|
c.SysOrigin, c.Country.Code, c.Country.Name)
|
||||||
return err
|
return err
|
||||||
@ -129,9 +133,9 @@ INSERT IGNORE INTO country_dashboard_game_period_user_metric (
|
|||||||
_, err = tx.ExecContext(ctx, `
|
_, err = tx.ExecContext(ctx, `
|
||||||
INSERT INTO country_dashboard_game_period_metric (
|
INSERT INTO country_dashboard_game_period_metric (
|
||||||
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
||||||
sys_origin, country_code, country_name, game_provider, game_id, game_name, refreshed_at
|
sys_origin, country_code, country_name, game_provider, game_id, game_name, user_count, refreshed_at
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, NOW())
|
||||||
ON DUPLICATE KEY UPDATE user_count = user_count + 1, country_name = VALUES(country_name),
|
ON DUPLICATE KEY UPDATE user_count = user_count + VALUES(user_count), country_name = VALUES(country_name),
|
||||||
game_name = VALUES(game_name), refreshed_at = NOW()
|
game_name = VALUES(game_name), refreshed_at = NOW()
|
||||||
`, window.Type, window.Key, statTimezone, window.Name, window.StartDate, window.EndDate,
|
`, window.Type, window.Key, statTimezone, window.Name, window.StartDate, window.EndDate,
|
||||||
c.SysOrigin, c.Country.Code, c.Country.Name, c.GameProvider, c.GameID, c.GameName)
|
c.SysOrigin, c.Country.Code, c.Country.Name, c.GameProvider, c.GameID, c.GameName)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user