Created
October 1, 2019 02:47
-
-
Save EvanTheB/cf839c2510382438e5dbde23287d604c to your computer and use it in GitHub Desktop.
confluence most liked pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
# set -x | |
rm likes | |
curl -sS -n -G -H 'Content-Type: application/json' https://intranet.gimr.garvan.org.au/rest/api/content/ --data-urlencode limit=500 --data-urlencode type=page --data-urlencode type=page > tmpdata | |
for i in $(seq 500); do | |
cat tmpdata | jq -r '.results[] | .id' | xargs -I'{}' curl -sS -n -G -H 'Content-Type: application/json' https://intranet.gimr.garvan.org.au/rest/likes/1.0/content/'{}'/likes | jq -r '[(.likes | length | tostring), .content_id] | join (" ")' >> likes | |
x=$(jq -r '._links.base + ._links.next' tmpdata) | |
echo "$x" | |
if test "$x" = ""; then | |
break | |
fi | |
echo keep going | |
x=$(jq -r '._links.base + ._links.next' tmpdata) | |
curl -sS -n -G -H 'Content-Type: application/json' "$x" > tmpdata | |
done | |
sort -n likes | tail | |
sort -n likes | tail | ecut 2 | xargs -I'{}' curl -sS -n -G -H 'Content-Type: application/json' https://intranet.gimr.garvan.org.au/rest/api/content/'{}' --data-urlencode expand=none | jq -r '[._links.base + ._links.tinyui, .title] | join(" ")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment