diff --git a/api/v1/api.gen.go b/api/v1/api.gen.go index 1e32df5..7a3dba6 100644 --- a/api/v1/api.gen.go +++ b/api/v1/api.gen.go @@ -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"` diff --git a/api/v1/documents.go b/api/v1/documents.go index 92e8fb0..242ed6e 100644 --- a/api/v1/documents.go +++ b/api/v1/documents.go @@ -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 } diff --git a/api/v1/documents_test.go b/api/v1/documents_test.go index d39e14a..e2a492b 100644 --- a/api/v1/documents_test.go +++ b/api/v1/documents_test.go @@ -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() { diff --git a/api/v1/openapi.yaml b/api/v1/openapi.yaml index c919463..5dc92a4 100644 --- a/api/v1/openapi.yaml +++ b/api/v1/openapi.yaml @@ -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 diff --git a/frontend/src/generated/model/documentResponse.ts b/frontend/src/generated/model/documentResponse.ts index 25c1bd5..2eb321d 100644 --- a/frontend/src/generated/model/documentResponse.ts +++ b/frontend/src/generated/model/documentResponse.ts @@ -6,9 +6,7 @@ * OpenAPI spec version: 1.0.0 */ import type { Document } from './document'; -import type { Progress } from './progress'; export interface DocumentResponse { document: Document; - progress?: Progress; } diff --git a/frontend/src/generated/model/documentsResponse.ts b/frontend/src/generated/model/documentsResponse.ts index 8d8c145..62db32a 100644 --- a/frontend/src/generated/model/documentsResponse.ts +++ b/frontend/src/generated/model/documentsResponse.ts @@ -6,8 +6,6 @@ * OpenAPI spec version: 1.0.0 */ import type { Document } from './document'; -import type { UserData } from './userData'; -import type { WordCount } from './wordCount'; export interface DocumentsResponse { documents: Document[]; @@ -17,6 +15,4 @@ export interface DocumentsResponse { next_page?: number; previous_page?: number; search?: string; - user: UserData; - word_counts: WordCount[]; } diff --git a/frontend/src/pages/DocumentPage.tsx b/frontend/src/pages/DocumentPage.tsx index a4269f5..fffa5c3 100644 --- a/frontend/src/pages/DocumentPage.tsx +++ b/frontend/src/pages/DocumentPage.tsx @@ -7,7 +7,6 @@ import { getGetDocumentQueryKey, } from '../generated/anthoLumeAPIV1'; import { Document } from '../generated/model/document'; -import { Progress } from '../generated/model/progress'; import { formatDuration } from '../utils/formatters'; import { DeleteIcon, @@ -54,15 +53,12 @@ export default function DocumentPage() { } const document = docData.data.document as Document; - const progress = - docData?.status === 200 ? (docData.data.progress as Progress | undefined) : undefined; if (!document) { return