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, `
|
||||
INSERT INTO country_dashboard_daily_metric (
|
||||
stat_date, date_number, sys_origin, country_code, country_name, refreshed_at
|
||||
) VALUES (?, ?, ?, ?, ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + ?, country_name = VALUES(country_name), refreshed_at = NOW()
|
||||
, `+column+`
|
||||
) 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)
|
||||
return err
|
||||
}
|
||||
@ -127,8 +129,10 @@ func (r *MySQLRepository) applyPeriodUserGroup(ctx context.Context, tx *sql.Tx,
|
||||
INSERT INTO country_dashboard_period_metric (
|
||||
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
||||
sys_origin, country_code, country_name, refreshed_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + ?, country_name = VALUES(country_name), refreshed_at = NOW()
|
||||
, `+column+`
|
||||
) 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.sysOrigin, key.countryCode, key.countryName, inserted)
|
||||
return err
|
||||
|
||||
@ -23,8 +23,10 @@ func (r *MySQLRepository) applyDailyUserMetric(ctx context.Context, tx *sql.Tx,
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
INSERT INTO country_dashboard_daily_metric (
|
||||
stat_date, date_number, sys_origin, country_code, country_name, refreshed_at
|
||||
) VALUES (?, ?, ?, ?, ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + 1, country_name = VALUES(country_name), refreshed_at = NOW()
|
||||
, `+column+`
|
||||
) 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)
|
||||
return err
|
||||
}
|
||||
@ -45,8 +47,10 @@ func (r *MySQLRepository) applyPeriodUserMetric(ctx context.Context, tx *sql.Tx,
|
||||
INSERT INTO country_dashboard_period_metric (
|
||||
period_type, period_key, stat_timezone, period_name, period_start_date, period_end_date,
|
||||
sys_origin, country_code, country_name, refreshed_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE `+column+` = `+column+` + 1, country_name = VALUES(country_name), refreshed_at = NOW()
|
||||
, `+column+`
|
||||
) 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,
|
||||
c.SysOrigin, c.Country.Code, c.Country.Name)
|
||||
return err
|
||||
@ -129,9 +133,9 @@ INSERT IGNORE INTO country_dashboard_game_period_user_metric (
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
INSERT INTO country_dashboard_game_period_metric (
|
||||
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
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE user_count = user_count + 1, country_name = VALUES(country_name),
|
||||
sys_origin, country_code, country_name, game_provider, game_id, game_name, user_count, refreshed_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, NOW())
|
||||
ON DUPLICATE KEY UPDATE user_count = user_count + VALUES(user_count), country_name = VALUES(country_name),
|
||||
game_name = VALUES(game_name), refreshed_at = NOW()
|
||||
`, 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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user