chore: remove unnecessary crap ai added
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
@@ -236,7 +236,6 @@ type Document struct {
|
||||
// DocumentResponse defines model for DocumentResponse.
|
||||
type DocumentResponse struct {
|
||||
Document Document `json:"document"`
|
||||
Progress *Progress `json:"progress,omitempty"`
|
||||
}
|
||||
|
||||
// DocumentsResponse defines model for DocumentsResponse.
|
||||
@@ -248,8 +247,6 @@ type DocumentsResponse struct {
|
||||
PreviousPage *int64 `json:"previous_page,omitempty"`
|
||||
Search *string `json:"search,omitempty"`
|
||||
Total int64 `json:"total"`
|
||||
User UserData `json:"user"`
|
||||
WordCounts []WordCount `json:"word_counts"`
|
||||
}
|
||||
|
||||
// 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"`
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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 <div className="text-content-muted">Document not found</div>;
|
||||
}
|
||||
|
||||
const percentage =
|
||||
document.percentage ?? (progress?.percentage ? progress.percentage * 100 : 0) ?? 0;
|
||||
const percentage = document.percentage ?? 0;
|
||||
const secondsPerPercent = document.seconds_per_percent || 0;
|
||||
const totalTimeLeftSeconds = Math.round((100 - percentage) * secondsPerPercent);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user