当前位置: 首页>>代码示例>>Golang>>正文


Golang ComplaintDB.AddDailyCount方法代码示例

本文整理汇总了Golang中github.com/skypies/complaints/complaintdb.ComplaintDB.AddDailyCount方法的典型用法代码示例。如果您正苦于以下问题:Golang ComplaintDB.AddDailyCount方法的具体用法?Golang ComplaintDB.AddDailyCount怎么用?Golang ComplaintDB.AddDailyCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/skypies/complaints/complaintdb.ComplaintDB的用法示例。


在下文中一共展示了ComplaintDB.AddDailyCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SendComplaintsWithSpan


//.........这里部分代码省略.........
	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),
		sent_single_ok, sent_single_fail)
	SendEmailToAdmin(c, subject, "")

	dc := complaintdb.DailyCount{
		Datestring:     date.Time2Datestring(start.Add(time.Hour)),
		NumComplaints:  complaints_submitted + complaints_private,
		NumComplainers: sent_ok,
	}
	cdb.AddDailyCount(dc)

	c.Infof("--- email wrapup: %d ok, %d fail (%d no data) : %d reports submitted (%d kept back)  single[%d/%d]",
		sent_ok, sent_fail, no_data, complaints_submitted, complaints_private, sent_single_ok, sent_single_fail)

	return
}
开发者ID:hugoh,项目名称:complaints,代码行数:101,代码来源:email.go


注:本文中的github.com/skypies/complaints/complaintdb.ComplaintDB.AddDailyCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。