File tree 2 files changed +9
-6
lines changed
websites/code/studygolang/src 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ func ServeBackGround() {
37
37
c .AddFunc ("@daily" , service .GenSitemap )
38
38
39
39
// 给用户发邮件,如通知网站最近的动态,每周的晨读汇总等
40
- c .AddFunc ("0 0 9 * * 1" , service .EmailNotice )
40
+ c .AddFunc ("0 0 4 * * 1" , service .EmailNotice )
41
41
42
42
c .Start ()
43
43
}
Original file line number Diff line number Diff line change 7
7
package service
8
8
9
9
import (
10
+ "bytes"
10
11
"html/template"
11
12
"net/smtp"
12
13
"strings"
13
14
"time"
14
15
15
- "bytes"
16
16
. "config"
17
17
"logger"
18
18
"model"
@@ -92,11 +92,12 @@ func EmailNotice() {
92
92
93
93
var (
94
94
lastUid = 0
95
+ limit = "500"
95
96
users []* model.User
96
97
)
97
98
98
99
for {
99
- users , err = userModel .Where ("uid>?" , lastUid ).Order ("uid ASC" ).FindAll ()
100
+ users , err = userModel .Where ("uid>?" , lastUid ).Order ("uid ASC" ).Limit ( limit ). FindAll ()
100
101
if err != nil {
101
102
logger .Errorln ("find user error:" , err )
102
103
continue
@@ -121,9 +122,11 @@ func EmailNotice() {
121
122
continue
122
123
}
123
124
124
- go func (content , email string ) {
125
- SendMail ("每周精选" , content , []string {email })
126
- }(content , user .Email )
125
+ SendMail ("每周精选" , content , []string {user .Email })
126
+
127
+ if lastUid < user .Uid {
128
+ lastUid = user .Uid
129
+ }
127
130
}
128
131
}
129
132
You can’t perform that action at this time.
0 commit comments