本文整理汇总了Golang中github.com/skypies/complaints/complaintdb.ComplaintDB.GetAllProfiles方法的典型用法代码示例。如果您正苦于以下问题:Golang ComplaintDB.GetAllProfiles方法的具体用法?Golang ComplaintDB.GetAllProfiles怎么用?Golang ComplaintDB.GetAllProfiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skypies/complaints/complaintdb.ComplaintDB
的用法示例。
在下文中一共展示了ComplaintDB.GetAllProfiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: bksvScanYesterdayHandler
// Examine all users. If they had any complaints, throw them in the queue.
func bksvScanYesterdayHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
cdb := complaintdb.ComplaintDB{C: c, Memcache: true}
var cps = []types.ComplainerProfile{}
cps, err := cdb.GetAllProfiles()
if err != nil {
c.Errorf(" /bksv/scan-yesterday: getallprofiles: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
start, end := date.WindowForYesterday()
bksv_ok := 0
for _, cp := range cps {
if cp.CcSfo == false {
continue
}
var complaints = []types.Complaint{}
complaints, err = cdb.GetComplaintsInSpanByEmailAddress(cp.EmailAddress, start, end)
if err != nil {
c.Errorf(" /bksv/scan-yesterday: getbyemail(%s): %v", cp.EmailAddress, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if len(complaints) > 0 {
t := taskqueue.NewPOSTTask("/bksv/submit-user", map[string][]string{
"user": {cp.EmailAddress},
})
if _, err := taskqueue.Add(c, t, "submitreports"); err != nil {
c.Errorf(" /bksv/scan-yesterday: enqueue: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
bksv_ok++
}
}
c.Infof("enqueued %d bksv", bksv_ok)
w.Write([]byte(fmt.Sprintf("OK, enqueued %d", bksv_ok)))
}
示例2: SendEmailToAllUsers
func SendEmailToAllUsers(c appengine.Context, subject string) int {
cdb := complaintdb.ComplaintDB{C: c}
if cps, err := cdb.GetAllProfiles(); err != nil {
c.Errorf("SendEmailToAllUsers/GetAllProfiles: %v", err)
return 0
} else {
buf := new(bytes.Buffer)
params := map[string]interface{}{}
if err := templates.ExecuteTemplate(buf, "email-update", params); err != nil {
return 0
}
n := 0
for _, cp := range cps {
// This message update goes only to the opt-outers ...
if cp.CcSfo == true && cp.CallerCode != "WOR005" {
continue
}
msg := &mail.Message{
Sender: kSenderEmail,
ReplyTo: kSenderEmail,
To: []string{cp.EmailAddress},
Subject: subject,
HTMLBody: buf.String(),
}
if err := mail.Send(c, msg); err != nil {
c.Errorf("Could not send useremail to <%s>: %v", cp.EmailAddress, err)
}
n++
}
return n
}
}
示例3: SendComplaintsWithSpan
func SendComplaintsWithSpan(c appengine.Context, start, end time.Time) (err error) {
c.Infof("--- Emails, %s -> %s", start, end)
blacklist := map[string]bool{}
for _, e := range blacklistAddrs {
blacklist[e] = true
}
cdb := complaintdb.ComplaintDB{C: c, Memcache: true}
var cps = []types.ComplainerProfile{}
cps, err = cdb.GetAllProfiles()
if err != nil {
return
}
complaints_private, complaints_submitted, no_data, sent_ok, sent_fail := 0, 0, 0, 0, 0
sent_single_ok, sent_single_fail := 0, 0
for _, cp := range cps {
var complaints = []types.Complaint{}
complaints, err = cdb.GetComplaintsInSpanByEmailAddress(cp.EmailAddress, start, end)
if err != nil {
c.Errorf("Could not get complaints [%v->%v] for <%s>: %v", start, end, cp.EmailAddress, err)
no_data++
continue
}
if len(complaints) == 0 {
no_data++
continue
}
// Emailing disabled; last run was Fri Oct 9, 4am, with data for Oct 8. BKSV is now live.
if false {
if cp.CcSfo == true {
for _, complaint := range complaints {
if msg, err := GenerateSingleComplaintEmail(c, cp, complaint); err != nil {
c.Errorf("Could not generate single email to <%s>: %v", cp.EmailAddress, err)
sent_single_fail++
continue
} else {
if blacklist[cp.EmailAddress] {
sent_single_fail++
} else {
if err := mail.Send(c, msg); err != nil {
c.Errorf("Could not send email to <%s>: %v", cp.EmailAddress, err)
sent_single_fail++
continue
} else {
sent_single_ok++
}
}
}
}
}
}
var cap = types.ComplaintsAndProfile{
Profile: cp,
Complaints: complaints,
}
var msg *mail.Message
if msg, err = GenerateEmail(c, cap); err != nil {
c.Errorf("Could not generate email to <%s>: %v", cp.EmailAddress, err)
sent_fail++
continue
}
useGateway := false
if useGateway {
if err = sendViaHTTPGateway(c, msg); err != nil {
c.Errorf("Could not gateway email to <%s>: %v", cp.EmailAddress, err)
sent_fail++
continue
}
} else {
if blacklist[cp.EmailAddress] {
sent_fail++
} else {
if err = mail.Send(c, msg); err != nil {
c.Errorf("Could not send email to <%s>: %v", cp.EmailAddress, err)
sent_fail++
continue
}
}
}
if cap.Profile.CcSfo == true {
complaints_submitted += len(cap.Complaints)
} else {
complaints_private += len(cap.Complaints)
}
sent_ok++
}
subject := fmt.Sprintf("Daily report stats: users:%d/%d reports:%d/%d emails:%d:%d",
sent_ok, (sent_ok + no_data),
complaints_submitted, (complaints_submitted + complaints_private),
//.........这里部分代码省略.........