Skip to content

Rank related and trending projects by how long people play, and count visit depth - #78

Merged
Mistium merged 1 commit into
mainfrom
session-depth-api
Nov 15, 2026
Merged

Mistium merged 1 commit into
mainfrom
session-depth-api

Conversation

@Mistium

@Mistium Mistium commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Part of the work to keep people watching projects for longer. In production from Nov 2 to 15, about 95% of project views ended on that project: 117 related-project clicks against 2,542 views, and 1 click on Next project. Half of signed-in plays lasted under 30 seconds.

Related projects

GET /v1/projects/:id/related now leads with projects the same players stayed in:

  • A player "held" a project if they have 30 seconds or more of total playtime on it, counting playtime updated in the last 90 days.
  • A co-played project needs at least 3 shared players, on a project with at least 5 held players.
  • Each player counts 1/sqrt(number of projects they held), so a narrow player's taste weighs more than someone who plays everything.
  • Co-played projects fill at most half the list. Then come the same owner (capped at half), shared tags and trending, as before. Excluded, hidden and current projects never appear.

Trending and featured

explore?sort=trending and the daily featured project weight week views by (held + 2) / (players + 4). Projects people stay in rise, projects people bounce off sink, and projects with little playtime sit in the middle.

Whose plays count

Owners' own plays never count, and neither do banned or shadowbanned players. Nor do players whose recent activity is hidden, which covers minors and students by default and anyone who switched it off. So co-play only draws on play history that players' profiles already show publicly. Review found that without this, a new project could be used to reveal what a single person had played.

Cost

The signals rebuild from project_playtime under one lock and are cached for five minutes. A failed read caches an empty result instead of retrying on every request. trendingOrder over 5,000 entries takes about 12 ms. Ties sort through a single comparator, because sortBy is not stable past 12 items.

Funnel counters

POST /v1/events accepts visit_start (new | returning) and visit_depth (2 | 3 | 5 | 10), so Admin → Activity can show returning visitors and how many projects a visit reaches. The site starts sending them in the matching scratch-gui PR.

Content update time

Project index entries now include lastUploadAt, and merging a pull request into a project sets it. The site uses it to show "Updated since you played" and the Updated date only when a project's content changed, not when its thumbnail, title or sharing changed.

Checks

  • osl test on 6.1.1: 61 passed.
  • lsp check, compile and conventions pass.
  • e2e_smoke.py passes.
  • An independent review's must-fix (privacy) and should-fixes (gaming, sort stability, rebuild stampede) are fixed. New tests cover the thresholds, the 90-day window, owner exclusion, user-id identity, tie order on a 30-item list and the co-play cap.

Version

1.0.1 → 1.1.0 (minor: new ranking and counters, backwards compatible).

No screenshots: backend only. The visible changes come with the scratch-gui PR.

@Mistium
Mistium changed the base branch from osl-6 to main November 15, 2026 04:34
… visit depth

Related projects now lead with projects that at least three of the same
players stayed in, on projects with at least five such players, weighted
toward players with fewer plays. Co-played projects fill at most half the
list, before the same owner, shared tags and trending. Trending and the
daily featured project weight week views by the share of signed-in players
with 30 seconds or more of total playtime, smoothed so projects with little
playtime sit in the middle.

Only plays updated in the last 90 days count. Owners' own plays, banned and
shadowbanned players, and players whose recent activity is hidden (minors
and students by default) never count, so co-play only draws on activity
their profiles already show. The signals are rebuilt from project_playtime
under one lock and cached for five minutes, and ties sort by a single
comparator so the order is stable.

The funnel accepts visit_start (new or returning device) and visit_depth
(2, 3, 5 or 10 projects in one visit).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant