chore: remove unnecessary crap ai added
Some checks failed
continuous-integration/drone/pr Build is failing

This commit is contained in:
2026-04-03 19:46:05 -04:00
parent 0930054847
commit 75c872264f
7 changed files with 9 additions and 94 deletions

View File

@@ -235,21 +235,18 @@ type Document struct {
// DocumentResponse defines model for DocumentResponse.
type DocumentResponse struct {
Document Document `json:"document"`
Progress *Progress `json:"progress,omitempty"`
Document Document `json:"document"`
}
// DocumentsResponse defines model for DocumentsResponse.
type DocumentsResponse struct {
Documents []Document `json:"documents"`
Limit int64 `json:"limit"`
NextPage *int64 `json:"next_page,omitempty"`
Page int64 `json:"page"`
PreviousPage *int64 `json:"previous_page,omitempty"`
Search *string `json:"search,omitempty"`
Total int64 `json:"total"`
User UserData `json:"user"`
WordCounts []WordCount `json:"word_counts"`
Documents []Document `json:"documents"`
Limit int64 `json:"limit"`
NextPage *int64 `json:"next_page,omitempty"`
Page int64 `json:"page"`
PreviousPage *int64 `json:"previous_page,omitempty"`
Search *string `json:"search,omitempty"`
Total int64 `json:"total"`
}
// ErrorResponse defines model for ErrorResponse.
@@ -469,12 +466,6 @@ type UsersResponse struct {
Users *[]User `json:"users,omitempty"`
}
// WordCount defines model for WordCount.
type WordCount struct {
Count int64 `json:"count"`
DocumentId string `json:"document_id"`
}
// GetActivityParams defines parameters for GetActivity.
type GetActivityParams struct {
DocFilter *bool `form:"doc_filter,omitempty" json:"doc_filter,omitempty"`

View File

@@ -63,7 +63,6 @@ func (s *Server) GetDocuments(ctx context.Context, request GetDocumentsRequestOb
}
apiDocuments := make([]Document, len(rows))
wordCounts := make([]WordCount, 0, len(rows))
for i, row := range rows {
apiDocuments[i] = Document{
Id: row.ID,
@@ -83,12 +82,6 @@ func (s *Server) GetDocuments(ctx context.Context, request GetDocumentsRequestOb
UpdatedAt: time.Now(), // Will be overwritten if we had a proper updated_at from DB
Deleted: false, // Default, should be overridden if available
}
if row.Words != nil {
wordCounts = append(wordCounts, WordCount{
DocumentId: row.ID,
Count: *row.Words,
})
}
}
response := DocumentsResponse{
@@ -99,8 +92,6 @@ func (s *Server) GetDocuments(ctx context.Context, request GetDocumentsRequestOb
NextPage: nextPage,
PreviousPage: previousPage,
Search: request.Params.Search,
User: UserData{Username: auth.UserName, IsAdmin: auth.IsAdmin},
WordCounts: wordCounts,
}
return GetDocuments200JSONResponse(response), nil
}
@@ -129,21 +120,6 @@ func (s *Server) GetDocument(ctx context.Context, request GetDocumentRequestObje
doc := docs[0]
progressRow, err := s.db.Queries.GetDocumentProgress(ctx, database.GetDocumentProgressParams{
UserID: auth.UserName,
DocumentID: request.Id,
})
var progress *Progress
if err == nil {
progress = &Progress{
UserId: &progressRow.UserID,
DocumentId: &progressRow.DocumentID,
DeviceName: &progressRow.DeviceName,
Percentage: &progressRow.Percentage,
CreatedAt: ptrOf(parseTime(progressRow.CreatedAt)),
}
}
apiDoc := Document{
Id: doc.ID,
Title: *doc.Title,
@@ -165,7 +141,6 @@ func (s *Server) GetDocument(ctx context.Context, request GetDocumentRequestObje
response := DocumentResponse{
Document: apiDoc,
Progress: progress,
}
return GetDocument200JSONResponse(response), nil
}
@@ -244,20 +219,6 @@ func (s *Server) EditDocument(ctx context.Context, request EditDocumentRequestOb
doc := docs[0]
progressRow, err := s.db.Queries.GetDocumentProgress(ctx, database.GetDocumentProgressParams{
UserID: auth.UserName,
DocumentID: request.Id,
})
var progress *Progress
if err == nil {
progress = &Progress{
UserId: &progressRow.UserID,
DocumentId: &progressRow.DocumentID,
DeviceName: &progressRow.DeviceName,
Percentage: &progressRow.Percentage,
CreatedAt: ptrOf(parseTime(progressRow.CreatedAt)),
}
}
apiDoc := Document{
Id: doc.ID,
@@ -280,7 +241,6 @@ func (s *Server) EditDocument(ctx context.Context, request EditDocumentRequestOb
response := DocumentResponse{
Document: apiDoc,
Progress: progress,
}
return EditDocument200JSONResponse(response), nil
}
@@ -601,20 +561,6 @@ func (s *Server) UploadDocumentCover(ctx context.Context, request UploadDocument
doc := docs[0]
progressRow, err := s.db.Queries.GetDocumentProgress(ctx, database.GetDocumentProgressParams{
UserID: auth.UserName,
DocumentID: request.Id,
})
var progress *Progress
if err == nil {
progress = &Progress{
UserId: &progressRow.UserID,
DocumentId: &progressRow.DocumentID,
DeviceName: &progressRow.DeviceName,
Percentage: &progressRow.Percentage,
CreatedAt: ptrOf(parseTime(progressRow.CreatedAt)),
}
}
apiDoc := Document{
Id: doc.ID,
@@ -637,7 +583,6 @@ func (s *Server) UploadDocumentCover(ctx context.Context, request UploadDocument
response := DocumentResponse{
Document: apiDoc,
Progress: progress,
}
return UploadDocumentCover200JSONResponse(response), nil
}

View File

@@ -108,7 +108,6 @@ func (suite *DocumentsTestSuite) TestAPIGetDocuments() {
suite.Require().NoError(json.Unmarshal(w.Body.Bytes(), &resp))
suite.Equal(int64(1), resp.Page)
suite.Equal(int64(9), resp.Limit)
suite.Equal("testuser", resp.User.Username)
}
func (suite *DocumentsTestSuite) TestAPIGetDocumentsUnauthenticated() {

View File

@@ -300,27 +300,17 @@ components:
format: int64
search:
type: string
user:
$ref: '#/components/schemas/UserData'
word_counts:
type: array
items:
$ref: '#/components/schemas/WordCount'
required:
- documents
- total
- page
- limit
- user
- word_counts
DocumentResponse:
type: object
properties:
document:
$ref: '#/components/schemas/Document'
progress:
$ref: '#/components/schemas/Progress'
required:
- document