Skip to content

Support touch_last_downloaded_at in Packages::Npm::MetadataCache

What does this MR do and why?

Part of #393655 (closed)

We'd like to support #touch_last_downloaded_at in Packages::Npm::MetadataCache.

For that this MR proposes to extrcat the code of #touch_last_downloaded_at from Packages::Package model (including EE part) into its own concern to re-use it in multiple places.

  • Adds Packages::Downloadable concern + EE part of it.
  • Removes #touch_last_downloaded_at from Packages::Package.
  • Changes Packages::Package and Packages::Npm::MetadataCache to use Packages::Downloadable concern.
  • Adds/removes related tests.

Screenshots or screen recordings

No.

How to set up and validate locally

Run the following commands in rails console:

  1. Create and verify a new package

    def fixture_file_upload(*args, **kwargs)
      Rack::Test::UploadedFile.new(*args, **kwargs)
    end
    
    p = FactoryBot.create(:npm_package)
    
    p.touch_last_downloaded_at
  2. Create and verify a new metadata cache

    c = FactoryBot.create(:npm_metadata_cache)
    
    c.touch_last_downloaded_at

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #393655 (closed)

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports

Loading