serlo / api.serlo.org

Public GraphQL API of https://serlo.org/
https://api.serlo.org/___graphql
Apache License 2.0
15 stars 4 forks source link

bug: video returns url as content and no url #1610

Closed elbotho closed 2 months ago

elbotho commented 3 months ago

content should be the description (editor state) of the video and url the actual video url.

e.g.

{uuid(id:107488){__typename, ... on Video{currentRevision{content,url}}}}

return with

{
  "data": {
    "uuid": {
      "__typename": "Video",
      "currentRevision": {
        "content": "https://www.youtube.com/watch?v=iFRF3qOJPfM",
        "url": ""
      }
    }
  }
}

same query result in prod:

{
  "data": {
    "uuid": {
      "__typename": "Video",
      "currentRevision": {
        "content": "{\"plugin\":\"rows\",\"state\":[{\"plugin\":\"text\",\"state\":[{\"type\":\"p\",\"children\":[{\"text\":\"Dieses Video eignet sich gut für den Einsatz von Flipped Classroom. Der Inhalt des Videos kann als Hefteintrag verwendet werden.\"}]},{\"type\":\"p\",\"children\":[{\"text\":\"Inhalt:\"}]},{\"type\":\"unordered-list\",\"children\":[{\"type\":\"list-item\",\"children\":[{\"type\":\"list-item-child\",\"children\":[{\"type\":\"p\",\"children\":[{\"text\":\"Veranschaulichung von Addition und Subtraktion am Zahlenstrahl\"}]}]}]},{\"type\":\"list-item\",\"children\":[{\"type\":\"list-item-child\",\"children\":[{\"type\":\"p\",\"children\":[{\"text\":\"Rechnen je eines Beispieles mit schriftlicher Addition bzw. Subtraktion\"}]}]}]}]}],\"id\":\"38d4ac06-42f1-4bcf-86c2-628939c4b5d6\"},{\"plugin\":\"text\",\"state\":[{\"type\":\"p\",\"children\":[{\"text\":\"\"}]}],\"id\":\"8fe20dd1-a035-49db-9b52-22c5fe264aff\"}],\"id\":\"0afb7680-7af2-4de1-8d08-bc4ab830ee60\"}",
        "url": "https://www.youtube.com/watch?v=iFRF3qOJPfM"
      }
    }
  }
}
hugotiburtino commented 2 months ago

And indeed, it's due to a strange code for the video See https://github.com/serlo/database-layer/blob/main/server/src/uuid/model/entity_revision/video_revision.rs

impl From<&AbstractEntityRevision> for VideoRevision {
    fn from(abstract_entity_revision: &AbstractEntityRevision) -> Self {
        let url = abstract_entity_revision.fields.get_or("content", "");
        let title = abstract_entity_revision.fields.get_or("title", "");
        let content = abstract_entity_revision.fields.get_or("description", "");

So the DB migration caused this bug. I'll update the migration

hugotiburtino commented 2 months ago

It seems the fix has worked