Merge remote-tracking branch 'origin/dev' into api_search

# Conflicts:
#	api/chalicelib/core/weekly_report.py
This commit is contained in:
Taha Yassine Kraiem 2022-01-03 14:40:53 +01:00
commit e80f991268
7 changed files with 24 additions and 32 deletions

View file

@ -19,7 +19,6 @@ captcha_key=
captcha_server=
change_password_link=/reset-password?invitation=%s&&pass=%s
email_basic=http://127.0.0.1:8000/async/basic/%s
email_funnel=http://127.0.0.1:8000/async/funnel/%s
email_signup=http://127.0.0.1:8000/async/email_signup/%s
invitation_link=/api/users/invitation?token=%s
isEE=false

View file

@ -1,6 +1,4 @@
from decouple import config
from chalicelib.utils import pg_client, helper
from chalicelib.utils import pg_client, helper, email_helper
from chalicelib.utils.TimeUTC import TimeUTC
from chalicelib.utils.helper import get_issue_title
@ -84,6 +82,7 @@ def cron():
) AS month_1_issues ON (TRUE)
WHERE projects.deleted_at ISNULL;"""), params)
projects_data = cur.fetchall()
emails_to_send = []
for p in projects_data:
params["project_id"] = p["project_id"]
print(f"checking {p['project_name']} : {p['project_id']}")
@ -228,13 +227,14 @@ def cron():
if j["type"] in keep_types:
keep.append(j)
i["partition"] = keep
helper.async_post(config('email_funnel') % "weekly_report2",
{"email": p.pop("emails"),
"data": {
**p,
"days_partition": days_partition,
"issues_by_type": issues_by_type,
"issues_breakdown_by_day": issues_breakdown_by_day,
"issues_breakdown_list": issues_breakdown_list
}
})
emails_to_send.append({"email": p.pop("emails"),
"data": {
**p,
"days_partition": days_partition,
"issues_by_type": issues_by_type,
"issues_breakdown_by_day": issues_breakdown_by_day,
"issues_breakdown_list": issues_breakdown_list
}})
print(f">>> Sending weekly report to {len(emails_to_send)} email-group")
for e in emails_to_send:
email_helper.weekly_report2(recipients=e["email"], data=e["data"])

View file

@ -566,15 +566,6 @@ def async_send_signup_emails(data: schemas.EmailPayloadSchema = Body(...)):
email_helper.send_assign_session(recipient=data.email, link=data.link, message=data.message)
# TODO: transform this to a background task when you find a way to run it without an attached request
@public_app.post('/async/funnel/weekly_report2', tags=["async mail"])
def async_weekly_report(data: schemas.WeeklyReportPayloadSchema = Body(...)):
print("=========================> Sending weekly report")
if data.auth != config("async_Token"):
return {}
email_helper.weekly_report2(recipients=data.email, data=data.data)
# @public_app.post('/async/basic/member_invitation', tags=["async mail"])
# def async_basic_emails(data: schemas.MemberInvitationPayloadSchema = Body(...)):
# if data.auth != config("async_Token"):

View file

@ -256,12 +256,6 @@ class EmailPayloadSchema(BaseModel):
message: str = Field(...)
class WeeklyReportPayloadSchema(BaseModel):
auth: str = Field(...)
email: EmailStr = Field(...)
data: dict = Field(...)
class MemberInvitationPayloadSchema(BaseModel):
auth: str = Field(...)
email: EmailStr = Field(...)

View file

@ -3,6 +3,7 @@ package builder
import (
"net/url"
"strings"
"time"
"openreplay/backend/pkg/intervals"
. "openreplay/backend/pkg/messages"
@ -42,6 +43,7 @@ func getResourceType(initiator string, URL string) string {
type builder struct {
readyMsgs []Message
timestamp uint64
lastProcessedTimestamp int64
peBuilder *pageEventBuilder
ptaBuilder *performanceTrackAggrBuilder
ieBuilder *inputEventBuilder
@ -112,6 +114,10 @@ func (b *builder) handleMessage(message Message, messageID uint64) {
if b.timestamp <= timestamp { // unnecessary? TODO: test and remove
b.timestamp = timestamp
}
b.lastProcessedTimestamp = time.Now().UnixNano()/1e6
// Might happen before the first timestamp.
switch msg := message.(type) {
case *SessionStart,
@ -294,6 +300,7 @@ func (b *builder) checkTimeouts(ts int64) bool {
}
lastTsGap := ts - int64(b.timestamp)
//b.lastProcessedTimestamp
//log.Printf("checking timeouts for sess %v: %v now, %v sesstime; gap %v",b.sid, ts, b.timestamp, lastTsGap)
if lastTsGap > intervals.EVENTS_SESSION_END_TIMEOUT {
if rm := b.ddDetector.Build(); rm != nil {

View file

@ -23,7 +23,6 @@ ch_host=
ch_port=
change_password_link=/reset-password?invitation=%s&&pass=%s
email_basic=http://127.0.0.1:8000/async/basic/%s
email_funnel=http://127.0.0.1:8000/async/funnel/%s
email_plans=http://127.0.0.1:8000/async/plans/%s
email_signup=http://127.0.0.1:8000/async/email_signup/%s
idp_entityId=

View file

@ -35,10 +35,12 @@ def get_full_config():
servers = servers.split("|")
credentials = get_temporary_credentials()
if __get_secret() is not None:
servers = [{"url": s.split(",")[0], **credentials} for s in servers]
for i in range(len(servers)):
url = servers[i].split(",")[0]
servers[i] = {"url": url} if url.lower().startswith("stun") else {"url": url, **credentials}
else:
for i in range(len(servers)):
s = servers[i].split("|")
s = servers[i].split(",")
if len(s) == 3:
servers[i] = {"url": s[0], "username": s[1], "credential": s[2]}
else: