Uploaded image for project: 'Automation Hub'
  1. Automation Hub
  2. AAH-1537

Add collection download count to pulp ansible.

Details

    • Story
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • Backend
    • None

    Description

      As a collection author, I would like to know how many times my collection has been downloaded.

      Models

      Create a CollectionVersionDownload model that tracks downloads by client. client and collection_version keys should be unique together:

      Fields:

      • collection_version: FK to collection version
      • client: string. "pulp", "ansible-galaxy", or "other".
      • count: int

      This model should subclass BaseModel from pulpcore.

      Note: Collection version downloads are tracked in a separate table instead of adding them as a field on the CollectionVersion model itself because CollectionVersion is immutable. Download counts don't need to be preserved during sync and import/export operations, so they can be stored separately from the content they're connected to.

      Views

      On artifact download endpoint:

      1. check request user-agent
        1. if pulp: client = pulp
        2. if ansible galaxy: client = ansible-galaxy
        3. if anything else: client = other
      2. get or create new download count object with collection version and client.
      3. Increase count by 1

      Serializers

      CollectionVersion and Collection serializers:

      Add download_count field.

      "download_count": [
          {"client": "pulp", "downloads": 0}
          {"client": "ansible-galaxy", "downloads": 0}
          {"client": "other", "downloads": 0}
      ] 

      On the collection serializer, the download counts should be the sum of all the collection versions. So if a collection has two versions with 3 and 5 downloads from the pulp client, the collection serializer would return 8 downloads.

       

      Add last_downloaded field that returns the time that the object was last downloaded:

      "last_downloaded": "2022-04-22T16:36:58.249615Z" 

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            dnewswan David Newswanger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: