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. // DocumentResponse defines model for DocumentResponse.
type DocumentResponse struct { type DocumentResponse struct {
Document Document `json:"document"` Document Document `json:"document"`
Progress *Progress `json:"progress,omitempty"`
} }
// DocumentsResponse defines model for DocumentsResponse. // DocumentsResponse defines model for DocumentsResponse.
type DocumentsResponse struct { type DocumentsResponse struct {
Documents []Document `json:"documents"` Documents []Document `json:"documents"`
Limit int64 `json:"limit"` Limit int64 `json:"limit"`
NextPage *int64 `json:"next_page,omitempty"` NextPage *int64 `json:"next_page,omitempty"`
Page int64 `json:"page"` Page int64 `json:"page"`
PreviousPage *int64 `json:"previous_page,omitempty"` PreviousPage *int64 `json:"previous_page,omitempty"`
Search *string `json:"search,omitempty"` Search *string `json:"search,omitempty"`
Total int64 `json:"total"` Total int64 `json:"total"`
User UserData `json:"user"`
WordCounts []WordCount `json:"word_counts"`
} }
// ErrorResponse defines model for ErrorResponse. // ErrorResponse defines model for ErrorResponse.
@@ -469,12 +466,6 @@ type UsersResponse struct {
Users *[]User `json:"users,omitempty"` 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. // GetActivityParams defines parameters for GetActivity.
type GetActivityParams struct { type GetActivityParams struct {
DocFilter *bool `form:"doc_filter,omitempty" json:"doc_filter,omitempty"` 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)) apiDocuments := make([]Document, len(rows))
wordCounts := make([]WordCount, 0, len(rows))
for i, row := range rows { for i, row := range rows {
apiDocuments[i] = Document{ apiDocuments[i] = Document{
Id: row.ID, 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 UpdatedAt: time.Now(), // Will be overwritten if we had a proper updated_at from DB
Deleted: false, // Default, should be overridden if available Deleted: false, // Default, should be overridden if available
} }
if row.Words != nil {
wordCounts = append(wordCounts, WordCount{
DocumentId: row.ID,
Count: *row.Words,
})
}
} }
response := DocumentsResponse{ response := DocumentsResponse{
@@ -99,8 +92,6 @@ func (s *Server) GetDocuments(ctx context.Context, request GetDocumentsRequestOb
NextPage: nextPage, NextPage: nextPage,
PreviousPage: previousPage, PreviousPage: previousPage,
Search: request.Params.Search, Search: request.Params.Search,
User: UserData{Username: auth.UserName, IsAdmin: auth.IsAdmin},
WordCounts: wordCounts,
} }
return GetDocuments200JSONResponse(response), nil return GetDocuments200JSONResponse(response), nil
} }
@@ -129,21 +120,6 @@ func (s *Server) GetDocument(ctx context.Context, request GetDocumentRequestObje
doc := docs[0] 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{ apiDoc := Document{
Id: doc.ID, Id: doc.ID,
Title: *doc.Title, Title: *doc.Title,
@@ -165,7 +141,6 @@ func (s *Server) GetDocument(ctx context.Context, request GetDocumentRequestObje
response := DocumentResponse{ response := DocumentResponse{
Document: apiDoc, Document: apiDoc,
Progress: progress,
} }
return GetDocument200JSONResponse(response), nil return GetDocument200JSONResponse(response), nil
} }
@@ -244,20 +219,6 @@ func (s *Server) EditDocument(ctx context.Context, request EditDocumentRequestOb
doc := docs[0] 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{ apiDoc := Document{
Id: doc.ID, Id: doc.ID,
@@ -280,7 +241,6 @@ func (s *Server) EditDocument(ctx context.Context, request EditDocumentRequestOb
response := DocumentResponse{ response := DocumentResponse{
Document: apiDoc, Document: apiDoc,
Progress: progress,
} }
return EditDocument200JSONResponse(response), nil return EditDocument200JSONResponse(response), nil
} }
@@ -601,20 +561,6 @@ func (s *Server) UploadDocumentCover(ctx context.Context, request UploadDocument
doc := docs[0] 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{ apiDoc := Document{
Id: doc.ID, Id: doc.ID,
@@ -637,7 +583,6 @@ func (s *Server) UploadDocumentCover(ctx context.Context, request UploadDocument
response := DocumentResponse{ response := DocumentResponse{
Document: apiDoc, Document: apiDoc,
Progress: progress,
} }
return UploadDocumentCover200JSONResponse(response), nil return UploadDocumentCover200JSONResponse(response), nil
} }

View File

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

View File

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

View File

@@ -6,9 +6,7 @@
* OpenAPI spec version: 1.0.0 * OpenAPI spec version: 1.0.0
*/ */
import type { Document } from './document'; import type { Document } from './document';
import type { Progress } from './progress';
export interface DocumentResponse { export interface DocumentResponse {
document: Document; document: Document;
progress?: Progress;
} }

View File

@@ -6,8 +6,6 @@
* OpenAPI spec version: 1.0.0 * OpenAPI spec version: 1.0.0
*/ */
import type { Document } from './document'; import type { Document } from './document';
import type { UserData } from './userData';
import type { WordCount } from './wordCount';
export interface DocumentsResponse { export interface DocumentsResponse {
documents: Document[]; documents: Document[];
@@ -17,6 +15,4 @@ export interface DocumentsResponse {
next_page?: number; next_page?: number;
previous_page?: number; previous_page?: number;
search?: string; search?: string;
user: UserData;
word_counts: WordCount[];
} }

View File

@@ -7,7 +7,6 @@ import {
getGetDocumentQueryKey, getGetDocumentQueryKey,
} from '../generated/anthoLumeAPIV1'; } from '../generated/anthoLumeAPIV1';
import { Document } from '../generated/model/document'; import { Document } from '../generated/model/document';
import { Progress } from '../generated/model/progress';
import { formatDuration } from '../utils/formatters'; import { formatDuration } from '../utils/formatters';
import { import {
DeleteIcon, DeleteIcon,
@@ -54,15 +53,12 @@ export default function DocumentPage() {
} }
const document = docData.data.document as Document; const document = docData.data.document as Document;
const progress =
docData?.status === 200 ? (docData.data.progress as Progress | undefined) : undefined;
if (!document) { if (!document) {
return <div className="text-content-muted">Document not found</div>; return <div className="text-content-muted">Document not found</div>;
} }
const percentage = const percentage = document.percentage ?? 0;
document.percentage ?? (progress?.percentage ? progress.percentage * 100 : 0) ?? 0;
const secondsPerPercent = document.seconds_per_percent || 0; const secondsPerPercent = document.seconds_per_percent || 0;
const totalTimeLeftSeconds = Math.round((100 - percentage) * secondsPerPercent); const totalTimeLeftSeconds = Math.round((100 - percentage) * secondsPerPercent);