···293293 const { bluesky } = thunkAPI.getState() as {
294294 bluesky: BlueskyState;
295295 };
296296- let bskyAgent: Agent;
297297- if (!bluesky.pdsAgent) {
298298- // unauthed request to Bluesky Appview
299299- bskyAgent = new Agent("https://public.api.bsky.app");
300300- } else {
301301- bskyAgent = bluesky.pdsAgent;
302302- }
303303-304304- if (!bskyAgent) throw new Error("No Agent!");
296296+ // unauthed request to Bluesky Appview
297297+ const bskyAgent = new Agent("https://public.api.bsky.app");
305298306299 return await bskyAgent.getProfiles({
307300 actors: actors,
+3-22
pkg/model/livestream.go
···7676 return &livestream, nil
7777}
78787979-// type for livestream with seg start time
8080-type LivestreamWithSegmentStartTime struct {
8181- Livestream
8282- // should be latest_segments.latest_segment_start_time in the query
8383- LatestSegmentStartTime string
8484-}
8585-8679// GetLatestLivestreams returns the most recent livestreams, given a limit and a cursor
8780// Only gets livestreams with a valid segment no less than 30 seconds old
8881func (m *DBModel) GetLatestLivestreams(limit int, before *time.Time) ([]Livestream, error) {
8989- var recentLivestreams []LivestreamWithSegmentStartTime
8282+ var recentLivestreams []Livestream
9083 thirtySecondsAgo := time.Now().Add(-30 * time.Second)
91849285 // get latest segment for the repo DID
···9689 m.DB.Table("segments").
9790 Select("repo_did, MAX(start_time)").
9891 Group("repo_did")).
9999- Where("start_time > ?", thirtySecondsAgo).
9292+ Where("start_time > ?", thirtySecondsAgo.UTC()).
10093 Group("repo_did")
1019410295 rankedLivestreamsSubQuery := m.DB.Table("livestreams").
···130123 return nil, nil
131124 }
132125133133- var finalStreams []Livestream
134134-135135- // for each seg, put results in map if seg start time is after 30 seconds ago
136136- for _, seg := range recentLivestreams {
137137- layout := "2006-01-02 15:04:05.000+00:00"
138138- segStartTime, _ := time.Parse(layout, seg.LatestSegmentStartTime)
139139- if segStartTime.After(thirtySecondsAgo) {
140140- finalStreams = append(finalStreams, seg.Livestream)
141141- //fmt.Printf("seg start time: %s vs 30 seconds ago: %s\n", segStartTime, thirtySecondsAgo.UTC())
142142- }
143143- }
144144-145145- return finalStreams, nil
126126+ return recentLivestreams, nil
146127}