fix calc percent of migration task
This commit is contained in:
parent
ad05f229af
commit
b447cc953e
|
@ -76,11 +76,17 @@ func (h *APIHandler) getDataMigrationTaskInfo(w http.ResponseWriter, req *http.R
|
||||||
for i, index := range taskConfig.Indices {
|
for i, index := range taskConfig.Indices {
|
||||||
indexName := index.Source.GetUniqueIndexName()
|
indexName := index.Source.GetUniqueIndexName()
|
||||||
count := indexState[indexName].IndexDocs
|
count := indexState[indexName].IndexDocs
|
||||||
percent := float64(count) / float64(index.Source.Docs) * 100
|
sourceDocs := indexState[indexName].SourceDocs
|
||||||
if percent > 100 {
|
var percent float64
|
||||||
|
if sourceDocs <= 0 {
|
||||||
percent = 100
|
percent = 100
|
||||||
|
}else{
|
||||||
|
percent = float64(count) / float64(sourceDocs) * 100
|
||||||
|
if percent > 100 {
|
||||||
|
percent = 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taskConfig.Indices[i].Source.Docs = indexState[indexName].SourceDocs
|
taskConfig.Indices[i].Source.Docs = sourceDocs
|
||||||
taskConfig.Indices[i].Target.Docs = count
|
taskConfig.Indices[i].Target.Docs = count
|
||||||
taskConfig.Indices[i].Percent = util.ToFixed(percent, 2)
|
taskConfig.Indices[i].Percent = util.ToFixed(percent, 2)
|
||||||
taskConfig.Indices[i].ErrorPartitions = indexState[indexName].ErrorPartitions
|
taskConfig.Indices[i].ErrorPartitions = indexState[indexName].ErrorPartitions
|
||||||
|
|
Loading…
Reference in New Issue