Collection: Sidebar works count is wrong if a work belongs to two subcollections or to the parent collection and a subcollection

Description

Steps to reproduce:

  1. Log in

  2. Browse > Collections > New Collection

  3. Fill in required information

  4. Submit

  5. Subcollections (0) > New Subcollection

  6. Fill in required information – the parent collection will already be entered for you

  7. Submit

  8. Post to Collection

  9. Fill in required information

  10. Since you used the Post to Collection option on the subcollection, the subcollection will already be listed under "Post to Collections / Challenges." Enter the name or title of the parent collection as well.

  11. Post Without Preview

  12. In the work meta, follow the link to the parent collection

What happens:

The sidebar on the parent collection says "Works (2)." (It may take a minute to update.) Following that link shows and counts only one work.

What should happen:

The parent collection's sidebar should say "Work (1)."

Notes

It doesn't have to be the parent collection and a subcollection. It also happens if the parent collection has two subcollections and the work is added to both of those.

Activity

Show:
Sammie Louise
August 17, 2020, 6:01 AM

A similar issue seems to occur when a work in a subcollection is in multiple collections; whether those collections are related or not.

An example:
A Parent Collection is created, and has two works added to it.
A SubCollection is created, and has 4 works add to it. One of those works is also already in An Unrelated Collection.

Navigating to A Parent Collection, the Works () sidebar menu says Works (6) and opening that link lists all 6 works in both collections.
Navigating to A SubCollection, the Works () sidebar menu says Works (6) and opening that link lists zero works. The page heading says “0 Works in A SubCollection”.

If I remove the one work that is also in another collection, this problem resolves. A Parent Collection says Works (#) and selecting the link lists all 5 works. A SubCollection says Works (#) and selecting the link lists all 4.

(The Works (#) hasn’t decreased, which seems to be a different issue)

Assignee

Unassigned

Reporter

Sarken

Roadmap

Collections

Priority

Medium

Affects versions

Fix versions

None

Components

BackEnd

Difficulty

Medium

Milestone

Internal 0.9