Conversation
| ) | ||
|
|
||
| const ( | ||
| // Collection queries |
There was a problem hiding this comment.
bisa dipisah file queries.go indent querynya dibenerin, syntax sqlnya di uppercase aja
| "github.com/tokopedia/tokopoints/tracer" | ||
| ) | ||
|
|
||
| func GetNilaiSiswa(ctx context.Context, nim int64, sekolah, kelas string, mapel_id int64) (resp GetNilaiSiswaResponse, err error) { |
There was a problem hiding this comment.
paramnya bisa jd satu struct terpisah GetNilaiSiswaParam
| return resp, errors.AddTrace(err) | ||
| } | ||
|
|
||
| detailSekolah, err := nilai.GetDetailSekolah(ctx, nilai.Sekolah[0]) |
There was a problem hiding this comment.
GetDetailSekolah dan mappingGetNilaiSiswa bisa taruh setelah if else biar ga redundant
| pb "github.com/tokopedia/grpc/code-review-workshop/proto" | ||
| ) | ||
|
|
||
| func (s *server) GetNilaiSiswa(ctx context.Context, req *pb.GetNilaiSiswaRequest) (resp *pb.GetNilaiSiswaResponse, err error) { |
There was a problem hiding this comment.
param ctx klo ga dipake bisa dihilangkan, ato di span jika ada kebutuhan tracing
| "github.com/tokopedia/code-review-workshop/tracer" | ||
| ) | ||
|
|
||
| type NilaiSiswa struct { |
There was a problem hiding this comment.
struct nya bisa dipisah file types.go
| type NilaiSiswa struct { | ||
| NIM int64 `json:"nim" db:"nim"` | ||
| MapelID int64 `json:"mapel_id" db:"mapel_id"` | ||
| Nilai int64 `json:"nili" db:"nili"` |
| Kelas string `json:"kelas" db:"kelas"` | ||
| } | ||
|
|
||
| func GetNilaiSiswaByID(ctx context.Context, nim, mapel_id int64) (result []NilaiSiswa, err error) { |
There was a problem hiding this comment.
penamaan paramnya mungkin ngikutin structnya aja tp di unexported
| req.sekolah = "semua" | ||
| } | ||
|
|
||
| nilai, err := mnilai.GetNilaiSiswa(req.nim, req.sekolah, req.kelas, mapel_id) |
| return resp, errors.AddTrace(err) | ||
| } | ||
|
|
||
| detailSekolah, err := nilai.GetDetailSekolah(ctx, nilai.Sekolah[0]) |
There was a problem hiding this comment.
jgn lupa cek len nilai.Sekolah nya
|
|
||
| redis, err = redislib.Get(redislib.PromoCatalog) | ||
| if err != nil { | ||
| log.Fatal("Cannot connect to redis") |
There was a problem hiding this comment.
lognya diperjelas ga bisa konek ke redis yg mana
| } | ||
|
|
||
| resp = mappingGetNilaiSiswa(nilai, detailSekolah) | ||
| } else if sekolah == "semua" { |
There was a problem hiding this comment.
semua sepertinya bisa dijadikan const karena sering dipake
| span, ctx := tracer.StartSpanFromContext(ctx) | ||
| defer span.Finish() | ||
|
|
||
| if nim != 0 && mapel_id != 0 { |
There was a problem hiding this comment.
bisa dikasi monitoring ato log error utk bbrp flownya jika memang critical
No description provided.