Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github repository age #9754

Closed
nektro opened this issue Nov 22, 2023 · 4 comments · Fixed by #9981
Closed

github repository age #9754

nektro opened this issue Nov 22, 2023 · 4 comments · Fixed by #9981
Labels
service-badge New or updated service badge

Comments

@nektro
Copy link

nektro commented Nov 22, 2023

📋 Description

  • github
  • either the created on date itself, or something like "3 months" / "2 years"

🔗 Data

https://api.github.com/repos/{:owner}/{:repository} + .created_at

🎤 Motivation

this info isn't shown on github desktop by default and would be nice to show off the maturity of a project

@nektro nektro added the service-badge New or updated service badge label Nov 22, 2023
@erayerdin
Copy link
Contributor

@chris48s, if it's okay, I can take this. The only question is how we'd render the datetime. There are three ways I can come up with:

Prettified Human-Readable Format

Would look similar to these:

minutes ago badge
years ago badge
just now badge

Pros:

  • Look pretty
  • Human-readable

Cons:

  • Ambiguous (5 months ago but when exactly?)
  • Would require to introduce another dependency to the codebase unless this kinda thing is enough

Standardized

Might be ISO-8601. Example:

iso badge

Pros:

  • A little bit verbose
    Cons:
  • Too much verbose if we are going to include time and timezone
  • There are other standards to think about. See this beautiful thing.

So, there are a couple of questions as well.

  • In two cases (and even more than two if we consider the other standards), should we create distinct services for that? If so:
    • Pretty badges would lay under /github/created-at/pretty/:username/:reponame.
    • What about the standardized ones? Should we (a) distinct each as /github/created-at/iso/:username/:reponame and /github/created-at/rfc/:username/:reponame and such or (b) use /github/created-at/standardized/:username/:reponame?format=rfc with format query parameter defaulting to iso?

Case (a) requires two different classes (maybe extending a base CreatedAtBase?) while case (b) can be done in a single class but requires query parameters, which must be documented. Documentation part for case (b) is easy anyway, OpenAPI spec already handles that, but case (a) seems more expressive than the other when you think about it.

@erayerdin
Copy link
Contributor

Apart from @nektro's assertion "nice to show off the maturity of a project", in the current UI of Github, the only way to know exactly when a project started is to do these steps:

Step 1: Click the commit count on the project page.
click commit count

Step 2: Click next until you reach the initial commit / until the big bang. If the commit count is several hundred, this is really painful.
click next until the big bang

Step 3: Hover over the prettified datetime on the initial commit to learn when you've started the project.
hover over the prettified datetime

AFAIK, there's no other easier way (unless one curls to the API). So, this would really benefit the community.

@chris48s
Copy link
Member

I would say do 1 version and use the formatDate() helper function

/**
* Returns a formatted date string without the year based on the value of input date param d.
*
* @param {Date | string | number | object } d - Input date in dayjs compatible format, date object, datestring, Unix timestamp etc.
* @returns {string} Formatted date string
*/
function formatDate(d) {
const date = dayjs(d)
const dateString = date.calendar(null, {
lastDay: '[yesterday]',
sameDay: '[today]',
lastWeek: '[last] dddd',
sameElse: 'MMMM YYYY',
})
// Trim current year from date string
return dateString.replace(` ${dayjs().year()}`, '').toLowerCase()
}

That would be consistent with how we do other similar badges e.g: "last commit", "release date", "last updated" type badges.

@erayerdin
Copy link
Contributor

New to the codebase so wasn't aware this was a thing. So, I take this as I can start working on a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants