As a Shopify app developer, we would like to fetch and store app reviews on a regular interval.
Shopify app reviews can be fetched via Shopify REST endpoint: https://apps.shopify.com/{app-name}/reviews.json
For example: https://apps.shopify.com/product-upsell/reviews.json
We would like the following:
- fetch app reviews from the Shopify public REST endpoint for a one or more of our applications (see app names below)
- store the results in a database table (see below)
- be able to handle updates to app reviews (i.e. original review was 1 star, now 5 stars)
- run on a configurable interval (i.e. every 30m or 60m)
- create a web UI that allows you to view and search app reviews (filter by app, sort by date)
Below is the full list of application names that we want to fetch and sync reviews for:
App Name |
---|
product-upsell |
product-discount |
store-locator |
product-options |
quantity-breaks |
product-bundles |
customer-pricing |
product-builder |
social-triggers |
recurring-orders |
multi-currency |
quickbooks-online |
xero |
the-bold-brain |
For example, if I wanted to fetch all the reviews for Product Upsell:
https://apps.shopify.com/product-upsell/reviews.json
-
Fork this repo on GitHub
-
Choose from either php, go, java, python or Javascript/Node
- Feel free to use web / application frameworks, there is no restriction on building everything from scratch
-
Store app reviews in a data structure something like: (for example: MySQL)
CREATE TABLE `shopify_app_reviews` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopify_domain` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`app_slug` varchar(255) NOT NULL,
`star_rating` int(11) DEFAULT NULL,
`previous_star_rating` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Now that you have this data, do something interesting with it, tell us something useful about our apps or present the data in a special way. How would you gather insight from this?
- Have fun! Happy Hacking
- Docker
- Laravel 5.6
- PHP 7.2
- MySQL 5.7
Since Bold Commerce stack mainly consist of these technologies, they were chosen for this project to be closer to the reality of the company.
-
- clone the project on a folder:
-
- open the terminal on the root folder of the project:
-
- user the docker-compose command to download and run the containers:
docker-compose up -d
-
- to enter the application container:
you can exit the container by executing
exit
2 times and then:
docker-compose exec -it reviewsyncer_webapp_1 /bin/bash
or you could open a new terminal and type just the last command
- to enter the application container:
you can exit the container by executing
-
- to update the project, run the following command on the application container:
composer update
-
- to create the table, run the following command on the application container:
php artisan migrate
-
- Since the fetch command isn't set to run on startup run the commands:
php artisan fetch:reviews
-
- To setup the fetching to run every 30min you can enter the webphp container (item 6) and run the following commands
crontab -e
then paste at the end of the file:
*/30 * * * * sh /var/www/html/scripts/shellFetch.sh >> /var/log/crontab_fetch.log 2>&1 @reboot sh /var/www/html/scripts/shellFetch.sh >> /var/log/crontab_fetch.log 2>&1
finally, you can exit the editor by pressing
ctrl+o
then hittingenter
andctrl+c
to exitand starting the cron service:
service cron start
-
- if you want to force the command to fetch, just run inside the webphp container (item 6):
php artisan fetch:reviews
-
- access the localhost on your web browser, click on the button and select one of the bold products to see the filtering on the table or just type anything on the seachbox.
- Create test classes
-
Improve UI by changing the list presentation -
Improve UX by changing the navigation to the list and the list itself - Creating graphs and doing data analysis (like the most reviewed product or the best reviewed to start with)
- Improve the list view to handle empty database and include a button to force the REST consumption
-
Make the fetch command run on startup