Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 207 additions & 0 deletions api/dbv1/get_sitemap.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions api/dbv1/queries/get_sitemap.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
-- name: GetSitemapTrackCount :one
SELECT count(*) as count
FROM track_routes tr
JOIN tracks t ON tr.track_id = t.track_id
JOIN users u ON tr.owner_id = u.user_id
JOIN aggregate_user au ON u.user_id = au.user_id
WHERE t.is_current = true
AND t.stem_of IS NULL
AND t.is_unlisted = false
AND t.is_available = true
AND t.is_delete = false
AND u.is_current = true
AND tr.is_current = true
AND au.follower_count >= 10;

-- name: GetSitemapTrackSlugs :many
SELECT u.handle, tr.slug
FROM track_routes tr
JOIN tracks t ON tr.track_id = t.track_id
JOIN users u ON tr.owner_id = u.user_id
JOIN aggregate_user au ON u.user_id = au.user_id
WHERE t.is_current = true
AND t.stem_of IS NULL
AND t.is_unlisted = false
AND t.is_available = true
AND t.is_delete = false
AND u.is_current = true
AND tr.is_current = true
AND au.follower_count >= 10
ORDER BY t.track_id ASC
LIMIT $1 OFFSET $2;

-- name: GetSitemapPlaylistCount :one
SELECT count(*) as count
FROM playlist_routes pr
JOIN playlists p ON pr.playlist_id = p.playlist_id
JOIN users u ON pr.owner_id = u.user_id
JOIN aggregate_user au ON u.user_id = au.user_id
WHERE u.is_current = true
AND pr.is_current = true
AND p.is_current = true
AND p.is_private = false
AND p.is_delete = false
AND au.follower_count >= 10;

-- name: GetSitemapPlaylistSlugs :many
SELECT u.handle, pr.slug, p.is_album
FROM playlist_routes pr
JOIN playlists p ON pr.playlist_id = p.playlist_id
JOIN users u ON pr.owner_id = u.user_id
JOIN aggregate_user au ON u.user_id = au.user_id
WHERE u.is_current = true
AND pr.is_current = true
AND p.is_current = true
AND p.is_private = false
AND p.is_delete = false
AND au.follower_count >= 10
ORDER BY p.playlist_id ASC
LIMIT $1 OFFSET $2;

-- name: GetSitemapUserCount :one
SELECT count(*) as count
FROM users u
JOIN aggregate_user au ON u.user_id = au.user_id
WHERE u.is_current = true
AND u.is_deactivated = false
AND u.handle_lc IS NOT NULL
AND u.is_available = true
AND au.follower_count >= 10;

-- name: GetSitemapUserSlugs :many
SELECT u.handle
FROM users u
JOIN aggregate_user au ON u.user_id = au.user_id
WHERE u.is_current = true
AND u.is_deactivated = false
AND u.handle_lc IS NOT NULL
AND u.is_available = true
AND au.follower_count >= 10
ORDER BY u.user_id ASC
LIMIT $1 OFFSET $2;
6 changes: 6 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ func NewApiServer(config config.Config) *ApiServer {
// Archiver proxy
app.All("/archive/*", archiveProxy)

// Sitemaps
app.Get("/sitemaps/default.xml", app.sitemapDefault)
app.Get("/sitemaps/defaults.xml", app.sitemapDefaults)
app.Get("/sitemaps/:type/index.xml", app.sitemapTypeIndex)
app.Get("/sitemaps/:type/:fileName", app.sitemapTypePage)

// resolve myId
app.Use(app.isFullMiddleware)
app.Use(app.resolveMyIdMiddleware)
Expand Down
Loading
Loading