feat: remove iTunes release year refresh API endpoint and UI from admin page
This commit is contained in:
@@ -1718,73 +1718,7 @@ export default function AdminPage() {
|
||||
☢️ Rebuild Database
|
||||
</button>
|
||||
|
||||
<div style={{ marginTop: '1rem', borderTop: '1px solid #eee', paddingTop: '1rem' }}>
|
||||
<p style={{ marginBottom: '1rem', color: '#666' }}>
|
||||
Update release years for all songs using the iTunes API. This will overwrite existing years.
|
||||
</p>
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (window.confirm('This will scan all songs and overwrite their release years using data from iTunes. This process may take a while.\n\nContinue?')) {
|
||||
try {
|
||||
let offset = 0;
|
||||
let hasMore = true;
|
||||
let totalUpdated = 0;
|
||||
let totalSkipped = 0;
|
||||
let totalFailed = 0;
|
||||
let totalProcessed = 0;
|
||||
let totalSongs = 0;
|
||||
|
||||
setMessage('Initializing release year refresh...');
|
||||
|
||||
while (hasMore) {
|
||||
const res = await fetch('/api/admin/refresh-years', {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify({ offset, limit: 10 }) // Process 10 at a time
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error('Batch request failed');
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
totalUpdated += data.updated;
|
||||
totalSkipped += data.skipped;
|
||||
totalFailed += data.failed;
|
||||
totalProcessed += data.processed;
|
||||
totalSongs = data.total;
|
||||
hasMore = data.hasMore;
|
||||
offset = data.nextOffset;
|
||||
|
||||
setMessage(`Processing... ${totalProcessed} / ${totalSongs} songs.\nUpdated: ${totalUpdated} | Skipped: ${totalSkipped} | Failed: ${totalFailed}`);
|
||||
}
|
||||
|
||||
const finalMsg = `✅ Completed!\nTotal Processed: ${totalProcessed}\nUpdated: ${totalUpdated}\nSkipped: ${totalSkipped}\nFailed: ${totalFailed}`;
|
||||
alert(finalMsg);
|
||||
setMessage(finalMsg);
|
||||
fetchSongs(); // Refresh the table
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('Process failed due to network error or timeout.');
|
||||
setMessage('Refresh failed.');
|
||||
}
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
padding: '0.75rem 1.5rem',
|
||||
background: '#f59e0b',
|
||||
color: 'white',
|
||||
border: 'none',
|
||||
borderRadius: '0.25rem',
|
||||
cursor: 'pointer',
|
||||
fontWeight: 'bold'
|
||||
}}
|
||||
>
|
||||
🔄 Refresh Release Years (iTunes)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user