augmented import outputs and logging
This commit is contained in:
@@ -798,6 +798,7 @@ func ConferenceImport(ctxt ui.AmContext) (string, any) {
|
|||||||
ctxt.SetFrameTitle("Import Messages: " + conf.Name)
|
ctxt.SetFrameTitle("Import Messages: " + conf.Name)
|
||||||
return "framed", "conf_import.jet"
|
return "framed", "conf_import.jet"
|
||||||
}
|
}
|
||||||
|
start := time.Now()
|
||||||
f, err := importData.Open()
|
f, err := importData.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctxt.VarMap().Set("errorMessage", err.Error())
|
ctxt.VarMap().Set("errorMessage", err.Error())
|
||||||
@@ -808,6 +809,7 @@ func ConferenceImport(ctxt ui.AmContext) (string, any) {
|
|||||||
}
|
}
|
||||||
topics, posts, scroll, err := exports.VCIFImportMessages(ctxt.Ctx(), f, comm, conf, mode, ctxt.FormFieldIsSet("create"), ctxt.CurrentUser(), ctxt.RemoteIP())
|
topics, posts, scroll, err := exports.VCIFImportMessages(ctxt.Ctx(), f, comm, conf, mode, ctxt.FormFieldIsSet("create"), ctxt.CurrentUser(), ctxt.RemoteIP())
|
||||||
f.Close()
|
f.Close()
|
||||||
|
log.Infof("import messages operation completed in %v", time.Since(start))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctxt.VarMap().Set("errorMessage", err.Error())
|
ctxt.VarMap().Set("errorMessage", err.Error())
|
||||||
ctxt.VarMap().Set("confName", conf.Name)
|
ctxt.VarMap().Set("confName", conf.Name)
|
||||||
|
|||||||
+5
-1
@@ -340,12 +340,13 @@ func VCIFImportMessages(ctx context.Context, r io.Reader, comm *database.Communi
|
|||||||
}
|
}
|
||||||
// If we created the topic, the "zero post" was already posted, so skip it in this loop so we don't post it again.
|
// If we created the topic, the "zero post" was already posted, so skip it in this loop so we don't post it again.
|
||||||
skipPost := created
|
skipPost := created
|
||||||
|
topicOK := 0
|
||||||
|
topicFail := 0
|
||||||
for _, pdata := range tdata.Posts {
|
for _, pdata := range tdata.Posts {
|
||||||
if skipPost {
|
if skipPost {
|
||||||
skipPost = false
|
skipPost = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//
|
|
||||||
author, err := database.AmGetUserByName(ctx, pdata.Author, nil)
|
author, err := database.AmGetUserByName(ctx, pdata.Author, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
author = loader
|
author = loader
|
||||||
@@ -355,11 +356,14 @@ func VCIFImportMessages(ctx context.Context, r io.Reader, comm *database.Communi
|
|||||||
err = augmentPost(ctx, post, &pdata, comm, loader, ipaddr)
|
err = augmentPost(ctx, post, &pdata, comm, loader, ipaddr)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
topicOK++
|
||||||
postCount++
|
postCount++
|
||||||
} else {
|
} else {
|
||||||
|
topicFail++
|
||||||
scroll = append(scroll, fmt.Sprintf("Unable to post message %d to topic \"%s\": %v", pdata.Index, topic.Name, err))
|
scroll = append(scroll, fmt.Sprintf("Unable to post message %d to topic \"%s\": %v", pdata.Index, topic.Name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scroll = append(scroll, fmt.Sprintf("In topic \"%s\": %d messages posted successfully, %d failed", topic.Name, topicOK, topicFail))
|
||||||
if created {
|
if created {
|
||||||
if tdata.Frozen {
|
if tdata.Frozen {
|
||||||
err = topic.SetFrozen(ctx, true, loader, comm, ipaddr)
|
err = topic.SetFrozen(ctx, true, loader, comm, ipaddr)
|
||||||
|
|||||||
@@ -787,6 +787,7 @@ func UserImport(ctxt ui.AmContext) (string, any) {
|
|||||||
return "framed", "import_users.jet"
|
return "framed", "import_users.jet"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
f, err := importData.Open()
|
f, err := importData.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctxt.VarMap().Set("errorMessage", err.Error())
|
ctxt.VarMap().Set("errorMessage", err.Error())
|
||||||
@@ -795,6 +796,7 @@ func UserImport(ctxt ui.AmContext) (string, any) {
|
|||||||
}
|
}
|
||||||
count, scroll, err := exports.VIUImportUserList(ctxt.Ctx(), f, ctxt.CurrentUser(), ctxt.RemoteIP())
|
count, scroll, err := exports.VIUImportUserList(ctxt.Ctx(), f, ctxt.CurrentUser(), ctxt.RemoteIP())
|
||||||
f.Close()
|
f.Close()
|
||||||
|
log.Infof("import users operation completed in %v", time.Since(start))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctxt.VarMap().Set("errorMessage", err.Error())
|
ctxt.VarMap().Set("errorMessage", err.Error())
|
||||||
ctxt.SetFrameTitle("Import User Accounts")
|
ctxt.SetFrameTitle("Import User Accounts")
|
||||||
|
|||||||
Reference in New Issue
Block a user