Skip to content

Commit af52d5d

Browse files
committed
chore(backend): add more comments
1 parent 25ecb49 commit af52d5d

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

backend/api/measure/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6613,7 +6613,7 @@ func GetSessionTargetingRule(c *gin.Context) {
66136613
return
66146614
}
66156615

6616-
trace, err := GetSTRule(ctx, ruleId)
6616+
trace, err := GetSTRuleById(ctx, ruleId)
66176617
if err != nil {
66186618
msg := "failed to get trace"
66196619
fmt.Println(msg, err)

backend/api/measure/session_targeting.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ type STDashboardConfig struct {
6868
OperatorTypes OperatorTypes `json:"operator_types"`
6969
}
7070

71+
// GetSTRules provides session targeting rules
72+
// that matches various filter criteria
73+
// in a paginated fashion.
7174
func GetSTRules(ctx context.Context, af *filter.AppFilter) (rules []SessionTargetingRule, next, previous bool, err error) {
7275
stmt := sqlf.PostgreSQL.From("session_targeting_rules").
7376
Select("id").
@@ -164,10 +167,9 @@ func GetSTRules(ctx context.Context, af *filter.AppFilter) (rules []SessionTarge
164167
return rules, next, previous, nil
165168
}
166169

167-
// GetSTRule constructs and returns a
168-
// session targeting rule for a
169-
// given ruleId
170-
func GetSTRule(ctx context.Context, ruleId string) (rule SessionTargetingRule, err error) {
170+
// GetSTRuleById fetches a session targeting
171+
// rule by its ruleId.
172+
func GetSTRuleById(ctx context.Context, ruleId string) (rule SessionTargetingRule, err error) {
171173
stmt := sqlf.PostgreSQL.From("session_targeting_rules").
172174
Select("id").
173175
Select("team_id").
@@ -205,6 +207,9 @@ func GetSTRule(ctx context.Context, ruleId string) (rule SessionTargetingRule, e
205207
return rule, nil
206208
}
207209

210+
// CreateSTRule validates and creates
211+
// a new session targeting rule for
212+
// an app.
208213
func CreateSTRule(ctx context.Context, teamId string, appId string, userId string, payload CreateSTRulePayload) (rule SessionTargetingRule, err error) {
209214
now := time.Now()
210215
ruleId := uuid.New()
@@ -257,6 +262,8 @@ func CreateSTRule(ctx context.Context, teamId string, appId string, userId strin
257262
return rule, nil
258263
}
259264

265+
// UpdateSTRule updates an existing
266+
// session targeting rule.
260267
func UpdateSTRule(ctx context.Context, teamId string, appId string, userId string, ruleId string, payload UpdateSTRulePayload) error {
261268
now := time.Now()
262269

@@ -299,6 +306,9 @@ func UpdateSTRule(ctx context.Context, teamId string, appId string, userId strin
299306
return nil
300307
}
301308

309+
// GetSTDashboardConfig creates and returns
310+
// the config required to render session
311+
// targeting rule creation page.
302312
func GetSTDashboardConfig(ctx context.Context, appId uuid.UUID, osName string) (STDashboardConfig, error) {
303313
eventUdAttrs, err := getUDAttrKeys(ctx, appId)
304314
if err != nil {
@@ -349,7 +359,8 @@ func getUDAttrKeys(ctx context.Context, appId uuid.UUID) (attributes []Attribute
349359
return
350360
}
351361

352-
// newEventsConfig creates OS-specific events configuration
362+
// newEventsConfig creates OS-specific
363+
// events configuration
353364
func newEventsConfig(os string) []Event {
354365
// Common events for both iOS and Android
355366
events := []Event{
@@ -443,6 +454,8 @@ func newEventsConfig(os string) []Event {
443454
return events
444455
}
445456

457+
// newEventsConfig creates OS-specific
458+
// session attributes configuration.
446459
func newSessionConfig(osName string) []Attribute {
447460
switch opsys.ToFamily(osName) {
448461
case opsys.Android:

0 commit comments

Comments
 (0)