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

API response should include a URL for each image of an item #178

Merged
merged 1 commit into from
May 24, 2017

Conversation

Libisch
Copy link
Contributor

@Libisch Libisch commented May 23, 2017

(See #177)

API adds a URL to every picture in Pictures (to all Items, in order to provide front all URLs without needing to generate them).

Example for added PictureUrl in expected response:

[
    {
        "RightsDesc": "Full",
        "UpdateUser": "BH Online",
        "StatusDesc": "Completed",
        "UnitText1": {
            "En": "Today: Poland, in 1918 - 1939 Poland. Pre 1914 Russia, pre 1795 Poland.\nCourtesy of www.bagnowka.pl"
        },
        "UnitPeriod": [
            {
                "PeriodDateTypeDesc": {
                    "En": "Year",
                    "He": "שנים"
                },
                "PeriodDesc": {
                    "En": "",
                    "He": ""
                }
            }
        ],
        "main_image_url": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/17127fb4ee9ddfd5cc2d0bcb783c571620238d67.jpg",
        "DisplayStatusDesc": "Museum and Internet",
        "UnitTypeDesc": "Photo",
        "TS": "",
        "PeriodDesc": {
            "En": "",
            "He": ""
        },
        "Header": {
            "En": "Poland - draws postcards photos",
            "He": "null"
        },
        "thumbnail_url": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/17127fb4ee9ddfd5cc2d0bcb783c571620238d67.jpg",
        "UnitHeaderDMSoundex": {
            "En": "",
            "He": ""
        },
        "bagnowka": "True",
        "UnitId": "111111111118215",
        "_id": "111111111118215",
        "Pictures": [
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/cbb235f952efb99d143ab5c61f3f2cfb344cacbd.jpg",
                "PictureId": "cbb235f952efb99d143ab5c61f3f2cfb344cacbd"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/bfa952952b58642696d1bb8d09b77423acb808ce.jpg",
                "PictureId": "bfa952952b58642696d1bb8d09b77423acb808ce"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/9247652184a347611e401a42a2f3399c169a9889.jpg",
                "PictureId": "9247652184a347611e401a42a2f3399c169a9889"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/7e7545b2965e5d18aff338beda7cd59933d56bb9.jpg",
                "PictureId": "7e7545b2965e5d18aff338beda7cd59933d56bb9"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/746462243f6de9f23fee453d7345ee69a0300a8f.jpg",
                "PictureId": "746462243f6de9f23fee453d7345ee69a0300a8f"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/1ddb7692f9b3e9cf03a4e0f8c61c2a499ebac243.jpg",
                "PictureId": "1ddb7692f9b3e9cf03a4e0f8c61c2a499ebac243"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/c32b06c7ce81b0fc0a21792eb0e04e251156cd3c.jpg",
                "PictureId": "c32b06c7ce81b0fc0a21792eb0e04e251156cd3c"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/06cf187dccce57fa38d5fd1052ba563789ad74bc.jpg",
                "PictureId": "06cf187dccce57fa38d5fd1052ba563789ad74bc"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/25bbcbccade88b2b731e98c0a7cc33c4fa6cda89.jpg",
                "PictureId": "25bbcbccade88b2b731e98c0a7cc33c4fa6cda89"
            },
            {
                "PictureUrl": "https://s3-us-west-2.amazonaws.com/bagnowka-scraped/full/17127fb4ee9ddfd5cc2d0bcb783c571620238d67.jpg",
                "PictureId": "17127fb4ee9ddfd5cc2d0bcb783c571620238d67"
            }
        ],
        "Slug": {
            "En": "image_poland-draws-postcards-photos"
        },
        "related": [
            "place_belarus"
        ],
        "UpdateDate": "2017-05-21T11:04:28.000Z"
    }
]

Copy link
Contributor

@OriHoch OriHoch 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, I wrote some minor comments but you can merge

@@ -189,6 +189,15 @@ def enrich_item(item, db=None, collection_name=None):
if pictures:
main_image_id = None
for image in pictures:
# Add 'PictureUrl' to all images of an item
image_id = image['PictureId']
if item.has_key('bagnowka'):
Copy link
Contributor

Choose a reason for hiding this comment

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

better to also check if the value is True, not only that it exists
can be done like this:

if item.get('bagnowka'):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is a bagnowka key, the value is always "True".

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but you can't know that it will always be true, in the future as well..

@@ -189,6 +189,15 @@ def enrich_item(item, db=None, collection_name=None):
if pictures:
main_image_id = None
for image in pictures:
# Add 'PictureUrl' to all images of an item
image_id = image['PictureId']
Copy link
Contributor

Choose a reason for hiding this comment

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

you are sure that image will always have 'PictureId'? if not, then it will raise an exception here

Copy link
Contributor

Choose a reason for hiding this comment

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

this is what happened on test environment, worth to look into it - why there are images without PictureId

@Libisch Libisch merged commit 1c6ac73 into Beit-Hatfutsot:dev May 24, 2017
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