v0.4.1 - Bug fixes and version display improvement #36

Merged
bscott merged 1 commit from v0.4.1 into main 2025-08-23 13:00:38 -04:00
bscott commented 2025-08-23 12:53:47 -04:00 (Migrated from github.com)

Summary

  • Fixed issue #35: Subscription updates now properly save all fields including dates
  • Added dynamic version display showing git commit SHA on settings page
  • Added Makefile for consistent builds with version injection

Changes

  • Fixed UpdateSubscription handler to parse date fields (start_date, renewal_date, cancellation_date)
  • Created version package for build-time version management
  • Updated settings page to display dynamic version from git commit SHA
  • Added Makefile with build targets for development and production

Testing

  • Tested subscription update functionality - all fields now save correctly
  • Verified version displays git commit SHA on settings page
  • Build process tested with Makefile

Fixes #35

## Summary - Fixed issue #35: Subscription updates now properly save all fields including dates - Added dynamic version display showing git commit SHA on settings page - Added Makefile for consistent builds with version injection ## Changes - Fixed `UpdateSubscription` handler to parse date fields (start_date, renewal_date, cancellation_date) - Created version package for build-time version management - Updated settings page to display dynamic version from git commit SHA - Added Makefile with build targets for development and production ## Testing - Tested subscription update functionality - all fields now save correctly - Verified version displays git commit SHA on settings page - Build process tested with Makefile Fixes #35
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-08-23 12:56:28 -04:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR addresses a subscription update bug and enhances version management by implementing dynamic version display. The changes ensure subscription date fields are properly saved during updates and add build-time version injection showing git commit SHA.

  • Fixed subscription update handler to properly parse and save date fields (start_date, renewal_date, cancellation_date)
  • Added version package with build-time git commit SHA injection
  • Created comprehensive Makefile for consistent builds and development workflow

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
internal/handlers/subscription.go Added date parsing logic to fix subscription update bug and version import for settings page
internal/version/version.go New package for build-time version management with git commit SHA support
templates/settings.html Updated to display dynamic version from template data instead of hardcoded value
Makefile New build configuration with version injection and multi-platform support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

## Pull Request Overview This PR addresses a subscription update bug and enhances version management by implementing dynamic version display. The changes ensure subscription date fields are properly saved during updates and add build-time version injection showing git commit SHA. - Fixed subscription update handler to properly parse and save date fields (start_date, renewal_date, cancellation_date) - Added version package with build-time git commit SHA injection - Created comprehensive Makefile for consistent builds and development workflow ### Reviewed Changes Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments. | File | Description | | ---- | ----------- | | internal/handlers/subscription.go | Added date parsing logic to fix subscription update bug and version import for settings page | | internal/version/version.go | New package for build-time version management with git commit SHA support | | templates/settings.html | Updated to display dynamic version from template data instead of hardcoded value | | Makefile | New build configuration with version injection and multi-platform support | --- <sub>**Tip:** Customize your code reviews with copilot-instructions.md. <a href="/bscott/subtrackr/new/main/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-23 12:56:27 -04:00

Date parsing errors are silently ignored. Consider logging parse errors or returning validation errors to provide feedback when users submit invalid date formats.

			subscription.StartDate = &startDate
		} else {
			c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid start_date format: %v", err)})
			c.Abort()
			return
		}
	}

	if renewalDateStr := c.PostForm("renewal_date"); renewalDateStr != "" {
		if renewalDate, err := time.Parse("2006-01-02", renewalDateStr); err == nil {
			subscription.RenewalDate = &renewalDate
		} else {
			c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid renewal_date format: %v", err)})
			c.Abort()
			return
		}
	}

	if cancellationDateStr := c.PostForm("cancellation_date"); cancellationDateStr != "" {
		if cancellationDate, err := time.Parse("2006-01-02", cancellationDateStr); err == nil {
			subscription.CancellationDate = &cancellationDate
		} else {
			c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid cancellation_date format: %v", err)})
			c.Abort()
			return
Date parsing errors are silently ignored. Consider logging parse errors or returning validation errors to provide feedback when users submit invalid date formats. ```suggestion subscription.StartDate = &startDate } else { c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid start_date format: %v", err)}) c.Abort() return } } if renewalDateStr := c.PostForm("renewal_date"); renewalDateStr != "" { if renewalDate, err := time.Parse("2006-01-02", renewalDateStr); err == nil { subscription.RenewalDate = &renewalDate } else { c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid renewal_date format: %v", err)}) c.Abort() return } } if cancellationDateStr := c.PostForm("cancellation_date"); cancellationDateStr != "" { if cancellationDate, err := time.Parse("2006-01-02", cancellationDateStr); err == nil { subscription.CancellationDate = &cancellationDate } else { c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid cancellation_date format: %v", err)}) c.Abort() return ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-23 12:56:27 -04:00

Date parsing errors are silently ignored. Consider logging parse errors or returning validation errors to provide feedback when users submit invalid date formats.

			subscription.StartDate = &startDate
		} else {
			c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid start_date format: %v", err)})
			return
		}
	}

	if renewalDateStr := c.PostForm("renewal_date"); renewalDateStr != "" {
		if renewalDate, err := time.Parse("2006-01-02", renewalDateStr); err == nil {
			subscription.RenewalDate = &renewalDate
		} else {
			c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid renewal_date format: %v", err)})
			return
		}
	}

	if cancellationDateStr := c.PostForm("cancellation_date"); cancellationDateStr != "" {
		if cancellationDate, err := time.Parse("2006-01-02", cancellationDateStr); err == nil {
			subscription.CancellationDate = &cancellationDate
		} else {
			c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid cancellation_date format: %v", err)})
			return
Date parsing errors are silently ignored. Consider logging parse errors or returning validation errors to provide feedback when users submit invalid date formats. ```suggestion subscription.StartDate = &startDate } else { c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid start_date format: %v", err)}) return } } if renewalDateStr := c.PostForm("renewal_date"); renewalDateStr != "" { if renewalDate, err := time.Parse("2006-01-02", renewalDateStr); err == nil { subscription.RenewalDate = &renewalDate } else { c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid renewal_date format: %v", err)}) return } } if cancellationDateStr := c.PostForm("cancellation_date"); cancellationDateStr != "" { if cancellationDate, err := time.Parse("2006-01-02", cancellationDateStr); err == nil { subscription.CancellationDate = &cancellationDate } else { c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid cancellation_date format: %v", err)}) return ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-23 12:56:28 -04:00

Date parsing errors are silently ignored. Consider logging parse errors or returning validation errors to provide feedback when users submit invalid date formats.

			subscription.StartDate = &startDate
		} else {
			validationErrors["start_date"] = "Invalid start date format (expected YYYY-MM-DD)"
		}
	}

	if renewalDateStr := c.PostForm("renewal_date"); renewalDateStr != "" {
		if renewalDate, err := time.Parse("2006-01-02", renewalDateStr); err == nil {
			subscription.RenewalDate = &renewalDate
		} else {
			validationErrors["renewal_date"] = "Invalid renewal date format (expected YYYY-MM-DD)"
		}
	}

	if cancellationDateStr := c.PostForm("cancellation_date"); cancellationDateStr != "" {
		if cancellationDate, err := time.Parse("2006-01-02", cancellationDateStr); err == nil {
			subscription.CancellationDate = &cancellationDate
		} else {
			validationErrors["cancellation_date"] = "Invalid cancellation date format (expected YYYY-MM-DD)"
		}
	}

	// If there are validation errors, return them to the user
	if len(validationErrors) > 0 {
		c.Header("HX-Retarget", "#form-errors")
		c.HTML(http.StatusBadRequest, "form-errors.html", gin.H{
			"ValidationErrors": validationErrors,
		})
		return
	}
Date parsing errors are silently ignored. Consider logging parse errors or returning validation errors to provide feedback when users submit invalid date formats. ```suggestion subscription.StartDate = &startDate } else { validationErrors["start_date"] = "Invalid start date format (expected YYYY-MM-DD)" } } if renewalDateStr := c.PostForm("renewal_date"); renewalDateStr != "" { if renewalDate, err := time.Parse("2006-01-02", renewalDateStr); err == nil { subscription.RenewalDate = &renewalDate } else { validationErrors["renewal_date"] = "Invalid renewal date format (expected YYYY-MM-DD)" } } if cancellationDateStr := c.PostForm("cancellation_date"); cancellationDateStr != "" { if cancellationDate, err := time.Parse("2006-01-02", cancellationDateStr); err == nil { subscription.CancellationDate = &cancellationDate } else { validationErrors["cancellation_date"] = "Invalid cancellation date format (expected YYYY-MM-DD)" } } // If there are validation errors, return them to the user if len(validationErrors) > 0 { c.Header("HX-Retarget", "#form-errors") c.HTML(http.StatusBadRequest, "form-errors.html", gin.H{ "ValidationErrors": validationErrors, }) return } ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-23 12:56:28 -04:00

The date parsing logic is duplicated three times with identical patterns. Consider extracting this into a helper function to reduce code duplication and improve maintainability.

	subscription.StartDate = parseDatePtr(c.PostForm("start_date"))
	subscription.RenewalDate = parseDatePtr(c.PostForm("renewal_date"))
	subscription.CancellationDate = parseDatePtr(c.PostForm("cancellation_date"))
The date parsing logic is duplicated three times with identical patterns. Consider extracting this into a helper function to reduce code duplication and improve maintainability. ```suggestion subscription.StartDate = parseDatePtr(c.PostForm("start_date")) subscription.RenewalDate = parseDatePtr(c.PostForm("renewal_date")) subscription.CancellationDate = parseDatePtr(c.PostForm("cancellation_date")) ```
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bscott/subtrackr!36
No description provided.