fix(db): fix db leftovers from #1008

This commit is contained in:
MiniDigger | Martin 2022-11-10 09:09:58 +01:00
parent 05fd045edb
commit 0e8b9e6718
3 changed files with 56 additions and 14 deletions

View File

@ -54,19 +54,19 @@ public interface HealthDAO {
@UseEnumStrategy(EnumStrategy.BY_ORDINAL)
@RegisterConstructorMapper(MissingFileCheck.class)
@SqlQuery(" SELECT pv.version_string," +
" pv.file_name," +
" p.owner_name \"owner\"," +
" p.slug," +
" p.name," +
" pq.platform" +
" FROM project_versions pv" +
" JOIN projects p ON pv.project_id = p.id" +
" JOIN (SELECT DISTINCT plv.platform, pvpd.version_id" +
" FROM project_version_platform_dependencies pvpd" +
" JOIN platform_versions plv ON pvpd.platform_version_id = plv.id" +
" ) pq ON pv.id = pq.version_id " +
" WHERE pv.file_name IS NOT NULL" +
" ORDER BY pv.created_at DESC")
@SqlQuery("SELECT pv.version_string,\n" +
" pvd.file_name,\n" +
" p.owner_name \"owner\",\n" +
" p.slug,\n" +
" p.name,\n" +
" pq.platform\n" +
"FROM project_versions pv\n" +
" JOIN projects p ON pv.project_id = p.id\n" +
" JOIN (SELECT DISTINCT plv.platform, pvpd.version_id\n" +
" FROM project_version_platform_dependencies pvpd\n" +
" JOIN platform_versions plv ON pvpd.platform_version_id = plv.id) pq ON pv.id = pq.version_id\n" +
" JOIN project_version_downloads pvd ON pvd.version_id = pq.version_id\n" +
"WHERE pvd.file_name IS NOT NULL\n" +
"ORDER BY pv.created_at DESC")
List<MissingFileCheck> getVersionsForMissingFiles();
}

View File

@ -39,3 +39,45 @@ FROM (SELECT DISTINCT ON (version_id) version_id,
WHERE 2 = ANY (pc.flags)
ORDER BY pv.created_at DESC)) AS pvs) AS t
ORDER BY t.created_at DESC;
CREATE OR REPLACE VIEW pinned_projects AS
SELECT *
FROM (SELECT DISTINCT ON (project_id) project_id,
user_id,
id,
owner_name as owner,
project_members,
slug,
visibility,
views,
downloads,
recent_views,
recent_downloads,
stars,
watchers,
category,
name,
created_at,
license_type,
last_updated
FROM (SELECT pp.id,
pp.user_id,
pp.project_id,
hp.owner_name,
hp.project_members,
hp.slug,
hp.visibility,
hp.views,
hp.downloads,
hp.recent_views,
hp.recent_downloads,
hp.stars,
hp.watchers,
hp.category,
hp.name,
hp.created_at,
hp.license_type,
hp.last_updated
FROM pinned_user_projects pp
JOIN home_projects hp ON hp.id = pp.project_id
JOIN projects p on pp.project_id = p.id) AS pvs) as t;