Skip to content

workshop content#20

Open
mulyadisetiawan wants to merge 1 commit intotherizk:masterfrom
mulyadisetiawan:workshop
Open

workshop content#20
mulyadisetiawan wants to merge 1 commit intotherizk:masterfrom
mulyadisetiawan:workshop

Conversation

@mulyadisetiawan
Copy link

No description provided.

const (
// Collection queries
QueryGetNilaiSiswaByID = `select nim, mapel_id, nilai, sekolah, kelas
from nilai_siswa
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dirapiin query nya jadi lbh rapi atau sejajar

type NilaiSiswa struct {
NIM int64 `json:"nim" db:"nim"`
MapelID int64 `json:"mapel_id" db:"mapel_id"`
Nilai int64 `json:"nili" db:"nili"`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nilai int64 `json:"nili" db:"nili"`
Nilai int64 `json:"nilai" db:"nilai"`

Kelas string `json:"kelas" db:"kelas"`
}

func GetNilaiSiswaByID(ctx context.Context, nim, mapel_id int64) (result []NilaiSiswa, err error) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead mapel_id mngkn lbh oke mapelID

func (s *server) GetNilaiSiswa(ctx context.Context, req *pb.GetNilaiSiswaRequest) (resp *pb.GetNilaiSiswaResponse, err error) {

if req.sekolah == "" {
req.sekolah = "semua"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"semua" dijadiin const


resp = parseGetNilaiSiswa(nilai)

return resp, nil
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lngsng return parseGetNilaiSiswa(nilai), nil

"github.com/tokopedia/tokopoints/tracer"
)

func GetNilaiSiswa(ctx context.Context, nim int64, sekolah, kelas string, mapel_id int64) (resp GetNilaiSiswaResponse, err error) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bisa dijadiin struct aja paramny biar kalo ada tmbhan lbh mudah

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mape_id jadi mapelID

return resp, errors.AddTrace(err)
}

detailSekolah, err := nilai.GetDetailSekolah(ctx, nilai.Sekolah[0])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini funcnya dikeluarin aja di luar if else

return resp, errors.AddTrace(err)
}

resp = mappingGetNilaiSiswa(nilai, detailSekolah)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini juga dikeluarin

req.sekolah = "semua"
}

nilai, err := mnilai.GetNilaiSiswa(req.nim, req.sekolah, req.kelas, mapel_id)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapel_id ga ada di parameter dapet dari mana

span, ctx := tracer.StartSpanFromContext(ctx)
defer span.Finish()

if nim != 0 && mapel_id != 0 {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini if nya dijadiin switch case aja

Suggested change
if nim != 0 && mapel_id != 0 {
switch b := param; {
case b.NIM > 0 && b.MapelID > 0:
fmt.Println("BLA")
case b.Sekolah == "SekolahGlobal":
fmt.Println("Semua")
default:
fmt.Println("ga semua")
}


resp = mappingGetNilaiSiswa(nilai, detailSekolah)
} else if sekolah == "semua" {
nilai, err := nilai.GetNilaiSiswaSemuaSekolah(ctx)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionny blm ada nih

return resp, errors.AddTrace(err)
}

detailSekolah, err := nilai.GetDetailSekolah(ctx, nilai.Sekolah[0])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ini jg blm ada functionnya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants