-
Notifications
You must be signed in to change notification settings - Fork 27
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
Asset API #22
base: main
Are you sure you want to change the base?
Asset API #22
Conversation
- Fetch User Favourites - Remove User Favourite - All around fixes
- Add Remove fanourite endpoint - Add Audiences (bulk) endpoint - Add List Audiences endpoint - Map Audience, Insight or Chart to user's directly under Favourite - Add postman environment and collection - Add Mock data for Audiences - Update README
After successfully bringing up an independent container with swagger, the UI was not nice. - So we fall back to plain old postman environment and collections. - And update readme file - Fix Insight id and other minor changes - Fixes postman collection
Wiz Scan Summary
|
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.
Hello @eirinivand 👋
Thank you very much for your time and effort in completing this assignment! I've added some comments, but I also have a few general questions about your implementation:
-
NoSQL Database Choice:
- Why did you choose to use a NoSQL database? Can you elaborate more on your thoughts behind this decision?
- Additionally, could you please describe, in simple terms, an approach to using an SQL database instead?
-
Models Package Usage:
- What are your thoughts on using the models package both in the endpoints' request bodies and in the database structs?
- Do you see any drawbacks to this approach?
-
Testing Priorities:
- If you had to add some tests to your implementation, which parts would be your priorities?
GetByID(ctx context.Context, id string) (models.User, error) | ||
Create(ctx context.Context, m *models.User) error | ||
CreateAll(ctx context.Context, m []*models.User) error | ||
Update(ctx context.Context, id string, m models.User) (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.
In the Create and CreateAll methods, your User inputs are pointers, but not in the Update one. Is there any specific reason for that??
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.
Well, the thing is, I forgot to use and update these, so there is no reason for it; it should have been a pointer. 😅
return &AssetHandler{service: service} | ||
} | ||
|
||
func (h *AssetHandler) GetAll(ctx *gin.Context) { |
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.
I noticed in your implementation that the context is propagated end-to-end until the database. What are some advantages of doing this?
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.
- Timeounts: say something takes too long it can be terminated at any level, or if the request is cancelled.
- Middleware usage, say to set/check/unset cookies
- That being said also security, since in an extension cookies/tokens can be checked at any level.
- Keeping the data relative to the request for improved consistency.
type AssetInterface interface { | ||
GetId() primitive.ObjectID | ||
Description() string | ||
GetAssetType() AssetInterface |
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.
What's the point of this method?
In the implementations (audience, chart, insight), the actual object is returned
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.
This was forgotten in there (and in the implementations). I was experimenting with different approaches to fetching the object. This one was not useful and was thus abandoned.
return client | ||
} | ||
|
||
func CloseClientDB() { |
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.
I noticed that you don't call the CloseClientDB
method anywhere in your implementation. Is there any specific reason for that?
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.
True, forgotten, should have been during application shutdown.
Hello @NikosMas 👋 Thank you for your comments! Here are the answers to the more general questions:
|
Will be squashed upon request.