fixed Account receivables report.

Improved MANY insertion times by rolling up large insertions into large generated queries (sorta dangerous)
master
dtookey 4 years ago
parent 5e28da9c17
commit 3a48e7e033

@ -50,6 +50,11 @@ type (
} }
) )
func (ar arReportInputLine) ToQueryBlock() string {
companyName := strings.ReplaceAll(ar.AccountName, "'", "\\'")
return fmt.Sprintf("('%s',%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,'%s','%s')", companyName, ar.Current, ar.Thirty, ar.Sixty, ar.Ninety, ar.OverNinety, ar.TotalForPeriod, ar.ReportNameInfo.DateString, ar.ReportNameInfo.Region)
}
func GenerateArAgingReport(pathlike string) { func GenerateArAgingReport(pathlike string) {
connector := &db.ConnectorGeneric{} connector := &db.ConnectorGeneric{}
res := make([]*arReportInputLine, 0, 5000) res := make([]*arReportInputLine, 0, 5000)
@ -65,8 +70,11 @@ func GenerateArAgingReport(pathlike string) {
res = append(res, part) res = append(res, part)
} }
} }
tableWipe := db.NewRunner("create-mercury-arReports-table.sql", db.MercuryDatabaseName)
connector.ExecuteSqlScript(tableWipe)
log.Println("Updating database") log.Println("Updating database")
db.BulkUpdate[arReportInputLine](connector, "mercury", "update-mercury-arReport.sql", &res, arReportInputLineMappingFunction) db.BlockUpdate[arReportInputLine](connector, db.MercuryDatabaseName, "update-mercury-arReport.sql", &res)
log.Println("Updates finished.") log.Println("Updates finished.")
} }

@ -12,17 +12,17 @@ import (
func main() { func main() {
s := time.Now() s := time.Now()
//processQBARReport() processQBARReport()
//updateInsightData() //updateInsightData()
test() updateTelecom()
f := time.Now() f := time.Now()
log.Println(f.Sub(s).Milliseconds()) log.Println(f.Sub(s).Milliseconds())
} }
func test() { func updateTelecom() {
icx := mercury.NewInterconnect() icx := mercury.NewInterconnect()
icx.PseudoInit() icx.PseudoInit()
icx.InsightDBConnector.ExecuteSqlScript(db.NewRunner("create-mercury-telecomVoice-table.sql", db.MercuryDatabaseName)) icx.InsightDBConnector.ExecuteSqlScript(db.NewRunner("create-mercury-telecomVoice-table.sql", db.MercuryDatabaseName))

@ -1,2 +1,2 @@
INSERT INTO mercury.ar_aging_report (AccountName, Current, Thirty, Sixty, Ninety, OverNinety, Total_for_Period, DateExported, Region) INSERT INTO mercury.ar_aging_report (AccountName, Current, Thirty, Sixty, Ninety, OverNinety, Total_for_Period, DateExported, Region)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); VALUES %s;
Loading…
Cancel
Save