augur icon indicating copy to clipboard operation
augur copied to clipboard

Fix large code duplication

Open MoralCode opened this issue 1 month ago • 3 comments

Several observations have bene made about ways in which major components/functions of the codebase are duplicated, requireing changes to be made in more than one place.

  • #3338
  • #3342 (the fix is made in multiple places that access the database)
  • #3357 (helps fix duplication in reading from config
  • The get_section in lib.py (more reading from config dupe not addressed by the above
  • augur backend start cli function and augur api start cli function seem to be very similar...

Is there a historical reason for this?

@sgoggins

MoralCode avatar Oct 27 '25 19:10 MoralCode

I think this is almost certainly technical debt that was introduced when we were refining contributor resolution.

sgoggins avatar Oct 28 '25 14:10 sgoggins

There are a few files with suffix _old two of them are in the data models module

razekmh avatar Oct 28 '25 15:10 razekmh

looking specifically at the two data insertion methods touched by #3342 - a codebase wide search indicates that

insert_data (2020, seemingly no specific reason to add) is used by the tables/models:

  • CollectionStatus
  • Config
  • Repo
  • UserGroup/UserRepo
  • Contributor
  • Message
  • PR/IssueMessageRef
  • PullRequest
  • PRAssignee/reviewer/Meta
  • PRReviewMessageRef
  • PRFile/PRCommit

bulk_insert_dicts (created apr 2024 by andrew to remove db session dependence) is used by:

  • Contributor
  • ContributorRepo
  • CommitMesage
  • RepoDepsLibyear
  • RepoDependency
  • RepoDepsScorecard
  • RepoLabor
  • Issue/PREvent
  • Issue Label/Assignee
  • RepoClone
  • Repo
  • ContributorsAlias
  • UnresolvedCommitEmail
  • PRLabel/Assignee/Reviewer/Meta
  • Message
  • PRReviewMessageRef
  • Release
  • repoInfo
  • Issue/PREvent
  • Issue
  • IssueMessageRed
  • PullRequest
  • and more.....

So this seems more complex than just duplicate code....

MoralCode avatar Oct 28 '25 20:10 MoralCode