mkitzmann / awwesome

Enhanced user interface for Awesome Selfhosted
https://awweso.me
BSD 3-Clause "New" or "Revised" License
245 stars 14 forks source link

Sort by recently added? #2

Open ItsNoted opened 10 months ago

ItsNoted commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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

I will follow up over there.

mkitzmann commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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

I will see how this can be integrated.

mkitzmann commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

Sounds reasonable to me!

modem7 commented 6 months ago

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 commented 6 months ago

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.