Skip to main content

github_rust/
config.rs

1use std::time::Duration;
2
3pub const GITHUB_API_URL: &str = "https://api.github.com";
4pub const GITHUB_GRAPHQL_URL: &str = "https://api.github.com/graphql";
5pub const USER_AGENT: &str = concat!("github-rust/", env!("CARGO_PKG_VERSION"));
6pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);
7
8pub const GRAPHQL_REPOSITORY_QUERY: &str = r#"
9query($owner: String!, $name: String!) {
10  repository(owner: $owner, name: $name) {
11    id
12    databaseId
13    name
14    nameWithOwner
15    description
16    url
17    homepageUrl
18    createdAt
19    updatedAt
20    pushedAt
21    isPrivate
22    isFork
23    isArchived
24    stargazerCount
25    forkCount
26    watchers {
27      totalCount
28    }
29    issues(states: OPEN) {
30      totalCount
31    }
32    pullRequests {
33      totalCount
34    }
35    releases {
36      totalCount
37    }
38    primaryLanguage {
39      name
40      color
41    }
42    languages(first: 100, orderBy: {field: SIZE, direction: DESC}) {
43      pageInfo { hasNextPage }
44      edges {
45        size
46        node {
47          name
48          color
49        }
50      }
51    }
52    licenseInfo {
53      name
54      spdxId
55    }
56    defaultBranchRef {
57      name
58    }
59    repositoryTopics(first: 100) {
60      edges {
61        node {
62          topic {
63            name
64          }
65        }
66      }
67    }
68  }
69}
70"#;
71
72pub const GRAPHQL_SEARCH_REPOSITORIES_QUERY: &str = r#"
73query($queryString: String!, $first: Int!, $after: String) {
74  search(query: $queryString, type: REPOSITORY, first: $first, after: $after) {
75    repositoryCount
76    pageInfo {
77      hasNextPage
78      endCursor
79    }
80    edges {
81      node {
82        ... on Repository {
83          id
84          databaseId
85          name
86          nameWithOwner
87          description
88          url
89          stargazerCount
90          forkCount
91          createdAt
92          updatedAt
93          pushedAt
94          primaryLanguage {
95            name
96            color
97          }
98          licenseInfo {
99            name
100            spdxId
101          }
102          repositoryTopics(first: 100) {
103            edges {
104              node {
105                topic {
106                  name
107                }
108              }
109            }
110          }
111        }
112      }
113    }
114  }
115}
116"#;