learningequality / learningequality/studio

Set unpublishable: true on PublishedChange by construction to simplify handleMaxRevs predicate

Open Beginner friendly
#5,868 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

DEV: frontend P3 - low
Dominant language
Python
Stars
191
Forks
307
Avg merge
5d 6h
Merged PRs (30d)
10

Description

This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Current behavior

In serverSync.js, handleMaxRevs uses findLastIndex to compute two values for deciding whether to set unpublished_changes = true on a channel:

  • lastChannelEditIndex — the last publishable change, filtered (among other conditions) with c.type !== CHANGE_TYPES.PUBLISHED
  • lastPublishIndex — the last publish change, matched with c.type === CHANGE_TYPES.PUBLISHED

The predicate for lastChannelEditIndex already includes !c.unpublishable, making the explicit c.type !== CHANGE_TYPES.PUBLISHED check partially redundant: if PublishedChange always set unpublishable: true, the type check would be unnecessary.

Desired behavior

PublishedChange and PublishedNextChange set unpublishable: true by construction (in its constructor in changes.js), so the c.type !== CHANGE_TYPES.PUBLISHED guard in handleMaxRevs can be removed. The !c.unpublishable check alone is sufficient to exclude publish changes from lastChannelEditIndex.

This makes the semantics self-contained in the change object — callers don't need to know the type mapping — and reduces the risk of future change types being accidentally treated as publishable.

Acceptance Criteria

  • PublishedChange constructor in changes.js sets unpublishable: true unconditionally
  • The c.type !== CHANGE_TYPES.PUBLISHED condition is removed from the lastChannelEditIndex predicate in handleMaxRevs (serverSync.js)
  • Existing tests for PublishedChange in changes.spec.js pass (updated if needed to assert unpublishable: true)
  • unpublished_changes continues to be set correctly after a publish event (no regression)

References

Follow-up to https://github.com/learningequality/studio/pull/5844#discussion_r3125011603

AI usage

This issue was drafted with Claude Code assistance from session context and code review.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PublishedChange and PublishedNextChange constructors in changes.js, then inspect the lastChannelEditIndex predicate in serverSync.js. Update the constructors and remove the redundant type condition, then run the existing PublishedChange tests in changes.spec.js and verify unpublished_changes remains correct after a publish event.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.