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

Sort by recently added? #2

Open
ItsNoted opened this issue Aug 26, 2023 · 18 comments
Open

Sort by recently added? #2

ItsNoted opened this issue Aug 26, 2023 · 18 comments

Comments

@ItsNoted
Copy link

Love the site and repo awesome-selfhosted. Is there any chance you can add a filter to sort by most recently added to the repo?

Thank you!

@mkitzmann
Copy link
Owner

Thank you for the idea.

The problem here is that the project currently does not save any data for the previous run. So it wouldnt know which projects were added.

It could work by generating a json file for every run that includes the date a project was first added. On consecutive runs this json could be read and updated.

I will try to find a good solution for this.

@adamshand
Copy link

Come to request the same thing! I’d love to be able to check in and see what’s new.

Thanks for the great project!

@mkitzmann
Copy link
Owner

I implemented a first version of this. You can check it out on https://awweso.me/

Only problem is it doesnt work for the past since there is no data when a project was added.

Im considering using the date of the first commit instead since I can query that easily from Github.

@adamshand
Copy link

This is great, thanks! I think there's something a bit screwy going on though. Not sure what the empty Reddit etc cards are?

image

@mkitzmann
Copy link
Owner

mkitzmann commented Sep 3, 2023

I noticed that as well and created an issue for it.

I will follow up over there.

@mkitzmann
Copy link
Owner

For now I changed the sort mechanism to use "Recently Created" in general. That data is more easily available since I can get the createdAt field from the Github API.

Do you think the "Recently Added" sorting is necessary as well?

@ItsNoted
Copy link
Author

ItsNoted commented Sep 3, 2023

Well something is not right. I know Caddy is not new and it hasn't been for a long time lol. Why would it show under "Recently Added" as the first one?

chrome_cIizd5fBbA

@mkitzmann
Copy link
Owner

Just updated the demo to v0.6 which is showing "Recently Created".

The reason "Recently Added" did not work as expected is because there was no way to determine when a project was first added to Awesome selfhosted (except for maybe going through the commit history). So I could only save the projects of the previous run and check if any new projects were added. This obviously only works for the future, which is why I changed it to "Recently Created"

@ItsNoted
Copy link
Author

ItsNoted commented Sep 3, 2023

I see. I also found this which seems to work good. https://www.trackawesomelist.com/awesome-selfhosted/awesome-selfhosted/

I thought maybe you could get something from this.

@mkitzmann
Copy link
Owner

Thats really great! Thanks for the input! Would be fantastic to use that data.

I will see how this can be integrated.

@mkitzmann
Copy link
Owner

It looks like they use git blame data to determine the date a project was added.

So this could be done with a query like this

query {
  repositoryOwner(login: "awesome-selfhosted") {
    repository(name: "awesome-selfhosted") {
      defaultRef
        ... on Commit {
          blame(path: "README.md") {
            ranges {
              startingLine
              endingLine
              age
              commit {
                commitedDate
              }
            }
          }
        }
      }
    }
  }
}

@adamshand
Copy link

Whatever they are doing I'm not sure it's super reliable, seems unlikely that AdGuardHome would have been added a couple months ago?

image

@mkitzmann
Copy link
Owner

My guess is they track every change of a project not just the addition.
Its actually quite difficult to determine when a project was first added.

  1. You could iterate the commits and register only the ones that had added lines and no removed lines, which probably is not trivial.
  2. You could track when new projects are added by saving the previous state of the markdown file, which will only work for the future.
  3. you could use git blame, but that wont tell you wheter a project was changed or added.

@adamshand
Copy link

I vote for #2.

The point of the feature is to be able to learn about new things, not to be able to browse the history of everything.

@mkitzmann
Copy link
Owner

I also think that is the most useful feature. Maybe giving every existing project the date of creation of the repo and from then on track when a project was added to the repo. This way the initial projects arent just randomly sorted and you still have the benefit of seeing when new projects are added in the future.

@adamshand
Copy link

Sounds reasonable to me!

@modem7
Copy link

modem7 commented Jan 2, 2024

How about using the Github API?

E.g. https://api.github.com/repos/AdguardTeam/AdGuardHome

"created_at": "2016-07-06T10:31:47Z",

And if required for a "recently updated":

"updated_at": "2024-01-02T17:44:12Z",

or

"pushed_at": "2023-12-29T15:30:17Z",

It would be trivial to extract the data, but I'm unsure what the call limits are for the API.

Source: https://mycyberuniverse.com/en-gb/how-know-creation-date-github-repository.html

@mkitzmann
Copy link
Owner

Thanks @modem7 for your suggestion.
The problem is that it would be most interesting to see projects that were most recently added to awesome selfhosted and this information is not easily extractable from the awesome selfhosted repo.
I have already added a filter to sort by "most recently created" which uses the Github API as you suggested.
Concerning the rate limit, the GraphQL API is much more foregiving on this than the REST API so that would not be a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Up Next
Development

No branches or pull requests

4 participants