minor: refined scopes, some more graphing, ocd

This commit is contained in:
2024-08-01 00:01:27 +05:30
parent 9bc0cb651d
commit 149965a15b
7 changed files with 52 additions and 32 deletions

View File

@@ -73,7 +73,7 @@ const updateUser = async (req, res) => {
}
let oldPlaylists = await Playlists.findAll({
attributes: ["playlistID", "playlistName"],
attributes: ["playlistID"],
raw: true,
where: {
userID: userURI.id
@@ -97,6 +97,7 @@ const updateUser = async (req, res) => {
let removedLinks = 0;
if (toRemove.length) {
// clean up any links dependent on the playlists
removedLinks = await Links.destroy({
where: {
[Op.and]: [
@@ -110,6 +111,8 @@ const updateUser = async (req, res) => {
]
}
})
// only then remove
const cleanedUser = await Playlists.destroy({
where: { playlistID: toRemoveIDs }
});

View File

@@ -2,7 +2,7 @@ const logger = require("../utils/logger")(module);
const typedefs = require("../typedefs");
const { axiosInstance } = require('../utils/axios');
const { parseSpotifyUri, parseSpotifyLink } = require("../utils/spotifyUriTransformer");
const { parseSpotifyURI, parseSpotifyLink } = require("../utils/spotifyURITransformer");
/**
* Retrieve list of all of user's playlists
@@ -15,7 +15,7 @@ const getUserPlaylists = async (req, res) => {
// get first 50
const response = await axiosInstance.get(
`/users/${parseSpotifyUri(req.session.user.uri).id}/playlists`,
`/users/${parseSpotifyURI(req.session.user.uri).id}/playlists`,
{
params: {
offset: 0,
@@ -89,7 +89,7 @@ const getPlaylistDetails = async (req, res) => {
try {
/** @type {typedefs.Playlist} */
let playlist = {};
/** @type {typedefs.UriObject} */
/** @type {typedefs.URIObject} */
let uri;
let initialFields = ["collaborative", "description", "images", "name", "owner(uri,display_name)", "public",
"snapshot_id", "tracks(next,total,items(is_local,track(name,uri)))"];