Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community Surveys and Scoring #1984

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

jctanner
Copy link
Collaborator

@jctanner jctanner commented Nov 21, 2023

Community scoring in old galaxy was based on a computed average of survey responses from the UX users. On each role or collection, they could rate aspects of the content on a 1-5 scale or a yes/no (which translated to 1 or 5). A user could change their answers at will, but could not delete them. After the POST call to provide their responses, a new score for the content would be computed and displayed in the UX.

There was also a scoring component that derived from ansible-lint outputs, which was called "quality score". This PR does not attempt to re-implement that function.

The new endpoints are in api/v1 for multiple reasons:

  • _ui/v1 is unsupported / unstable and flagged for migration to api/v3
  • api/v3 is no longer truly a galaxy_ng controlled api but is instead a redirect to pulp.
  • this feature is not yet ready for being a full on generic thing that is useful to satellite or other pulp stakeholders
  • we need to iterate quickly on it for the community site

Example survey payload ...

{'docs': 3,
 'does_what_it_says': 4,
 'ease_of_use': 3,
 'used_in_production': 1,
 'works_as_is': 0}

For a role, the payload should be POST'ed to /api/v1/surveys/roles/<roleid>/
For a collection, the payload should be POST'ed to /api/v1/surveys/collections/<namespace>/<name>/ ... because we have no way of getting the pulp_id for a collection from the API right now.

Computed scores come from these endpoints ...

(venv) [jtanner@p1 galaxy_ng]$ curl -s http://localhost:5001/api/v1/scores/roles/ | jq .
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 7,
      "created": "2023-11-29T03:29:06.708629Z",
      "modified": "2023-11-29T03:29:10.572142Z",
      "role": 7,
      "namespace": "jctannerTEST",
      "name": "role1",
      "score": "1.98"
    }
  ]
}
(venv) [jtanner@p1 galaxy_ng]$ curl -s http://localhost:5001/api/v1/scores/collections/ | jq .
{
  "count": 2,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 1,
      "created": "2023-11-29T02:53:09.562222Z",
      "modified": "2023-11-29T02:53:13.397804Z",
      "collection": "018c18fe-59a2-7cd1-8574-ea51f2105133",
      "namespace": "autohubtest2",
      "name": "krdqdlyw",
      "score": "2.40"
    },
    {
      "id": 2,
      "created": "2023-11-29T03:29:31.486404Z",
      "modified": "2023-11-29T03:29:35.316854Z",
      "collection": "018c191f-a4b8-74cd-9389-a597da785d66",
      "namespace": "autohubtest2",
      "name": "adozvbxh",
      "score": "1.63"
    }
  ]
}

Scores have namespace and name filtering ...

(venv) [jtanner@p1 galaxy_ng]$ curl -s 'http://localhost:5001/api/v1/scores/collections/?namespace=autohubtest2&name=adozvbxh' | jq .                                                                                                         
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 2,
      "created": "2023-11-29T03:29:31.486404Z",
      "modified": "2023-11-29T03:29:35.316854Z",
      "collection": "018c191f-a4b8-74cd-9389-a597da785d66",
      "namespace": "autohubtest2",
      "name": "adozvbxh",
      "score": "1.63"
    }
  ]
}

Both the role and the collection scores can be filtered by their roleid or collectionid, if known.

@github-actions github-actions bot added backport-4.2 This PR should be backported to stable-4.2 (1.2) backport-4.4 This PR should be backported to stable-4.4 (2.1) backport-4.5 This PR should be backported to stable-4.5 (2.2) backport-4.6 This PR should be backported to stable-4.6 (2.3) backport-4.7 This PR should be backported to stable-4.7 (2.4) backport-4.8 This PR should be backported to stable-4.8 (2.4) labels Nov 21, 2023
@jctanner jctanner removed backport-4.2 This PR should be backported to stable-4.2 (1.2) backport-4.4 This PR should be backported to stable-4.4 (2.1) backport-4.5 This PR should be backported to stable-4.5 (2.2) backport-4.6 This PR should be backported to stable-4.6 (2.3) backport-4.7 This PR should be backported to stable-4.7 (2.4) backport-4.8 This PR should be backported to stable-4.8 (2.4) labels Nov 21, 2023
@rochacbruno
Copy link
Member

Would be nice to add a data migration reading the existing static data on https://galaxy.ansible.com/static/scores/role.json and https://galaxy.ansible.com/static/scores/collection.json and adding to the new datamodels.

@jctanner
Copy link
Collaborator Author

@rochacbruno these models require the full survey data rather than the final computed scores. I've dumped everthing required and made scripts to import the old data here: https://github.com/jctanner/galaxy-hacking/blob/main/beta.surveys/load_data.py

@jctanner jctanner mentioned this pull request Nov 21, 2023
@jctanner jctanner marked this pull request as draft November 21, 2023 13:24
@jctanner jctanner changed the title Community ratings v2 [WIP] Community ratings v2 Nov 21, 2023
No-Issue

Signed-off-by: James Tanner <[email protected]>
No-Issue

Signed-off-by: James Tanner <[email protected]>
No-Issue

Signed-off-by: James Tanner <[email protected]>
No-Issue

Signed-off-by: James Tanner <[email protected]>
No-Issue

Signed-off-by: James Tanner <[email protected]>
No-Issue

Signed-off-by: James Tanner <[email protected]>
No-Issue

Signed-off-by: James Tanner <[email protected]>
@jctanner jctanner changed the title [WIP] Community ratings v2 Community Surveys and Scoring Nov 29, 2023
@jctanner jctanner marked this pull request as ready for review November 29, 2023 17:08
Copy link
Member

@rochacbruno rochacbruno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some prints found

galaxy_ng/app/access_control/access_policy.py Outdated Show resolved Hide resolved
galaxy_ng/app/api/v1/viewsets/survey.py Outdated Show resolved Hide resolved
galaxy_ng/app/access_control/access_policy.py Outdated Show resolved Hide resolved
No-Issue

Signed-off-by: James Tanner <[email protected]>
No-Issue

Signed-off-by: James Tanner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants