Refactor brand service and related components
- Removed ListQuestionVersions method and associated types from BrandService and Queries. - Updated PromptRuleGenerationService to change task naming and handling. - Enhanced ScheduleTaskService to support filtering by created date range and keyword. - Introduced InstantTaskService for managing instant tasks with appropriate filtering and response structures. - Added InstantTaskHandler for handling API requests related to instant tasks. - Created InstantTaskTab component for the admin web interface to display and manage instant tasks. - Updated database migrations to rename source types for articles and generation tasks. - Adjusted models and repository queries to reflect the removal of question version handling.
This commit is contained in:
@@ -429,46 +429,6 @@ func (s *BrandService) DeleteQuestion(ctx context.Context, brandID, questionID i
|
||||
return nil
|
||||
}
|
||||
|
||||
type QuestionVersionResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
QuestionID int64 `json:"question_id"`
|
||||
QuestionText string `json:"question_text"`
|
||||
QuestionHash string `json:"question_hash"`
|
||||
VersionNo int `json:"version_no"`
|
||||
IsActive bool `json:"is_active"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
func (s *BrandService) ListQuestionVersions(ctx context.Context, brandID int64) ([]QuestionVersionResponse, error) {
|
||||
actor := auth.MustActor(ctx)
|
||||
rows, err := s.pool.Query(ctx, `
|
||||
SELECT v.id, v.question_id, v.question_text, v.question_hash, v.version_no, v.is_active, v.created_at
|
||||
FROM brand_question_versions v
|
||||
JOIN brand_questions q ON q.id = v.question_id
|
||||
WHERE q.brand_id = $1 AND q.tenant_id = $2
|
||||
ORDER BY v.created_at DESC
|
||||
`, brandID, actor.TenantID)
|
||||
if err != nil {
|
||||
return nil, response.ErrInternal(50010, "query_failed", "failed to list question versions")
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var versions []QuestionVersionResponse
|
||||
for rows.Next() {
|
||||
var v QuestionVersionResponse
|
||||
var ca interface{}
|
||||
if err := rows.Scan(&v.ID, &v.QuestionID, &v.QuestionText, &v.QuestionHash, &v.VersionNo, &v.IsActive, &ca); err != nil {
|
||||
return nil, response.ErrInternal(50010, "scan_failed", err.Error())
|
||||
}
|
||||
v.CreatedAt = fmt.Sprintf("%v", ca)
|
||||
versions = append(versions, v)
|
||||
}
|
||||
if versions == nil {
|
||||
versions = []QuestionVersionResponse{}
|
||||
}
|
||||
return versions, nil
|
||||
}
|
||||
|
||||
// --- Competitor CRUD ---
|
||||
|
||||
type CompetitorRequest struct {
|
||||
|
||||
Reference in New Issue
Block a user