openlibhums / openlibhums/janeway

Clear up unneeded saves after adding M2M links

Open
#3,558 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

refactoring
Dominant language
Python
Stars
238
Forks
97
Avg merge
9d 1h
Merged PRs (30d)
8

Description

Is your feature request related to a problem? Please describe.
Django's add method for creating many-to-many relations typically does not require calling save to prompt a database-level change, in contrast to most other changes to objects.

However, we often call save after many-to-many changes:

https://github.com/BirkbeckCTP/janeway/blob/78abba6cc64bc70d59cc06516823b994c31aa046/src/journal/logic.py#L218-L219

https://github.com/BirkbeckCTP/janeway/blob/78abba6cc64bc70d59cc06516823b994c31aa046/src/identifiers/logic.py#L432-L433

https://github.com/BirkbeckCTP/janeway/blob/78abba6cc64bc70d59cc06516823b994c31aa046/src/journal/views.py#L1746-L1747

https://github.com/BirkbeckCTP/janeway/blob/78abba6cc64bc70d59cc06516823b994c31aa046/src/submission/forms.py#L475-L476

Describe the solution you'd like
Find all these and remove them if they can be removed.

Describe alternatives you've considered
Leaving them on the off chance they are needed.

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 by reviewing the cited calls in src/journal/logic.py, src/identifiers/logic.py, src/journal/views.py, and src/submission/forms.py, then search for other many-to-many additions followed by save calls. Check the surrounding model and form behavior and run the relevant tests. Done means unnecessary saves are removed without changing database updates or existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, database
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.