Line 1: |
Line 1: |
− | I'm also going to use this page for some tests. | + | I'm also going to use this page for some tests with https://www.mediawiki.org/wiki/Extension:External_Data . |
| | | |
| {{#get_web_data: | | {{#get_web_data: |
Line 9: |
Line 9: |
| }} | | }} |
| | | |
| + | == Simple test == |
| + | Products with funny barcodes: |
| + | {| class="wikitable" |
| + | ! Code {{#for_external_table:<nowiki/> |
| + | {{!}}- |
| + | {{!}} {{{product}}} |
| + | }} |
| + | |} |
| + | |
| + | == Test with "product" macro == |
| Products with funny barcodes: | | Products with funny barcodes: |
| {| class="wikitable" | | {| class="wikitable" |
Line 14: |
Line 24: |
| {{!}}- | | {{!}}- |
| {{!}} {{Product|{{{product}}}}} | | {{!}} {{Product|{{{product}}}}} |
| + | }} |
| + | |} |
| + | |
| + | == Rich test chaining two requests == |
| + | |
| + | {{#get_web_data: |
| + | url=https://world.openfoodfacts.org/api/v2/search?code={{#for_external_table:{{{product}}},}}&fields=code,product_name |
| + | |format=JSON |
| + | |use jsonpath |
| + | |data=code=$.products[*].code,name=$.products[*].product_name |
| + | |cache seconds=360 |
| + | |use stale cache |
| + | }} |
| + | |
| + | Products with funny barcodes: |
| + | {| class="wikitable" |
| + | ! Code |
| + | ! Name {{#for_external_table:<nowiki/> |
| + | {{!}}- |
| + | {{!}} {{{code}}} |
| + | {{!}} {{{name}}} |
| + | }} |
| + | |} |
| + | |
| + | == Data quality test == |
| + | |
| + | {{#get_web_data: |
| + | url=https://world.openfoodfacts.org/category/vegetable-oils/nutrition-grade/b.json&fields=code,product_name&page_size=100&nocache=1 |
| + | |format=JSON |
| + | |use jsonpath |
| + | |data=count=$.count,code=$.products[*].code,name=$.products[*].product_name |
| + | |cache seconds=360 |
| + | |use stale cache |
| + | }} |
| + | |
| + | {{#get_web_data: |
| + | url=https://world.openfoodfacts.org/category/vegetable-oils.json&fields=count&nocache=1 |
| + | |format=JSON |
| + | |use jsonpath |
| + | |data=count_category=$.count |
| + | |cache seconds=360 |
| + | |use stale cache |
| + | }} |
| + | |
| + | {{#external_value:count}} of {{#external_value:count_category}} ({{#expr: ({{#external_value:count}} / {{#external_value:count_category}} * 100)round2}}%) vegetable oils with Nutri-Score B (100 products max displayed): |
| + | {| class="wikitable" |
| + | ! Name |
| + | ! Code |
| + | {{#for_external_table:<nowiki/> |
| + | {{!}}- |
| + | {{!}} {{{name}}} |
| + | {{!}} {{Product|{{{code}}}}} |
| }} | | }} |
| |} | | |} |