Add delimiters, fixed likes file name.

main
mathan 2024-02-20 11:07:47 -08:00
parent b7458a18f4
commit de4017bc83
2 changed files with 19 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
go.work*
.env
*.csv

View File

@ -2,6 +2,8 @@
set -e
# ------------------------------ FOLLOWS ----------------------------------
follows_query="$(cat <<- EOF
select repos.did as ":START_ID", records.content ->> 'subject' as ":END_ID" from repos join records on repos.id = records.repo where records.collection = 'app.bsky.graph.follow' and records.content ->> 'subject' <> repos.did
EOF
@ -12,6 +14,10 @@ docker compose exec -it postgres psql -U postgres -d bluesky \
-c "copy (${follows_query}) to stdout with csv header;" > follows.csv
echo "Done: $(ls -lh follows.csv)"
# ------------------------------ FOLLOWS ----------------------------------
# ------------------------------ LIKES ----------------------------------
likes_query="$(cat <<- EOF
select repos.did as ":START_ID", subject_did as ":END_ID", "count:long" from
repos join lateral (
@ -23,8 +29,8 @@ EOF
echo "Dumping likes..."
docker compose exec -it postgres psql -U postgres -d bluesky \
-c "copy (${likes_query}) to stdout with csv header;" > like_counts2.csv
echo "Done: $(ls -lh like_counts2.csv)"
-c "copy (${likes_query}) to stdout with csv header;" > like_counts.csv
echo "Done: $(ls -lh like_counts.csv)"
posts_query="$(cat <<- EOF
select repos.did as ":START_ID", subject_did as ":END_ID", "count:long" from
@ -35,11 +41,19 @@ posts_query="$(cat <<- EOF
EOF
)"
# ------------------------------ LIKES ----------------------------------
# ------------------------------ REPLIES ----------------------------------
echo "Dumping posts..."
docker compose exec -it postgres psql -U postgres -d bluesky \
-c "copy (${posts_query}) to stdout with csv header;" > post_counts.csv
echo "Done: $(ls -lh post_counts.csv)"
# ------------------------------ REPLIES ----------------------------------
# ------------------------------ HANDLES ----------------------------------
dids_query="$(cat <<- EOF
insert into repos (did)
select distinct did from (
@ -59,7 +73,7 @@ docker compose exec -it postgres psql -U postgres -d bluesky \
-c "copy (${posts_query}) to stdout with csv header;" > dids.csv
echo "Done: $(ls -lh dids.csv)"
docker exec -it plc-postgres-1 psql -U postgres -d plc \
-c 'copy (select handle, did as "did:ID" from actors) to stdout with (format csv , header, force_quote ("handle"));' > handles.csv
# ------------------------------ HANDLES ----------------------------------