-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/async #1
Conversation
type: array | ||
items: | ||
$ref: '#/components/schemas/User' | ||
status: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good practice to make status as enum, but not necessary to change now
internal/data/pg/client.go
Outdated
db *pgdb.DB | ||
sql sq.SelectBuilder | ||
} | ||
|
||
func (q *ClientQ) New() data.ClientQ { | ||
q.mx.Lock() | ||
defer q.mx.Unlock() | ||
return NewClientQ(q.db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return NewClientQ(q.db.Clone())
internal/data/pg/client.go
Outdated
err := q.db.Exec(stmt) | ||
|
||
return err | ||
err := q.db.Exec(sq.Update(clientTableName).SetMap(clauses).Where(sq.Eq{"id": client.ID})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where should be moved and you should make separate builders(like selectBuilder + updateBuilder)
internal/data/pg/client.go
Outdated
if err != nil { | ||
return errors.Wrap(err, "failed to update client") | ||
} | ||
return nil | ||
} | ||
|
||
func (q *ClientQ) Insert(value *data.Client) (int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you return int64 here?
internal/data/pg/template.go
Outdated
db *pgdb.DB | ||
sql sq.SelectBuilder | ||
} | ||
|
||
func (q *TemplateQ) New() data.TemplateQ { | ||
q.mx.Lock() | ||
defer q.mx.Unlock() | ||
return NewTemplateQ(q.db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q.db.Clone() here too
return nil, errors.Wrap(err, "failed ot create file") | ||
} | ||
|
||
defer os.Remove(fileOutput.Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2
internal/service/core/pdf/pdf.go
Outdated
templateImg := config.templates[data.Course] | ||
|
||
if backgroundImg == nil { | ||
template, err := masterQ.TemplateQ().GetByName(templateImg, userID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
internal/service/core/pdf/pdf.go
Outdated
return nil, "", nil, errors.Wrap(err, "failed to get background img") | ||
} | ||
if template == nil { | ||
template, err = masterQ.TemplateQ().GetByName(templateImg, userID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2
@@ -0,0 +1,234 @@ | |||
package pdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor it a little bit
internal/service/core/pdf/runner.go
Outdated
select { | ||
case <-ctx.Done(): | ||
return | ||
case container := <-p.handlerChan: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe would be better to close channel too
# Conflicts: # internal/service/pdf/types.go
No description provided.