CtrlK
BlogDocsLog inGet started
Tessl Logo

guydemo/pubnub-presence

Implement real-time presence tracking with PubNub

79

1.07x

Quality

67%

Does it follow best practices?

Impact

98%

1.07x

Average score across 5 eval scenarios

Overview
Skills
Evals
Files

task.mdevals/scenario-5/

Room Listing with Occupancy Counts

Context

You are building a chat application with many rooms. The room listing page shows users how many people are currently in each room. This page may be viewed frequently by many users, and the list of rooms can be long (50-100 rooms).

Fetching live occupancy data from PubNub every time the page renders or a component re-renders is expensive in terms of API calls and latency. The occupancy counts do not need to be perfectly real-time on this listing page -- being within 30 seconds of accurate is acceptable.

The listing page only needs the occupancy count for each room. It does not need to know the individual UUIDs or their state metadata.

Task

Implement a JavaScript class called PresenceCache that:

  1. Accepts a PubNub instance and an optional TTL (time-to-live) parameter
  2. Provides a getOccupancy(channel) method that returns the current occupancy for a given channel
  3. Avoids redundant API calls by reusing recent results when they are still fresh enough
  4. Makes efficient API calls when fresh data is needed, requesting only the minimum necessary information
  5. Supports fetching occupancy for multiple channels efficiently

Expected Outputs

A single JavaScript file presence-cache.js containing the PresenceCache class.

Install with Tessl CLI

npx tessl i guydemo/pubnub-presence@0.1.2

evals

SKILL.md

tile.json