dwyl / learn-postgresql

🐘 Learn how to use PostgreSQL and Structured Query Language (SQL) to store and query your relational data. 🔍
212 stars 23 forks source link

Codeface: Get Org, Repo & Profile Data for Example #62

Open nelsonic opened 5 years ago

nelsonic commented 5 years ago

As part of the example app we are assembling #51 we need to source fresh data. I propose writing a "crawler" to index all of @dwyl's repositories and people. The crawler should:

nelsonic commented 5 years ago

progress: (all the next pages to crawl are being inserted for an Org) image

nelsonic commented 5 years ago

image

nelsonic commented 5 years ago
SELECT
 next_page, 
 COUNT (next_page) AS c
FROM
 logs
WHERE next_page IS NOT null
GROUP BY
 next_page
ORDER BY 
 c asc
limit 1;

image

nelsonic commented 5 years ago

Context: I'm trying to get the next_page we need to view that has not been viewed before. 🔍

SELECT
 next_page, 
 COUNT (next_page) AS c
FROM
 logs
WHERE next_page IS NOT null
AND next_page NOT IN (
    SELECT path
    FROM logs
    WHERE path IS NOT NULL
)
GROUP BY
 next_page
ORDER BY 
 c ASC
LIMIT 1;

image

nelsonic commented 5 years ago

Stars are being saved! ⭐️ image