|
@@ -12,7 +12,7 @@ import ( |
|
@@ -12,7 +12,7 @@ import ( |
12
|
"opp/protocol"
|
12
|
"opp/protocol"
|
13
|
)
|
13
|
)
|
14
|
|
14
|
|
15
|
-const LoopSize = 1
|
15
|
+const LoopSize = 20
|
16
|
|
16
|
|
17
|
const (
|
17
|
const (
|
18
|
Uploaded = "已上传,跳过"
|
18
|
Uploaded = "已上传,跳过"
|
|
@@ -31,12 +31,13 @@ func MigrateChanceDataToAliYun() { |
|
@@ -31,12 +31,13 @@ func MigrateChanceDataToAliYun() { |
31
|
log.Info("【迁移机会媒体数据】开始迁移")
|
31
|
log.Info("【迁移机会媒体数据】开始迁移")
|
32
|
defer log.Info("【迁移机会媒体数据】结束迁移")
|
32
|
defer log.Info("【迁移机会媒体数据】结束迁移")
|
33
|
var (
|
33
|
var (
|
34
|
- datas []*models.ChanceData
|
|
|
35
|
query = `select * from chance_data order by id limit ?,?`
|
34
|
query = `select * from chance_data order by id limit ?,?`
|
36
|
pageInfo = protocol.PageInfo{PageSize: LoopSize}
|
35
|
pageInfo = protocol.PageInfo{PageSize: LoopSize}
|
37
|
)
|
36
|
)
|
38
|
o := orm.NewOrm()
|
37
|
o := orm.NewOrm()
|
39
|
for {
|
38
|
for {
|
|
|
39
|
+ var datas []*models.ChanceData
|
|
|
40
|
+ log.Info("当前页:", pageInfo.PageIndex, "起始:", pageInfo.Offset())
|
40
|
if _, e := o.Raw(query, pageInfo.Offset(), pageInfo.PageSize).QueryRows(&datas); e != nil {
|
41
|
if _, e := o.Raw(query, pageInfo.Offset(), pageInfo.PageSize).QueryRows(&datas); e != nil {
|
41
|
if e == orm.ErrNoRows {
|
42
|
if e == orm.ErrNoRows {
|
42
|
break
|
43
|
break
|
|
@@ -44,6 +45,9 @@ func MigrateChanceDataToAliYun() { |
|
@@ -44,6 +45,9 @@ func MigrateChanceDataToAliYun() { |
44
|
log.Error(e)
|
45
|
log.Error(e)
|
45
|
break
|
46
|
break
|
46
|
}
|
47
|
}
|
|
|
48
|
+ if len(datas) == 0 {
|
|
|
49
|
+ break
|
|
|
50
|
+ }
|
47
|
|
51
|
|
48
|
for i := range datas {
|
52
|
for i := range datas {
|
49
|
data := datas[i]
|
53
|
data := datas[i]
|
|
@@ -53,12 +57,12 @@ func MigrateChanceDataToAliYun() { |
|
@@ -53,12 +57,12 @@ func MigrateChanceDataToAliYun() { |
53
|
//上传视频
|
57
|
//上传视频
|
54
|
data.Videos = utils.JsonMarsh(uploadVideos(data, data.Videos))
|
58
|
data.Videos = utils.JsonMarsh(uploadVideos(data, data.Videos))
|
55
|
//上传音频
|
59
|
//上传音频
|
56
|
- data.Speechs = utils.JsonMarsh(uploadVoice(data, data.Speechs))
|
60
|
+ //data.Speechs = utils.JsonMarsh(uploadVoice(data, data.Speechs))
|
57
|
//更新数据
|
61
|
//更新数据
|
58
|
o.Update(data)
|
62
|
o.Update(data)
|
59
|
}
|
63
|
}
|
60
|
pageInfo.PageIndex += 1
|
64
|
pageInfo.PageIndex += 1
|
61
|
- break
|
65
|
+ //break
|
62
|
}
|
66
|
}
|
63
|
}
|
67
|
}
|
64
|
|
68
|
|