Skip to content

Commit

Permalink
Merge branch 'release/v0.0.89'
Browse files Browse the repository at this point in the history
* release/v0.0.89:
  chore: update CODEOWNERS file
  refactor: notion handler
  • Loading branch information
namnhce committed Apr 19, 2023
2 parents d99b257 + 26693b8 commit 7ce4f3f
Show file tree
Hide file tree
Showing 44 changed files with 510 additions and 883 deletions.
12 changes: 6 additions & 6 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Default reviewers for every PR
* @huynguyenh @namnhce
.github/ @huynguyenh @namnhce @nguyennh4522
cmd/ @huynguyenh @namnhce @nguyennh4522 @thanhpn @datphamcode295
docs/ @huynguyenh @namnhce @nguyennh4522 @thanhpn @datphamcode295
migrations/ @huynguyenh @namnhce @nguyennh4522 @thanhpn @datphamcode295
pkg/ @huynguyenh @namnhce @nguyennh4522 @thanhpn @datphamcode295
* @huynguyenh @namnhce @lmquang
.github/ @huynguyenh @namnhce @lmquang
cmd/ @huynguyenh @namnhce @lmquang
docs/ @huynguyenh @namnhce @lmquang
migrations/ @huynguyenh @namnhce @lmquang
pkg/ @huynguyenh @namnhce @lmquang
7 changes: 0 additions & 7 deletions pkg/handler/audience/interface.go

This file was deleted.

45 changes: 0 additions & 45 deletions pkg/handler/dfupdate/interface.go

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/handler/digest/interface.go

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/handler/earn/interface.go

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/handler/event/interface.go

This file was deleted.

119 changes: 43 additions & 76 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,24 @@ import (
"github.com/dwarvesf/fortress-api/pkg/controller"
"github.com/dwarvesf/fortress-api/pkg/handler/accounting"
"github.com/dwarvesf/fortress-api/pkg/handler/asset"
"github.com/dwarvesf/fortress-api/pkg/handler/audience"
"github.com/dwarvesf/fortress-api/pkg/handler/audit"
"github.com/dwarvesf/fortress-api/pkg/handler/auth"
"github.com/dwarvesf/fortress-api/pkg/handler/bankaccount"
"github.com/dwarvesf/fortress-api/pkg/handler/birthday"
"github.com/dwarvesf/fortress-api/pkg/handler/changelog"
"github.com/dwarvesf/fortress-api/pkg/handler/client"
"github.com/dwarvesf/fortress-api/pkg/handler/dashboard"
"github.com/dwarvesf/fortress-api/pkg/handler/dashboard/util"
"github.com/dwarvesf/fortress-api/pkg/handler/dfupdate"
"github.com/dwarvesf/fortress-api/pkg/handler/digest"
"github.com/dwarvesf/fortress-api/pkg/handler/discord"
"github.com/dwarvesf/fortress-api/pkg/handler/earn"
"github.com/dwarvesf/fortress-api/pkg/handler/employee"
"github.com/dwarvesf/fortress-api/pkg/handler/event"
"github.com/dwarvesf/fortress-api/pkg/handler/feedback"
"github.com/dwarvesf/fortress-api/pkg/handler/healthz"
"github.com/dwarvesf/fortress-api/pkg/handler/hiring"
"github.com/dwarvesf/fortress-api/pkg/handler/invoice"
"github.com/dwarvesf/fortress-api/pkg/handler/issue"
"github.com/dwarvesf/fortress-api/pkg/handler/memo"
"github.com/dwarvesf/fortress-api/pkg/handler/metadata"
"github.com/dwarvesf/fortress-api/pkg/handler/notion"
"github.com/dwarvesf/fortress-api/pkg/handler/payroll"
"github.com/dwarvesf/fortress-api/pkg/handler/profile"
"github.com/dwarvesf/fortress-api/pkg/handler/project"
"github.com/dwarvesf/fortress-api/pkg/handler/staffingdemand"
"github.com/dwarvesf/fortress-api/pkg/handler/survey"
"github.com/dwarvesf/fortress-api/pkg/handler/techradar"
"github.com/dwarvesf/fortress-api/pkg/handler/update"
"github.com/dwarvesf/fortress-api/pkg/handler/valuation"
"github.com/dwarvesf/fortress-api/pkg/handler/webhook"
"github.com/dwarvesf/fortress-api/pkg/logger"
Expand All @@ -43,73 +32,51 @@ import (
)

type Handler struct {
Healthcheck healthz.IHandler
Employee employee.IHandler
Metadata metadata.IHandler
Auth auth.IHandler
Project project.IHandler
Profile profile.IHandler
Feedback feedback.IHandler
Survey survey.IHandler
Dashboard dashboard.IHandler
Valuation valuation.IHandler
Earn earn.IHandler
TechRadar techradar.IHandler
Issue issue.IHandler
Audience audience.IHandler
Event event.IHandler
Hiring hiring.IHandler
StaffingDemand staffingdemand.IHandler
Audit audit.IHandler
Digest digest.IHandler
Update update.IHandler
Memo memo.IHandler
BankAccount bankaccount.IHandler
Birthday birthday.IHandler
Invoice invoice.IHandler
Webhook webhook.IHandler
Discord discord.IHandler
Client client.IHandler
Asset asset.IHandler
Changelog changelog.IHandler
DFUpdate dfupdate.IHandler
Payroll payroll.IHandler
Accounting accounting.IHandler
Accounting accounting.IHandler
Asset asset.IHandler
Audit audit.IHandler
Auth auth.IHandler
BankAccount bankaccount.IHandler
Birthday birthday.IHandler
Client client.IHandler
Dashboard dashboard.IHandler
Discord discord.IHandler
Employee employee.IHandler
Feedback feedback.IHandler
Healthcheck healthz.IHandler
Invoice invoice.IHandler
Metadata metadata.IHandler
Notion notion.IHandler
Payroll payroll.IHandler
Profile profile.IHandler
Project project.IHandler
Survey survey.IHandler
Valuation valuation.IHandler
Webhook webhook.IHandler
}

func New(store *store.Store, repo store.DBRepo, service *service.Service, ctrl *controller.Controller, worker *worker.Worker, logger logger.Logger, cfg *config.Config) *Handler {
return &Handler{
Healthcheck: healthz.New(),
Employee: employee.New(ctrl, store, repo, service, logger, cfg),
Metadata: metadata.New(store, repo, service, logger, cfg),
Auth: auth.New(ctrl, logger, cfg),
Project: project.New(store, repo, service, logger, cfg),
Profile: profile.New(store, repo, service, logger, cfg),
Feedback: feedback.New(store, repo, service, logger, cfg),
Survey: survey.New(store, repo, service, logger, cfg),
Dashboard: dashboard.New(store, repo, service, logger, cfg, util.New()),
Valuation: valuation.New(store, repo, service, logger, cfg),
Earn: earn.New(store, repo, service, logger, cfg),
TechRadar: techradar.New(store, repo, service, logger, cfg),
Issue: issue.New(store, repo, service, logger, cfg),
Audience: audience.New(store, repo, service, logger, cfg),
Event: event.New(store, repo, service, logger, cfg),
Hiring: hiring.New(store, repo, service, logger, cfg),
StaffingDemand: staffingdemand.New(store, repo, service, logger, cfg),
Audit: audit.New(store, repo, service, logger, cfg),
Digest: digest.New(store, repo, service, logger, cfg),
Update: update.New(store, repo, service, logger, cfg),
Memo: memo.New(store, repo, service, logger, cfg),
BankAccount: bankaccount.New(store, repo, service, logger, cfg),
Birthday: birthday.New(store, repo, service, logger, cfg),
Invoice: invoice.New(ctrl, store, repo, service, worker, logger, cfg),
Webhook: webhook.New(ctrl, store, repo, service, logger, cfg),
Discord: discord.New(store, repo, service, logger, cfg),
Client: client.New(ctrl, store, repo, service, logger, cfg),
Asset: asset.New(store, repo, service, logger, cfg),
Changelog: changelog.New(store, repo, service, logger, cfg),
DFUpdate: dfupdate.New(store, repo, service, logger, cfg),
Payroll: payroll.New(store, repo, service, worker, logger, cfg),
Accounting: accounting.New(store, repo, service, logger, cfg),
Accounting: accounting.New(store, repo, service, logger, cfg),
Asset: asset.New(store, repo, service, logger, cfg),
Audit: audit.New(store, repo, service, logger, cfg),
Auth: auth.New(ctrl, logger, cfg),
BankAccount: bankaccount.New(store, repo, service, logger, cfg),
Birthday: birthday.New(store, repo, service, logger, cfg),
Client: client.New(ctrl, store, repo, service, logger, cfg),
Dashboard: dashboard.New(store, repo, service, logger, cfg, util.New()),
Discord: discord.New(store, repo, service, logger, cfg),
Employee: employee.New(ctrl, store, repo, service, logger, cfg),
Feedback: feedback.New(store, repo, service, logger, cfg),
Healthcheck: healthz.New(),
Invoice: invoice.New(ctrl, store, repo, service, worker, logger, cfg),
Metadata: metadata.New(store, repo, service, logger, cfg),
Notion: notion.New(store, repo, service, logger, cfg),
Payroll: payroll.New(store, repo, service, worker, logger, cfg),
Profile: profile.New(store, repo, service, logger, cfg),
Project: project.New(store, repo, service, logger, cfg),
Survey: survey.New(store, repo, service, logger, cfg),
Valuation: valuation.New(store, repo, service, logger, cfg),
Webhook: webhook.New(ctrl, store, repo, service, logger, cfg),
}
}
7 changes: 0 additions & 7 deletions pkg/handler/hiring/interface.go

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/handler/issue/interface.go

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/handler/memo/interface.go

This file was deleted.

46 changes: 12 additions & 34 deletions pkg/handler/audience/audience.go → pkg/handler/notion/audience.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
// please edit this file only with approval from hnh
package audience
// Package notion please edit this file only with approval from hnh
package notion

import (
"net/http"

"github.com/dstotijn/go-notion"
"github.com/dwarvesf/fortress-api/pkg/config"
"github.com/dwarvesf/fortress-api/pkg/logger"
"github.com/gin-gonic/gin"

"github.com/dwarvesf/fortress-api/pkg/model"
"github.com/dwarvesf/fortress-api/pkg/service"
"github.com/dwarvesf/fortress-api/pkg/store"
"github.com/dwarvesf/fortress-api/pkg/view"
"github.com/gin-gonic/gin"
)

type handler struct {
store *store.Store
service *service.Service
logger logger.Logger
repo store.DBRepo
config *config.Config
}

// New returns a handler
func New(store *store.Store, repo store.DBRepo, service *service.Service, logger logger.Logger, cfg *config.Config) IHandler {
return &handler{
store: store,
repo: repo,
service: service,
logger: logger,
config: cfg,
}
}

// List godoc
// ListAudiences godoc
// @Summary Get list audiences from DF Audience
// @Description Get list audiences from DF Audience
// @Tags Audience
// @Accept json
// @Produce json
// @Success 200 {object} []model.Audience
// @Failure 400 {object} view.ErrorResponse
func (h *handler) List(c *gin.Context) {
func (h *handler) ListAudiences(c *gin.Context) {
filter := &notion.DatabaseQueryFilter{}

filterNewSubscriber := true
Expand Down Expand Up @@ -69,15 +47,15 @@ func (h *handler) List(c *gin.Context) {
return
}

var audiences = []model.Audience{}
var audiences []model.NotionAudience
for _, r := range resp.Results {
props := r.Properties.(notion.DatabasePageProperties)

fullname := ""
fullName := ""
if len(props["Full Name"].Title) > 0 {
fullname = props["Full Name"].Title[0].Text.Content
fullName = props["Full Name"].Title[0].Text.Content
}
sources := []string{}
var sources []string
for _, c := range props["Source"].MultiSelect {
sources = append(sources, c.Name)
}
Expand All @@ -86,9 +64,9 @@ func (h *handler) List(c *gin.Context) {
email = *props["Email"].Email
}

audiences = append(audiences, model.Audience{
audiences = append(audiences, model.NotionAudience{
ID: r.ID,
FullName: fullname,
FullName: fullName,
Email: email,
CreatedAt: r.CreatedTime,
Sources: sources,
Expand Down
Loading

0 comments on commit 7ce4f3f

Please sign in to comment.