Derrick Tay
Derrick Tay

Reputation: 11

Listing Github organization user last access date

Was trying to list out the users which is not active for 30 days, so wanted to do a housekeeping for organization github users. Is there any way of listing out with this criteria? I do found out Github users API and there is one response field called updated_at, but this field will only updated when github profile is being update and this API only query on one particular user.

https://docs.github.com/en/enterprise-cloud@latest/rest/reference/users#list-users

Currently using github Enterprise Cloud version, and by default whoever user is not active for 90 days it will be suspended, also wondering is there a way to finding the remaining days/time to suspend user?

Upvotes: 1

Views: 1023

Answers (1)

VonC
VonC

Reputation: 1329092

A graphQL Repository has RepositoryInfo with an updatedAt field.

That means a GraphQL search (which has the same sort option than GitHub website, meaning is sorted by updatedAt by default) would list all repositories from an organization.

You would then need to iterate through the results in order to detects the one updated with a date matching your criteria.


{
  "queryString": "org:google"
}

query myOrgRepos($queryString: String!) {
  search(query: $queryString, type: REPOSITORY, first: 10) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          name
          updatedAt
        }
      }
    }
  }
}

Upvotes: 0

Related Questions