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)
|
||||
return "framed", "conf_import.jet"
|
||||
}
|
||||
start := time.Now()
|
||||
f, err := importData.Open()
|
||||
if err != nil {
|
||||
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())
|
||||
f.Close()
|
||||
log.Infof("import messages operation completed in %v", time.Since(start))
|
||||
if err != nil {
|
||||
ctxt.VarMap().Set("errorMessage", err.Error())
|
||||
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.
|
||||
skipPost := created
|
||||
topicOK := 0
|
||||
topicFail := 0
|
||||
for _, pdata := range tdata.Posts {
|
||||
if skipPost {
|
||||
skipPost = false
|
||||
continue
|
||||
}
|
||||
//
|
||||
author, err := database.AmGetUserByName(ctx, pdata.Author, nil)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
if err == nil {
|
||||
topicOK++
|
||||
postCount++
|
||||
} 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("In topic \"%s\": %d messages posted successfully, %d failed", topic.Name, topicOK, topicFail))
|
||||
if created {
|
||||
if tdata.Frozen {
|
||||
err = topic.SetFrozen(ctx, true, loader, comm, ipaddr)
|
||||
|
||||
@@ -787,6 +787,7 @@ func UserImport(ctxt ui.AmContext) (string, any) {
|
||||
return "framed", "import_users.jet"
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
f, err := importData.Open()
|
||||
if err != nil {
|
||||
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())
|
||||
f.Close()
|
||||
log.Infof("import users operation completed in %v", time.Since(start))
|
||||
if err != nil {
|
||||
ctxt.VarMap().Set("errorMessage", err.Error())
|
||||
ctxt.SetFrameTitle("Import User Accounts")
|
||||
|
||||
Reference in New Issue
Block a user