librariesio / libraries.io

:books: The Open Source Discovery Service
https://libraries.io
GNU Affero General Public License v3.0
1.1k stars 206 forks source link

Migration: adds Project#latest_version_id #3356

Closed tiegz closed 2 months ago

tiegz commented 2 months ago

this new column can cache the most recently published Project#versions so we can do includes() and joins() against it. We currently do a query everytime we fetch latest_version: https://github.com/librariesio/libraries.io/blob/8cad44493718ea89347074a08db925dd5ca48b80/app/models/concerns/releases.rb#L40-L42

in a followup PR, we'll backfill this value, change it to a real association, and keep it updated in the same place that we keep latest_release_published_at + latest_release_number updated: https://github.com/librariesio/libraries.io/blob/main/app/models/project.rb#L268-L270

(NB: "latest release" means "either latest version or latest tag", but "latest version" will simply be the latest Version only)