Skip to content

Instantly share code, notes, and snippets.

View mozgovipc's full-sized avatar
💭
status

Vladimir Caruntu mozgovipc

💭
status
View GitHub Profile
SELECT
"price".*,
MAX("price"."percentageChangeWRTReferencePrice") OVER (PARTITION BY "price"."priceTypeID") AS "max_perc_wrt"
FROM "a36fc41e-073b-5d2d-a1aa-6e8837e83d9b" AS "price"
INNER JOIN (
SELECT
"priceTypeID", MAX("date") AS "date"
FROM "a36fc41e-073b-5d2d-a1aa-6e8837e83d9b"
WHERE "Country" = 'India'
GROUP BY "priceTypeID"
SELECT DISTINCT
"price"."Country",
MAX("price"."percentageChangeWRTReferencePrice") OVER (PARTITION BY "price"."Country") AS "max_perc_wrt"
FROM "ae6fcfa3-ded9-5e24-943d-c5ebb9cdc19b" AS "price"
INNER JOIN (
SELECT
"priceTypeID", MAX("date") AS "date"
FROM "ae6fcfa3-ded9-5e24-943d-c5ebb9cdc19b"
GROUP BY "priceTypeID"
) AS "max_date_per_pricetype"
const dummy_config = {
volatility_warning: [
{
"id": "435874d1-54c5-5daa-99f8-532b8e5c167b",
"label": "HARD WHEAT",
"icon": "<i class=\"fa fa-lemon-o\"></i>",
"url": "https://example.org/hard-wheat"
},
{
"id": "f9dcca19-6108-525c-a357-75bae968d9ee",
SELECT
indicator.id AS db_id,
indicator.year AS year,
indicator.value AS value,
indicatortype.unit AS unit,
datasource.longName_EN AS source_name,
datasource.URL AS source_url,
indicator.last_sync AS last_sync
FROM indicator
INNER JOIN indicatortype ON indicatortype.id = indicator.indicatorTypeID

Add new harvester

Requirements

  1. A table/view in the MySQL database with at least the following columns:
    • db_id - INTEGER unique for each row
    • last_sync - TIMESTAMP, that indicates when the row was last modified (can be created as ALTER TABLE `table_name` ADD COLUMN last_sync TIMESTAMP DEFAULT NOW() ON UPDATE NOW();)
  2. Harvester configuration - a JSON object that includes the credentials to connect to the MySQL database and the field names and type of the table/view that you want to synchronize into CKAN. An example configuration:
{
    "host": "MySQL hostname - string",
    "port": "MySQL port - string or number",
ping 1.1.1.1 | while read pong; do echo "$(date):\t$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport --getinfo | grep SSID | xargs)\t$pong "; done
$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master