Skip to content

Commit

Permalink
updated List/Feed SQL notebook to work with seed data
Browse files Browse the repository at this point in the history
  • Loading branch information
mgroves committed Nov 8, 2023
1 parent 49ffb9b commit 9b52e33
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cells":[{"kind":2,"language":"SQL++","value":"SELECT \r\n a.slug,\r\n a.title,\r\n a.description,\r\n a.body,\r\n a.tagList,\r\n a.createdAt,\r\n a.updatedAt,\r\n false AS favorited,\r\n a.favoritesCount,\r\n {\r\n \"username\": META(u).id,\r\n u.bio,\r\n u.image,\r\n \"following\": ARRAY_CONTAINS(COALESCE(fol,[]), META(u).id)\r\n } AS author,\r\n COUNT(*) OVER() AS articlesCount\r\n\r\nFROM Conduit._default.Articles a\r\nJOIN Conduit._default.Users u ON a.authorUsername = META(u).id\r\n\r\n\r\n/* these next lines are only for authenticated users */\r\n/* usernames need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favCurrent ON META(favCurrent).id = (\"mgroves\" || \":favorites\")\r\nLEFT JOIN Conduit._default.`Follows` fol ON META(fol).id = (\"mgroves\" || \"::follows\")\r\n\r\n/* for use with optional filter */\r\n/* username need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favFilter ON META(favFilter).id = (\"jake\" || \"::favorites\")\r\n\r\n/* convenience variable for getting the ArticleKey from slug */\r\nLET articleKey = SPLIT(a.slug, \"::\")[1]\r\n\r\nWHERE 1=1\r\n /* optional filters */\r\n /*AND ARRAY_CONTAINS(a.tagList, \"cruising\")\r\n AND a.authorUsername = 'user-u4tjaxvr.2lw'\r\n AND ARRAY_CONTAINS(favFilter, articleKey)\r\n AND ARRAY_CONTAINS(fol, a.authorUsername)*/ /* used for Feed endpoint */\r\n\r\nORDER BY COALESCE(a.updatedAt, a.createdAt) DESC\r\n\r\n/* needs parameterized */\r\nLIMIT 20\r\nOFFSET 0\r\n"}]}
{"cells":[{"kind":2,"language":"SQL++","value":"SELECT \r\n a.slug,\r\n a.title,\r\n a.description,\r\n a.body,\r\n a.tagList,\r\n a.createdAt,\r\n a.updatedAt,\r\n false AS favorited,\r\n a.favoritesCount,\r\n {\r\n \"username\": META(u).id,\r\n u.bio,\r\n u.image,\r\n \"following\": ARRAY_CONTAINS(COALESCE(fol,[]), META(u).id)\r\n } AS author,\r\n COUNT(*) OVER() AS articlesCount\r\n\r\nFROM Conduit._default.Articles a\r\nJOIN Conduit._default.Users u ON a.authorUsername = META(u).id\r\n\r\n\r\n/* these next lines are only for authenticated users */\r\n/* usernames need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favCurrent ON META(favCurrent).id = (\"matt\" || \":favorites\")\r\nLEFT JOIN Conduit._default.`Follows` fol ON META(fol).id = (\"matt\" || \"::follows\")\r\n\r\n/* for use with optional filter */\r\n/* username need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favFilter ON META(favFilter).id = (\"johnDoe\" || \"::favorites\")\r\n\r\n/* convenience variable for getting the ArticleKey from slug */\r\nLET articleKey = SPLIT(a.slug, \"::\")[1]\r\n\r\nWHERE 1=1\r\n /* optional filters */\r\n /*AND ARRAY_CONTAINS(a.tagList, \"cruising\")\r\n AND a.authorUsername = 'user-u4tjaxvr.2lw'\r\n AND ARRAY_CONTAINS(favFilter, articleKey)\r\n AND ARRAY_CONTAINS(fol, a.authorUsername)*/ /* used for Feed endpoint */\r\n\r\nORDER BY COALESCE(a.updatedAt, a.createdAt) DESC\r\n\r\n/* needs parameterized */\r\nLIMIT 20\r\nOFFSET 0\r\n"}]}

0 comments on commit 9b52e33

Please sign in to comment.