-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
traffic.rs
43 lines (38 loc) · 1.08 KB
/
traffic.rs
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
40
41
42
43
use hubcaps::traffic::TimeUnit;
use hubcaps::{Credentials, Github};
use std::env;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
pretty_env_logger::init();
let token = env::var("GITHUB_TOKEN")?;
let github = Github::new(
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
Credentials::Token(token),
)?;
let owner = "softprops";
let repo = "hubcaps";
println!("Top 10 referrers");
for referrer in github.repo(owner, repo).traffic().referrers().await? {
println!("{:#?}", referrer)
}
println!("Top 10 paths");
for path in github.repo(owner, repo).traffic().paths().await? {
println!("{:#?}", path)
}
println!("Views per day");
let views = github
.repo(owner, repo)
.traffic()
.views(TimeUnit::Day)
.await?;
println!("{:#?}", views);
println!("Clones per day");
let clones = github
.repo(owner, repo)
.traffic()
.clones(TimeUnit::Day)
.await?;
println!("{:#?}", clones);
Ok(())
}