fix: upload ai table exports to oss
This commit is contained in:
@@ -135,6 +135,16 @@ type AIFileMetadata struct {
|
||||
Location string
|
||||
}
|
||||
|
||||
type CompletedFileUpload struct {
|
||||
ID int64
|
||||
UserID int64
|
||||
MIMEType string
|
||||
Size int64
|
||||
ETag string
|
||||
Location string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (s *Store) AICapabilities(ctx context.Context) ([]AICapability, error) {
|
||||
var items []AICapability
|
||||
err := s.db.SelectContext(ctx, &items, `SELECT feature,enabled,model,daily_limit,concurrency_limit,
|
||||
@@ -315,6 +325,36 @@ func (s *Store) SaveAITableAnalysis(ctx context.Context, tenantCode string, user
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func (s *Store) SaveCompletedFileUpload(ctx context.Context, file CompletedFileUpload) error {
|
||||
now := file.CreatedAt.UTC().Round(time.Millisecond)
|
||||
if now.IsZero() {
|
||||
now = time.Now().UTC().Round(time.Millisecond)
|
||||
}
|
||||
_, err := s.db.ExecContext(ctx, `INSERT INTO im_fileuploads
|
||||
(tenant_id,id,createdat,updatedat,userid,status,mimetype,size,etag,location)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,?)`,
|
||||
s.tenant(), file.ID, now, now, formatInt64(file.UserID), 1, file.MIMEType, file.Size, file.ETag, file.Location)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) UpdateAITableAnalysisExportFileID(ctx context.Context, userID int64, recordID, fileID string) error {
|
||||
now := time.Now().UTC().Round(time.Millisecond)
|
||||
res, err := s.db.ExecContext(ctx, `UPDATE wb_ai_table_analysis SET export_file_id=?,updated_at=?
|
||||
WHERE tenant_id=? AND user_id=? AND record_id=?`,
|
||||
fileID, now, s.tenant(), formatInt64(userID), recordID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
affected, err := res.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if affected == 0 {
|
||||
return ErrNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Store) AITableAnalyses(ctx context.Context, userID int64, queryText, cursor string, limit int) ([]AIRecord, string, error) {
|
||||
return s.aiRecords(ctx, userID, "smart_table", queryText, cursor, limit)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user