FIWARE / tutorials.TourGuide-App

:mortar_board: FIWARE Tour Guide Application.
https://fiwaretourguide.readthedocs.io/
MIT License
17 stars 19 forks source link

CLI: Add load commands #130

Closed dmabtrg closed 8 years ago

dmabtrg commented 8 years ago

This PR adds the load, load restaurants, load reservations and load reviews commands to the CLI. This PR depends on both #127 and #122.

These commands allows the user to load sample data for use in TourGuide-App.

FiwareULPGC commented 8 years ago

Restaurants are not properly loaded.

If we use ./tourguide load restaurants the following restaurants are not properly loaded:

El Caserón, Artomaña Txakolina, Bistró 1860, Viña Salceda, Marqués de Riscal, Viña Laguardia, Bodegas López Oria, Señorio de Astobiza (Okendo Txakolina) , Labastida - Solagüen, Marqués de Carrión, Agrícola Labastida, Granja Nuestra Señora de Remelluri , Carlos San Pedro Pérez Deviñaspre , González Teso, La Casa del Patrón, Ángel Santamaría, Señorío de las Viñas, Luis Cañas, Pastelería La Peña Dulce, Sidrería de Algorta, Torre de Oña, Ruiz de Viñaspre, García de Olano, Confitería Goya, El Bodegón Laguardia, El Bodegón Labastida, Bodegas Juan José García Berrueco , Villa Lucía, Pastelería Sosoaga, McDonald´s Leioa, El Portalón, Hnos. Frías del Val, Pastelería Zuricalday, El Mesón, El Rincón de Luis Mari, Pastelería Arrese, Begoña, Karlos Arguiñano, Víctor, Héctor Oribe, Viñedos y Bodegas Casado Morales , Ibañez de Bilbao, Club Náutico, Ramón Roteta, Hospedería los Parajes, Café Iruña, Cafetería Abandoibarra, Sebastián, Hondartzape , El Medoc Alavés, Arbolagaña, Arita Berri , Erreka Güeñes, Txoñe, Café La Granja, Boliña, Pastelería Urrestarazu, Ametzagaña, Santa Bárbara, 5ª Planta, Ñañarri, San Bartolomé, Izkiña, Martín Cendoya (Eguren Ugarte), Mirador de Ulía, Viña Real, Mesón Martín, Bodegón Alejandro, Café Irun, Casa Julián, Frontón, Egaña, Prêt à porter, Mantxua , Janarik Ariña (Mc Donalds), Gaztañaga  Gaztañaga, Magalarte Lezama Txakolina , Añota,Mesón Jauregui  Mesón Jauregui, Iñausti, Iñigo Lavado, Pastelería Brasil, La Fábrica, Martín Berasategui, Martínez, Confitería Gorrotxategi, Bar Restaurante Izkiña, Casa Nicolás, Casa Cámara, Pastelería Otaegui, Oteñe,Katxiña

If we enter to the tourguide docker image and execute node restaurantGeocoder.js before executing the cli loader, the restaurants are loaded properly.

dmabtrg commented 8 years ago

Restaurants are not properly loaded.

If we use ./tourguide load restaurants the following restaurants are not properly loaded:

El Caserón, Artomaña Txakolina, Bistró 1860, Viña Salceda, Marqués de Riscal, Viña Laguardia, Bodegas López Oria, Señorio de Astobiza (Okendo Txakolina) , Labastida - Solagüen, Marqués de Carrión, Agrícola Labastida, Granja Nuestra Señora de Remelluri , Carlos San Pedro Pérez Deviñaspre , González Teso, La Casa del Patrón, Ángel Santamaría, Señorío de las Viñas, Luis Cañas, Pastelería La Peña Dulce, Sidrería de Algorta, Torre de Oña, Ruiz de Viñaspre, García de Olano, Confitería Goya, El Bodegón Laguardia, El Bodegón Labastida, Bodegas Juan José García Berrueco , Villa Lucía, Pastelería Sosoaga, McDonald´s Leioa, El Portalón, Hnos. Frías del Val, Pastelería Zuricalday, El Mesón, El Rincón de Luis Mari, Pastelería Arrese, Begoña, Karlos Arguiñano, Víctor, Héctor Oribe, Viñedos y Bodegas Casado Morales , Ibañez de Bilbao, Club Náutico, Ramón Roteta, Hospedería los Parajes, Café Iruña, Cafetería Abandoibarra, Sebastián, Hondartzape , El Medoc Alavés, Arbolagaña, Arita Berri , Erreka Güeñes, Txoñe, Café La Granja, Boliña, Pastelería Urrestarazu, Ametzagaña, Santa Bárbara, 5ª Planta, Ñañarri, San Bartolomé, Izkiña, Martín Cendoya (Eguren Ugarte), Mirador de Ulía, Viña Real, Mesón Martín, Bodegón Alejandro, Café Irun, Casa Julián, Frontón, Egaña, Prêt à porter, Mantxua , Janarik Ariña (Mc Donalds), Gaztañaga  Gaztañaga, Magalarte Lezama Txakolina , Añota,Mesón Jauregui  Mesón Jauregui, Iñausti, Iñigo Lavado, Pastelería Brasil, La Fábrica, Martín Berasategui, Martínez, Confitería Gorrotxategi, Bar Restaurante Izkiña, Casa Nicolás, Casa Cámara, Pastelería Otaegui, Oteñe,Katxiña

If we enter to the tourguide docker image and execute node restaurantGeocoder.js before executing the cli loader, the restaurants are loaded properly.

This is strange. Could you please tell us the steps you've followed before running ./tourguide load restaurants? I've made a clean clone of the repository and pulled just the needed branches to test this and it's working for me.

FiwareULPGC commented 8 years ago

Steps to replicate:

restaurants-not-loaded

If we replicate the same steps but doing these steps before executing the load command:

All restaurants are loaded (see image below).

restaurants-loaded
dmabtrg commented 8 years ago

Ok, the restaurants are loading, but some of them don't have the geolocation data added when loading. See this example after ./tourguide load restaurants:

curl -s --header 'x-auth-token: rFyqQP0vzYIO3D0568EdyLvRAX8O2d' --header 'fiware-service: tourguide' -X GET http://tourguide/api/orion/restaurant/Elizalde | json_reformat 
[
    {
        "@context": "http://schema.org",
        "@type": "Restaurant",
        "additionalProperty": [
            {
                "value": 200,
                "name": "capacity",
                "@type": "PropertyValue"
            },
            {
                "value": 0,
                "name": "occupancyLevels",
                "@type": "PropertyValue",
                "timestamp": "2016-09-01T00:19:29.136Z"
            }
        ],
        "address": {
            "streetAddress": "Cuesta de las Cabras Aldapa 2",
            "addressRegion": "Araba",
            "addressLocality": "Alegría-Dulantzi",
            "postalCode": "01240",
            "@type": "PostalAddress"
        },
        "aggregateRating": {
            "reviewCount": 77,
            "ratingValue": 2
        },
        "department": "Franchise3",
        "description": "Restaurante de estilo sidrería ubicado en Alegria-Dulantzi. Además de su menú del día y carta, también ofrece menú de sidrería. El menú del día cuesta 9 euros. Los fines de semana la especialidad de la casa son las alubias con sacramentos. En lo que a bebidas se refiere, hay una amplia selección además de la sidra. Cabe destacar que se puede hacer txotx. La capacidad del establecimiento es de 50 personas pero la sidrería no dispone de aparcamiento.\n\nHORARIO: \n\nLunes a domingo: 9:00-17:00 y 19:00-23:00.",
        "geo": {
            "@type": "GeoCoordinates",
            "latitude": "42.8404625",
            "longitude": " -2.5123277"
        },
        "name": "Elizalde",
        "telephone": "945 400 868"
    }
]
curl -s --header 'x-auth-token: rFyqQP0vzYIO3D0568EdyLvRAX8O2d' --header 'fiware-service: tourguide' -X GET http://tourguide/api/orion/restaurant/Marqués%20de%20Riscal | json_reformat 
[
    {
        "@context": "http://schema.org",
        "@type": "Restaurant",
        "additionalProperty": [
            {
                "value": 50,
                "name": "capacity",
                "@type": "PropertyValue"
            },
            {
                "value": 0,
                "name": "occupancyLevels",
                "@type": "PropertyValue",
                "timestamp": "2016-09-01T00:17:08.296Z"
            }
        ],
        "address": {
            "streetAddress": "Calle Torrea, 1",
            "addressRegion": "ALAVA",
            "addressLocality": "ELCIEGO",
            "postalCode": "010022",
            "@type": "PostalAddress"
        },
        "aggregateRating": {
            "reviewCount": 5,
            "ratingValue": 5
        },
        "department": "Franchise2",
        "description": "Ubicado en el exclusivo hotel del mismo nombre, el restaurante Marqués de Riscal ofrece a los comensales la oportunidad de degustar platos típicos de la comarca, siempre con un toque vanguardista y creativo, bajo el asesoramiento del chef Francis Paniego. Como no podía ser de otra manera, también cuenta con una amplia carta de vinos, incluyendo caldos procedentes de la bodega Marqués de Riscal, y presta especial atención a los platos de temporada. Además de la carta, disponen de varios menús degustación y menús navideños.",
        "name": "Marqués de Riscal",
        "telephone": "945 180 888",
        "url": "http://www.restaurantemarquesderiscal.com/es/"
    }
]

As you can see, the restaurant is loaded, just without the geolocation.

@albertinisg, could you check the geolocation file? It seems some of the restaurants don't have the geolocation available in that file. In this example, the restaurant Marqués de Riscal (ID 0e1f6b3c7f8c1e60ed1ee2f6819ad68b88c68d0c) does not have an entry in the restaurantsGeo.json file. If this is the case, it should be fixed in #122, as that is the PR that add the geolocation file.

albertinisg commented 8 years ago

I'll have a look!

FiwareULPGC commented 8 years ago

We have revised the PR again and restaurants seems to be loaded correctly. So this problem now seems to be solved.

Otherwise, we found another unexpected behaviour when reviews are loaded. If we filter reviews by franchises we get an empty set, and, if we add a new review using the client, it is shown correctly when we retrieve the franchise reviews.

We retrieved the reviews entities directly from Orion and we found the following difference:

All loaded reviews have:

        "publisher":
        {
            "type": "Organization",
            "value": "Bitergia",
            "metadata":
            {
            }
        },

But if we create a new review, it has:

        "publisher":
        {
            "type": "Organization",
            "value": "Franchise1",
            "metadata":
            {
            }
        },

We could not find additional differences.

Note: In order to retrieve reviews filtered by franchise, we use http://tourguide/api/orion/reviews/organization/Franchise1

albertinisg commented 8 years ago

The behavior it's been the same since the beginning. I guess there's a misconception of the field publisher. This field is for the organization of the user that generates the review, the organization he/she belongs.

So for example, if I generate a review, the organization I belong is Bitergia, but if you generate a review, the organization should be ULPGC.

FiwareULPGC commented 8 years ago

In order to clarify this question, we are going to suppose this scenario:

User1-1 (Franchise1 employee) writes a review(r2-1-a) about a restaurant(R2-1) that belongs to the Franchise2.

So, If we perform the "List reviews by organization" operation (http://docs.tourguide.apiary.io/#reference/api-especification-for-tourguide/review/list-reviews-by-organization), using Franchise1 as filter, we will get the r2-1-a review? Note that this review is about a Restaurant (R2-x) that belongs to Franchise2 and not to Franchise1.

If this is the case, we were wrong because we thought that "List reviews by organization" returned a list of reviews that users have written about a organization.

One example should be:

An empoyee of one franchise (McDonals) write a review of another franchise (BurgerKing). When we ask for McDonals reviews, it returns the reviews of McDonals employee about BurgerKing.

albertinisg commented 8 years ago

That's it. For that function, we just filter the reviews by the Publisher value: https://github.com/Fiware/tutorials.TourGuide-App/blob/develop/server/routes/orion.js#L468 So it will return the elements that match this field.

Anyway, I'll modify the reviews generator, adding Franchise1-4 instead of Bitergia to clarify it.

albertinisg commented 8 years ago

PR #122 updated as mentioned last week

FiwareULPGC commented 8 years ago

Apart of the behavior with the franchises, if it looks good to @jmcanterafonseca, this PR LGTM

FiwareULPGC commented 8 years ago

LGTM