Compare commits

..

3 Commits

Author SHA1 Message Date
72606b30fc feat 优化到达阈值后推送内容
Some checks failed
Build image / build (push) Has been cancelled
2024-12-03 09:37:58 +08:00
1e799ae1c2 fix 修复没达到阈值就推送的bug 2024-12-03 09:34:04 +08:00
03ad24f689 feat 提高数据库超时时间 2024-12-03 09:29:16 +08:00
3 changed files with 5 additions and 4 deletions

View File

@ -36,6 +36,7 @@ func NewController(ctx context.Context, cfg *options.Config, client *coach_clien
ctx: ctx,
providerId: cfg.ProviderId,
interval: cfg.AtsInterval,
threshold: cfg.AtsThreshold,
client: client,
storage: storage.NewStorage(db),
tracers: NewTracers(storage.NewStorage(db), cfg.ProviderId),
@ -158,7 +159,7 @@ func (c *Controller) doTrace(tracer *Tracer) (available bool) {
if value := tracer.lastAts - article.Ats; value >= c.threshold {
_, _ = pusher.Push(c.ctx, &push.PushReq{
Title: "coach 商品库存减少",
Content: fmt.Sprintf("coach 商品 %s %s 减少了 %d \n链接%s", tracer.pArticle.SkuID, c.interval, value, tracer.pArticle.Link),
Content: fmt.Sprintf("coach 商品 %s %s 减少了 %d \n链接%s", tracer.pArticle.SkuID, time.Now().Sub(tracer.lastTraceTime).String(), value, tracer.pArticle.Link),
})
}
c.storage.DB().Create(&v2.ProviderAts{

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.22.2
toolchain go1.22.3
require (
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241202124532-436ec577c266
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241203012724-2cc7b5cfb70a
gitea.timerzz.com/kedaya_haitao/pusher v0.0.0-20241129135359-c16e02a7eab0
github.com/cloudwego/kitex v0.11.3
github.com/gofiber/fiber/v3 v3.0.0-beta.3

4
go.sum
View File

@ -1,6 +1,6 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241202124532-436ec577c266 h1:jD1LT+BPAORoQFIEShLkdN6x3CsiyZEMLwhKuX8Cm6s=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241202124532-436ec577c266/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241203012724-2cc7b5cfb70a h1:BfHVMbA29/0KLg4Nv0PQVnca1pwJp7EQqjsth6A0CBY=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241203012724-2cc7b5cfb70a/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
gitea.timerzz.com/kedaya_haitao/pusher v0.0.0-20241129135359-c16e02a7eab0 h1:WMNOErbI6At865VWI3sN74RMQaZ8ZhwsNSB9A4vg/6Q=
gitea.timerzz.com/kedaya_haitao/pusher v0.0.0-20241129135359-c16e02a7eab0/go.mod h1:nRdxwOP3hhkUdH3PjHq3gt8SA+YEfR/d7Ig9DuQQZQY=
github.com/3andne/restls-client-go v0.1.6 h1:tRx/YilqW7iHpgmEL4E1D8dAsuB0tFF3uvncS+B6I08=