Skip to content

Instantly share code, notes, and snippets.

@kochie
Created May 21, 2019 01:33
Show Gist options
  • Save kochie/540ec2ca50e912d1dbfcb04ee83c7a93 to your computer and use it in GitHub Desktop.
Save kochie/540ec2ca50e912d1dbfcb04ee83c7a93 to your computer and use it in GitHub Desktop.

Revisions

  1. kochie created this gist May 21, 2019.
    10 changes: 10 additions & 0 deletions cart_edges.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    SELECT CONCAT(CAST(m1.lid AS VARCHAR),
    '-',CAST(m2.lid AS VARCHAR)) AS "id",
    CONCAT(CAST(m1.pid AS VARCHAR),'-',CAST(m2.pid AS VARCHAR)) AS "~id",
    m1.pid AS "~to", m2.pid AS "~from",
    m1.quantity*m2.quantity AS "weight",
    'boughtTogether' AS "~label"
    FROM "mumumango"."lineitem" AS m1, "mumumango"."lineitem" AS m2
    WHERE m1.lid<m2.lid
    AND m1.oid=m2.oid
    ORDER BY m1.lid;
    8 changes: 8 additions & 0 deletions product_vertex.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    SELECT mp.pid AS "~id",
    mp."title" AS "~label",
    mp.catid AS "catid",
    mc.category AS "category"
    FROM "mumumango"."product" as mp
    JOIN "mumumango"."category" as mc
    ON mp.catid=mc.catid
    ORDER BY mp.pid