0.3.32
This commit is contained in:
@@ -81,6 +81,10 @@ type JourneyEvent struct {
|
||||
// the two records having to agree on anything but this.
|
||||
PlaySessionID string `json:"playSessionId,omitempty"`
|
||||
Outcome string `json:"outcome,omitempty"`
|
||||
// PositionMs is where playback was, in the title, at a pause or resume step. Zero on
|
||||
// every other kind of step. A pause's duration is derived by the reader from the gap
|
||||
// between a pause event's OccurredAt and its matching resume's, never stored directly.
|
||||
PositionMs int64 `json:"positionMs,omitempty"`
|
||||
}
|
||||
|
||||
type AnalyticsUser struct {
|
||||
@@ -336,13 +340,14 @@ func (s *Store) InsertJourneyEvents(ctx context.Context, events []JourneyEvent)
|
||||
batch.Queue(`
|
||||
INSERT INTO journey_events
|
||||
(occurred_at, emby_user_id, journey_id, sequence, category, action, screen,
|
||||
feature, source, target, item_id, item_name, item_type, play_session_id, outcome)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)
|
||||
feature, source, target, item_id, item_name, item_type, play_session_id, outcome,
|
||||
position_ms)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)
|
||||
ON CONFLICT (emby_user_id, journey_id, sequence) DO NOTHING`,
|
||||
event.OccurredAt, event.UserID, event.JourneyID, event.Sequence,
|
||||
event.Category, event.Action, event.Screen, event.Feature, event.Source,
|
||||
event.Target, event.ItemID, event.ItemName, event.ItemType,
|
||||
event.PlaySessionID, event.Outcome)
|
||||
event.PlaySessionID, event.Outcome, event.PositionMs)
|
||||
}
|
||||
results := s.pool.SendBatch(ctx, batch)
|
||||
defer results.Close()
|
||||
@@ -564,7 +569,7 @@ func (s *Store) UserJourneyEvents(ctx context.Context, userID string, since time
|
||||
rows, err := s.pool.Query(ctx, `
|
||||
SELECT id, occurred_at, emby_user_id, journey_id, sequence, category, action,
|
||||
screen, feature, source, target, item_id, item_name, item_type,
|
||||
play_session_id, outcome
|
||||
play_session_id, outcome, position_ms
|
||||
FROM journey_events WHERE emby_user_id=$1 AND occurred_at >= $2
|
||||
ORDER BY occurred_at DESC, sequence DESC LIMIT $3`, userID, since, limit)
|
||||
if err != nil {
|
||||
@@ -574,7 +579,7 @@ func (s *Store) UserJourneyEvents(ctx context.Context, userID string, since time
|
||||
out := []JourneyEvent{}
|
||||
for rows.Next() {
|
||||
var v JourneyEvent
|
||||
if err := rows.Scan(&v.ID, &v.OccurredAt, &v.UserID, &v.JourneyID, &v.Sequence, &v.Category, &v.Action, &v.Screen, &v.Feature, &v.Source, &v.Target, &v.ItemID, &v.ItemName, &v.ItemType, &v.PlaySessionID, &v.Outcome); err != nil {
|
||||
if err := rows.Scan(&v.ID, &v.OccurredAt, &v.UserID, &v.JourneyID, &v.Sequence, &v.Category, &v.Action, &v.Screen, &v.Feature, &v.Source, &v.Target, &v.ItemID, &v.ItemName, &v.ItemType, &v.PlaySessionID, &v.Outcome, &v.PositionMs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, v)
|
||||
|
||||
Reference in New Issue
Block a user