Skip to content

Remove documents table #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4ce9e2d
Remove documents table (WIP)
tankerkiller125 Apr 6, 2025
c3cfa98
Further cleanup of documents table
tankerkiller125 Apr 6, 2025
7538060
This should clean up the errors, but actual attachment handling still…
tankerkiller125 Apr 6, 2025
b022a82
Full generation to update the JS side of things too
tankerkiller125 Apr 6, 2025
6c26ba5
Further fixes
tankerkiller125 Apr 6, 2025
f2f757c
Fix cyclic dependency issue
tankerkiller125 Apr 6, 2025
b41ebbe
In theory the API side works now
tankerkiller125 Apr 6, 2025
dbfb62e
Fix go linting issues
tankerkiller125 Apr 6, 2025
6dc8c55
Fix frontend issues
tankerkiller125 Apr 6, 2025
7efb1c0
Way closer, but has a foreign key constrant issue
tankerkiller125 Apr 6, 2025
f98f1bd
UI actually works now
tankerkiller125 Apr 6, 2025
7f613cc
Fix deduplication feature not working right
tankerkiller125 Apr 6, 2025
5c60122
Upgrade to `golangci-lint` v2 file
tankerkiller125 Apr 19, 2025
12376a3
Add ability to set primary during attachment creation
tankerkiller125 Apr 19, 2025
53a01a5
Update swagger with new primary attachment during creation stuff
tankerkiller125 Apr 19, 2025
f8d3a1c
Files are actually saved now, but there's still a bug
tankerkiller125 Apr 19, 2025
30a6e3c
Fix critical issue whith how deletions were working
tankerkiller125 Apr 19, 2025
de5f4fb
Fix the byte copy issue
tankerkiller125 Apr 19, 2025
61a6df7
Hopefully everything is fixed now
tankerkiller125 Apr 19, 2025
6206182
Fix golangci-lint config and lint files
tankerkiller125 Apr 19, 2025
78352a5
Fix lint issue
tankerkiller125 Apr 19, 2025
77693ba
Fix a few more tests
tankerkiller125 Apr 19, 2025
0f8de55
Fix lint issues again
tankerkiller125 Apr 19, 2025
373800e
More minor test fixes
tankerkiller125 Apr 19, 2025
7ac4209
Update backend/internal/core/services/service_items_attachments.go
tankerkiller125 Apr 19, 2025
7ca0378
Fix migration (I think)
tankerkiller125 Apr 19, 2025
ef084c2
Fixed postgres migration
tankerkiller125 Apr 19, 2025
bf8c7b6
Change some migration options to work better
tankerkiller125 Apr 19, 2025
a6c65a3
Merge branch 'main' into mk/merge-attachments-and-docs
tankerkiller125 Apr 19, 2025
e68189e
Merge remote-tracking branch 'origin/mk/merge-attachments-and-docs' i…
tankerkiller125 Apr 22, 2025
7791d43
Some more little things that I tried
tankerkiller125 Apr 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/partial-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v7
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
Expand Down
99 changes: 53 additions & 46 deletions backend/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,81 @@
run:
timeout: 10m
linters-settings:
goconst:
min-len: 5
min-occurrences: 5
exhaustive:
default-signifies-exhaustive: true
revive:
ignore-generated-header: false
severity: warning
confidence: 3
depguard:
rules:
main:
deny:
- pkg: io/util
desc: |
Deprecated: As of Go 1.16, the same functionality is now provided by
package io or package os, and those implementations should be
preferred in new code. See the specific function documentation for
details.
gocritic:
enabled-checks:
- ruleguard
testifylint:
enable-all: true
tagalign:
order:
- json
- schema
- yaml
- yml
- toml
- validate
version: "2"
linters:
disable-all: true
default: none
enable:
- asciicheck
- bodyclose
- copyloopvar
- depguard
- dogsled
- errcheck
- errorlint
- exhaustive
- copyloopvar
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- testifylint
- typecheck
- typecheck
- unconvert
- unused
- whitespace
- zerologlint
- sqlclosecheck
settings:
depguard:
rules:
main:
deny:
- pkg: io/util
desc: |
Deprecated: As of Go 1.16, the same functionality is now provided by
package io or package os, and those implementations should be
preferred in new code. See the specific function documentation for
details.
exhaustive:
default-signifies-exhaustive: true
goconst:
min-len: 5
min-occurrences: 5
gocritic:
enabled-checks:
- ruleguard
revive:
confidence: 3
severity: warning
tagalign:
order:
- json
- schema
- yaml
- yml
- toml
- validate
testifylint:
enable-all: true
exclusions:
generated: lax
paths:
- internal/data/ent.*
- third_party$
- builtin$
- examples$
issues:
exclude-use-default: false
exclude-dirs:
- internal/data/ent.*
fix: true
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- internal/data/ent.*
- third_party$
- builtin$
- examples$
11 changes: 10 additions & 1 deletion backend/app/api/handlers/v1/v1_ctrl_items_attachments.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"net/http"
"path/filepath"
"strconv"
"strings"

"github.com/hay-kot/httpkit/errchain"
Expand All @@ -30,6 +31,7 @@ type (
// @Param id path string true "Item ID"
// @Param file formData file true "File attachment"
// @Param type formData string true "Type of file"
// @Param primary formData bool false "Is this the primary attachment"
// @Param name formData string true "name of the file including extension"
// @Success 200 {object} repo.ItemOut
// @Failure 422 {object} validate.ErrorResponse
Expand Down Expand Up @@ -80,6 +82,12 @@ func (ctrl *V1Controller) HandleItemAttachmentCreate() errchain.HandlerFunc {
}
}

primary, err := strconv.ParseBool(r.FormValue("primary"))
if err != nil {
log.Debug().Msg("failed to parse primary from form")
primary = false
}

id, err := ctrl.routeID(r)
if err != nil {
return err
Expand All @@ -92,6 +100,7 @@ func (ctrl *V1Controller) HandleItemAttachmentCreate() errchain.HandlerFunc {
id,
attachmentName,
attachment.Type(attachmentType),
primary,
file,
)
if err != nil {
Expand Down Expand Up @@ -163,7 +172,7 @@ func (ctrl *V1Controller) handleItemAttachmentsHandler(w http.ResponseWriter, r
log.Err(err).Msg("failed to get attachment path")
return validate.NewRequestError(err, http.StatusInternalServerError)
}

// w.Header().Set("Content-Disposition", "attachment; filename="+doc.Title)
http.ServeFile(w, r, doc.Path)
return nil

Expand Down
3 changes: 3 additions & 0 deletions backend/app/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
schema.WithDir(dir),
schema.WithDropColumn(true),
schema.WithDropIndex(true),
schema.WithDialect(strings.ToLower(cfg.Database.Driver)),
schema.WithForeignKeys(true),
schema.WithMigrationMode(schema.ModeReplay),
}

err = c.Schema.Create(context.Background(), options...)
Expand Down Expand Up @@ -203,7 +206,7 @@

currencies, err := currencies.CollectionCurrencies(collectFuncs...)
if err != nil {
go log.Error().

Check failure on line 209 in backend/app/api/main.go

View workflow job for this annotation

GitHub Actions / Backend Server Tests / Go

must be dispatched by Msg or Send method (zerologlint)
Err(err).
Msg("failed to collect currencies")
return err
Expand Down
33 changes: 16 additions & 17 deletions backend/app/api/static/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,12 @@ const docTemplate = `{
"in": "formData",
"required": true
},
{
"type": "boolean",
"description": "Is this the primary attachment",
"name": "primary",
"in": "formData"
},
{
"type": "string",
"description": "name of the file including extension",
Expand Down Expand Up @@ -2108,20 +2114,6 @@ const docTemplate = `{
}
}
},
"repo.DocumentOut": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"path": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
"repo.Group": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2182,15 +2174,18 @@ const docTemplate = `{
"createdAt": {
"type": "string"
},
"document": {
"$ref": "#/definitions/repo.DocumentOut"
},
"id": {
"type": "string"
},
"path": {
"type": "string"
},
"primary": {
"type": "boolean"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
Expand Down Expand Up @@ -2466,6 +2461,10 @@ const docTemplate = `{
"quantity": {
"type": "integer"
},
"soldTime": {
"description": "Sale details",
"type": "string"
},
"updatedAt": {
"type": "string"
}
Expand Down
33 changes: 16 additions & 17 deletions backend/app/api/static/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,12 @@
"in": "formData",
"required": true
},
{
"type": "boolean",
"description": "Is this the primary attachment",
"name": "primary",
"in": "formData"
},
{
"type": "string",
"description": "name of the file including extension",
Expand Down Expand Up @@ -2106,20 +2112,6 @@
}
}
},
"repo.DocumentOut": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"path": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
"repo.Group": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2180,15 +2172,18 @@
"createdAt": {
"type": "string"
},
"document": {
"$ref": "#/definitions/repo.DocumentOut"
},
"id": {
"type": "string"
},
"path": {
"type": "string"
},
"primary": {
"type": "boolean"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
Expand Down Expand Up @@ -2464,6 +2459,10 @@
"quantity": {
"type": "integer"
},
"soldTime": {
"description": "Sale details",
"type": "string"
},
"updatedAt": {
"type": "string"
}
Expand Down
22 changes: 11 additions & 11 deletions backend/app/api/static/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ definitions:
symbol:
type: string
type: object
repo.DocumentOut:
properties:
id:
type: string
path:
type: string
title:
type: string
type: object
repo.Group:
properties:
createdAt:
Expand Down Expand Up @@ -59,12 +50,14 @@ definitions:
properties:
createdAt:
type: string
document:
$ref: '#/definitions/repo.DocumentOut'
id:
type: string
path:
type: string
primary:
type: boolean
title:
type: string
type:
type: string
updatedAt:
Expand Down Expand Up @@ -248,6 +241,9 @@ definitions:
type: number
quantity:
type: integer
soldTime:
description: Sale details
type: string
updatedAt:
type: string
type: object
Expand Down Expand Up @@ -1172,6 +1168,10 @@ paths:
name: type
required: true
type: string
- description: Is this the primary attachment
in: formData
name: primary
type: boolean
- description: name of the file including extension
in: formData
name: name
Expand Down
6 changes: 3 additions & 3 deletions backend/app/tools/migrations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func main() {
}

databaseURL := ""
switch {
case cfg.Database.Driver == "sqlite3":
switch cfg.Database.Driver {
case "sqlite3":
databaseURL = fmt.Sprintf("sqlite://%s", cfg.Database.SqlitePath)
case cfg.Database.Driver == "postgres":
case "postgres":
databaseURL = fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=%s", cfg.Database.Username, cfg.Database.Password, cfg.Database.Host, cfg.Database.Port, cfg.Database.Database, cfg.Database.SslMode)
default:
log.Fatalf("unsupported database driver: %s", cfg.Database.Driver)
Expand Down
Loading
Loading