Skip to content

Conversation

@gitgc
Copy link
Owner

@gitgc gitgc commented Aug 11, 2025

No description provided.

Copilot AI review requested due to automatic review settings August 11, 2025 23:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive image upload functionality for the application by reorganizing file paths, enhancing session management with PostgreSQL storage, and adding image preview capabilities.

  • Migrates session storage from memory to PostgreSQL using connect-pg-simple
  • Reorganizes upload directory structure to separate driver and circuit images
  • Adds client-side image preview functionality with validation and immediate feedback

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/appConfig.js Configures PostgreSQL session store with connection pooling and error handling
src/routes/raceSettings.js Updates circuit image path to use new directory structure
src/routes/leaderboard.js Updates profile picture path to use new directory structure
src/middleware/upload.js Implements UUID-based filename generation and organized upload directories
public/styles.css Adds styling for image preview containers with animations
public/js/modals.js Integrates preview clearing functionality into modal lifecycle
public/js/main.js Adds image preview initialization and new event handlers
public/js/imagePreview.js New module providing comprehensive image preview functionality
public/js/forms.js Enhanced form handling with immediate profile picture updates
public/index.html Adds preview containers and updates form structure
package.json Adds connect-pg-simple dependency for PostgreSQL sessions
docker-compose.yml Updates volume mounting strategy for uploads
Dockerfile Creates organized directory structure for uploads


export function triggerCircuitImageUpload() {
document.getElementById('circuitImageInput').click()
document.getElementById('circuitImageUpload').click()
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ID 'circuitImageUpload' doesn't match the ID referenced in triggerFileUpload() function which uses 'profilePictureInput'. This inconsistency could cause the function to fail silently if the element doesn't exist.

Suggested change
document.getElementById('circuitImageUpload').click()
document.getElementById('profilePictureInput').click()

Copilot uses AI. Check for mistakes.
*/
export function initializeImagePreviews() {
// Setup preview for add driver modal
setupImagePreview('profilePictureAdd', 'addPicturePreviewContainer', 'addPicturePreview')
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file input ID 'profilePictureAdd' doesn't match the actual ID 'profilePictureAdd' in the HTML, but the HTML shows 'profilePictureAdd' while other references in the codebase use 'profilePictureInput'. This mismatch could prevent the preview functionality from working for the add driver modal.

Suggested change
setupImagePreview('profilePictureAdd', 'addPicturePreviewContainer', 'addPicturePreview')
setupImagePreview('profilePictureInput', 'addPicturePreviewContainer', 'addPicturePreview')

Copilot uses AI. Check for mistakes.
pool: pgPool,
tableName: 'session', // Table name for storing sessions
createTableIfMissing: true, // Auto-create table if it doesn't exist
pruneSessionInterval: 60 * 15, // Prune expired sessions every 15 minutes
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The magic number '60 * 15' should be extracted to a named constant like 'SESSION_PRUNE_INTERVAL_SECONDS' to improve code readability and maintainability.

Suggested change
pruneSessionInterval: 60 * 15, // Prune expired sessions every 15 minutes
pruneSessionInterval: SESSION_PRUNE_INTERVAL_SECONDS, // Prune expired sessions every 15 minutes

Copilot uses AI. Check for mistakes.
@gitgc gitgc closed this Aug 11, 2025
@gitgc gitgc reopened this Aug 11, 2025
@gitgc gitgc merged commit 3e60802 into main Aug 11, 2025
14 checks passed
@gitgc gitgc deleted the fix-image-uploads branch August 11, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants