Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add duration and category to ES mappings #291

Merged
merged 3 commits into from
Oct 13, 2021

Conversation

sarayourfriend
Copy link
Contributor

Fixes

Fixes #212 by @krysal

Description

Adds the duration and category fields to the ES mappings. Also adds the category to the AudioSerializer. Duration was already present there (though doesn't appear to be working in my tests of the audio results endpoint).

Testing Instructions

Run just down && just init then inspect the response of the http://localhost:8000/v1/audio?format=json endpoint and verify that the expected fields are all present.

As I said above, the duration is still missing but I'm unsure why.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added ✨ goal: improvement Improvement to an existing user-facing feature 🕹 aspect: interface Concerns end-users' experience with the software labels Oct 11, 2021
@sarayourfriend sarayourfriend requested a review from a team as a code owner October 11, 2021 16:31
Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

Looks good, though I don't have any advice on the missing duration piece 😅

@dhruvkb
Copy link
Member

dhruvkb commented Oct 11, 2021

The addition of duration did not work because it also needs to be added here:

This is the code that transforms a DB cursor row dict into an elasticsearch_dsl.Document. category by weird chance is already present there but duration isn't.

@sarayourfriend
Copy link
Contributor Author

@dhruvkb Thank you so much! That worked perfectly! I've update the PR with that change and the testing instructions pass now.

@zackkrida
Copy link
Member

It looks like to make the audio tests pass, the sample responses in the tests need to be updated with the new fields. Other than that this already looks great 👍

@@ -119,6 +120,10 @@ class AudioSerializer(MediaSerializer):
required=False, help_text="JSON describing alternative files for this audio."
)

category = serializers.CharField(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be moved to the MediaSerializer now: in the Catalog, we have changed the Category for Audio to match Image Category, i.e. now it's an Array field that can contain several categories.

Copy link
Member

Choose a reason for hiding this comment

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

I'm skeptical about having categories being an array. We already have genres for many-to-many classification and tags for attributes. Furthermore, if we look at the example categories (namely music, sound_effect, podcast, news & audiobook), it's hard to see any overlap between them. Even in our sample data, none of the files belong to more than one category.

Anyway if we do decide to change it, here's the Django model for reference. It'll need to be updated.

category = models.CharField(

Copy link
Member

Choose a reason for hiding this comment

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

As discussed this will stay a string and can be move to the MediaSerializer later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this stay for the time being until the images are converted to a single category? Or is it possible to update it now already?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe @dhruvkb can confirm, I think it'd be better for this to stay where it is for now and for us to update it later but not sure.

Copy link
Member

Choose a reason for hiding this comment

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

The category can be separate for audio and images for the time being. We can merge the fields later when we clean up the existing image catalog.

ingestion_server/ingestion_server/es_mapping.py Outdated Show resolved Hide resolved
@sarayourfriend sarayourfriend merged commit 80d3358 into main Oct 13, 2021
@sarayourfriend sarayourfriend deleted the feat/add-categoy-to-audio branch October 13, 2021 15:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🕹 aspect: interface Concerns end-users' experience with the software ✨ goal: improvement Improvement to an existing user-facing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add audio fields to audio search response
5 participants