-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Hide retired packages #24
Conversation
Running codegen changed the generated sql.gleam file a lot, I'm not sure if it's intended |
I'm not sure if this behavior is what we want, and I should improve error handling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we hide them rather than deleting them please? 🙏
Weird how the ordering of the functions in the generated module has changed. Maybe we should make it sort them by name to avoid this in future.
@lpil I just found that there is a table named Before this discovery, I was planning to add an |
That table is for packages that have been deliberately hidden by us rather than retired by the package maintainer. I think it would be tricky to make that table mutable and not accidentally remove its contents thinking they are not retired. Let's use the retirement field on releases. I don't think we'll have performance problems querying both tables, so we can avoid making a cache on the packages table for now. |
Oh, I did not realize we had the retirement state in the database. This will make things easier 🙂 |
src/packages/index.gleam
Outdated
max(inserted_in_hex_at) | ||
) | ||
where | ||
retirement_reason is not null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you instead make a non_retired_packages
view? I think that would be easier to use and it wouldn't have to read the entire table to filter a single package. Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done! (I learned some new things about sqlite along the way but it seems to work).
I had to adjust the text search query because sqlite views don't have rowid
s, but the search seems to behave the same way as it does in production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. One small thing below
src/packages/index.gleam
Outdated
@@ -141,6 +141,25 @@ create table if not exists hidden_packages ( | |||
name text primary key | |||
) strict; | |||
|
|||
create view if not exists non_retired_packages as | |||
-- A package is retired if its latest release is retired |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A package is retired if all its releases are retired. Something like this:
create view non_retired_packages as
select
p.id
, p.name
, p.description
, p.docs_url
, p.links
, p.updated_in_hex_at
from packages p
where p.id in (
select distinct r.package_id
from releases r
where r.id is null or r.retirement_reason is null
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops! Fixed, thanks for the explanation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Closes #18
This PR adds two things: