|
|
@@ -2,20 +2,37 @@ package friend_circle |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/md" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" |
|
|
|
"fmt" |
|
|
|
"testing" |
|
|
|
) |
|
|
|
|
|
|
|
// 创建朋友圈索引 |
|
|
|
func TestCreateFriendCircleIndex(t *testing.T) { |
|
|
|
es.Init("http://123.57.140.192:9200", "elastic", "fnuo123") |
|
|
|
err := es.CreateIndexIfNotExists(md.EggFriendCircleEsIndex, md.EggFriendCircleEsMapping) |
|
|
|
index := md.EggFriendCircleEsIndex |
|
|
|
err := es.CreateIndexIfNotExists(index, md.EggFriendCircleEsMapping) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
} |
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
// 删除朋友圈索引 |
|
|
|
func TestDeleteFriendCircleIndex(t *testing.T) { |
|
|
|
es.Init("http://123.57.140.192:9200", "elastic", "fnuo123") |
|
|
|
|
|
|
|
_, err := es.DeleteIndex(md.EggFriendCircleEsIndex) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
// 创建朋友圈点赞索引 |
|
|
|
func TestCreateFriendCircleCommentLikeIndex(t *testing.T) { |
|
|
|
es.Init("http://123.57.140.192:9200", "elastic", "fnuo123") |
|
|
|
for i := 0; i < 10; i++ { |
|
|
@@ -29,6 +46,22 @@ func TestCreateFriendCircleCommentLikeIndex(t *testing.T) { |
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
// 删除朋友圈点赞索引 |
|
|
|
func TestDeleteFriendCircleCommentLikeIndex(t *testing.T) { |
|
|
|
es.Init("http://123.57.140.192:9200", "elastic", "fnuo123") |
|
|
|
for i := 0; i < 10; i++ { |
|
|
|
index := fmt.Sprintf("%s%d", md.EggFriendCircleLikeEsIndex, i) |
|
|
|
_, err := es.DeleteIndex(index) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
// 创建朋友圈评论索引 |
|
|
|
func TestCreateFriendCircleCommentIndex(t *testing.T) { |
|
|
|
es.Init("http://123.57.140.192:9200", "elastic", "fnuo123") |
|
|
|
for i := 0; i < 10; i++ { |
|
|
@@ -42,7 +75,8 @@ func TestCreateFriendCircleCommentIndex(t *testing.T) { |
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
func TestDeleteIndex(t *testing.T) { |
|
|
|
// 删除朋友圈评论索引 |
|
|
|
func TestDeleteFriendCircleCommentIndex(t *testing.T) { |
|
|
|
es.Init("http://123.57.140.192:9200", "elastic", "fnuo123") |
|
|
|
for i := 0; i < 10; i++ { |
|
|
|
index := fmt.Sprintf("%s%d", md.EggFriendCircleCommentEsIndex, i) |
|
|
@@ -52,6 +86,49 @@ func TestDeleteIndex(t *testing.T) { |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
// 删除蛋蛋分记录 |
|
|
|
func TestDeleteEggScoreIndex(t *testing.T) { |
|
|
|
es.Init("http://120.55.48.175:9200", "elastic", "fnuo123") |
|
|
|
index := fmt.Sprintf("%s_%d", md.EggEnergyUserEggScoreEsAlias, 202451) |
|
|
|
_, err := es.DeleteIndex(index) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
return |
|
|
|
} |
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
// 创建临时蛋蛋分记录 |
|
|
|
func TestCreateTempEggScoreIndex(t *testing.T) { |
|
|
|
es.Init("http://120.55.48.175:9200", "elastic", "fnuo123") |
|
|
|
index := fmt.Sprintf("%s_%d_1", md.EggEnergyUserEggScoreEsAlias, 202451) |
|
|
|
err := es.CreateIndexIfNotExists(index, md.EggEnergyUserEggScoreEsMapping) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
} |
|
|
|
|
|
|
|
for i := 1; i < 650; i++ { |
|
|
|
egg_energy.ExistOrDefaultUserEggScore(int64(i)) |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println("success") |
|
|
|
} |
|
|
|
|
|
|
|
// 创建蛋蛋分记录 |
|
|
|
func TestCreateEggScoreIndex(t *testing.T) { |
|
|
|
es.Init("http://120.55.48.175:9200", "elastic", "fnuo123") |
|
|
|
index := fmt.Sprintf("%s_%d", md.EggEnergyUserEggScoreEsAlias, 202451) |
|
|
|
err := es.CreateIndexIfNotExists(index, md.EggEnergyUserEggScoreEsMapping) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
} |
|
|
|
|
|
|
|
for i := 1; i < 650; i++ { |
|
|
|
egg_energy.ExistOrDefaultUserEggScore(int64(i)) |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println("success") |
|
|
|
} |