A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update UpdateLastRepo handler to insert into user_repos table

The handler now:
1. Updates users.last_repo field (existing behavior)
2. Inserts into user_repos table if not already exists
3. Updates last_used_at timestamp for the repo

This ensures selected repos are tracked in both places for persistence.

+16 -1
+16 -1
backend/internal/api/handlers/auth.go
··· 243 243 json.NewEncoder(w).Encode(response) 244 244 } 245 245 246 - // Logout logs out the current user 246 + // UpdateLastRepo updates the user's last selected repository and adds to user_repos table 247 247 func (h *AuthHandler) UpdateLastRepo(w http.ResponseWriter, r *http.Request) { 248 248 var payload struct { 249 249 LastRepo string `json:"last_repo"` ··· 266 266 return 267 267 } 268 268 269 + // Update the user's last_repo field 269 270 if err := h.db.UpdateUserRepo(userID, payload.LastRepo); err != nil { 270 271 http.Error(w, "Failed to update last repository", http.StatusInternalServerError) 271 272 return 273 + } 274 + 275 + // Also insert into user_repos table if not exists 276 + // Construct repo link from repo name 277 + repoLink := "https://github.com/" + payload.LastRepo 278 + now := time.Now() 279 + 280 + // Try to insert (will fail if already exists due to unique constraint, which is fine) 281 + _ = h.db.InsertUserRepo(userID, payload.LastRepo, repoLink, now) 282 + 283 + // Update last_used_at regardless 284 + if err := h.db.UpdateLastUsedAt(userID, payload.LastRepo, now); err != nil { 285 + // Log but don't fail - the main update already succeeded 286 + log.Printf("Warning: failed to update last_used_at for repo %s: %v", payload.LastRepo, err) 272 287 } 273 288 274 289 w.WriteHeader(http.StatusNoContent)