FreshPorts / freshports

The website part of FreshPorts
http://www.freshports.org/
BSD 2-Clause "Simplified" License
70 stars 24 forks source link

Old categories are not purged when they are no longer active #479

Closed dlangille closed 1 year ago

dlangille commented 1 year ago

Categories come and go. FreshPorts handles new categories. It does not detect and remove categories.

NOTE: We can't delete old categories if there are deleted ports in those categories (e.g. palm).

This came about from #473

So far, I see these which should be removed: ipv6 erlang offix palm paralell perl php picobsd python:2.7 tcl80 tcl81 tcl82 tcl83 tcl84 tk42 tk80 tk82 tk83 tk84 tkstep90 wip

Remove only if not used.

Case in point, sometimes a category is created in error:

freshports.devgit=# select * from categories where name = 'paralell';
 id | is_primary | element_id |   name   |                       description                        
----+------------+------------+----------+----------------------------------------------------------
 93 | f          |            | paralell | This is a virtual category. No description is available.
(1 row)

freshports.devgit=# select * from categories where name = 'parallel';
 id | is_primary | element_id |   name   |                     description                     
----+------------+------------+----------+-----------------------------------------------------
 68 | f          |            | parallel | Applications dealing with parallelism in computing.
(1 row)

freshports.devgit=# 
dlangille commented 1 year ago

We got a whole bunch in use:

freshports.devgit=# select count(*), categories.name from ports_categories join categories on ports_categories.category_id = categories.id  where category_id in (select id from categories where name in ('ipv6', 'erlang', 'offix', 'palm', 'paralell', 'perl', 'php', 'picobsd', 'python:2.7', 'tcl80', 'tcl81', 'tcl82', 'tcl83', 'tcl84', 'tk42', 'tk80', 'tk82', 'tk83', 'tk84', 'tkstep90', 'wip')) group by categories.name order by categories.name;
 count |  name   
-------+---------
  1709 | ipv6
    70 | palm
     1 | picobsd
     2 | tcl80
     1 | tcl81
     2 | tcl82
     1 | tcl83
     5 | tcl84
     2 | tk42
     4 | tk80
     8 | tk82
     2 | tk83
     6 | tk84
(13 rows)

freshports.devgit=# 
dlangille commented 1 year ago

How often are these used?


with suspects as (
select name from categories where name in 
('ipv6', 'erlang', 'offix', 'palm', 'paralell', 'perl', 'php', 'picobsd', 'python:2.7', 'tcl80', 'tcl81', 'tcl82', 'tcl83', 'tcl84', 'tk42', 'tk80', 'tk82', 'tk83', 'tk84', 'tkstep90', 'wip')
)
select suspects.name, count(*) 
from suspects join categories on categories.name = suspects.name
left outer join ports_categories on ports_categories.category_id = categories.id
 group by suspects.name;

    name    | count 
------------+-------
 erlang     |     1
 ipv6       |  1709
 offix      |     1
 palm       |    70
 paralell   |     1
 perl       |     1
 php        |     1
 picobsd    |     1
 python:2.7 |     1
 tcl80      |     2
 tcl81      |     1
 tcl82      |     2
 tcl83      |     1
 tcl84      |     5
 tk42       |     2
 tk80       |     4
 tk82       |     8
 tk83       |     2
 tk84       |     6
 wip        |     1
(20 rows)

freshports.devgit=# 
dlangille commented 1 year ago

NOTE: We can't delete old categories if there are deleted ports in those categories (e.g. palm).