-
Notifications
You must be signed in to change notification settings - Fork 5
/
traffic.sh
executable file
·39 lines (34 loc) · 1.09 KB
/
traffic.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
source "base_api.sh"
source "utils.sh"
function traffic_clones() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r REPO="$3"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$REPO/traffic/clones")
echo "$body" | jq -r '.count, .uniques'
}
function traffic_ref() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r REPO="$3"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$REPO/traffic/popular/referrers")
echo "$body" | jq -r '.[] | .referrer, .count, .uniques'
}
function traffic_ref_path() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r REPO="$3"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$REPO/traffic/popular/paths")
echo "$body" | jq -r '.[] | .path, .title, .count, .uniques'
# You can also replace it with:
# echo "$body" | jq -r '.[] | "Path: \(.path)\nTitle: \(.title)\nCount: \(.count)\nUniques: \(.uniques)\n"'
# for more readable output.
}
function traffic_views() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r REPO="$3"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$REPO/traffic/views")
echo "$body" | jq -r '.count, .uniques'
}