Add application workflow and lead analytics
This commit is contained in:
@@ -112,6 +112,21 @@ func (r *mutationResolver) PromoteJobLead(ctx context.Context, id int) (*models.
|
||||
return services.PromoteJobLead(r.Store.DB, uint(id), time.Now())
|
||||
}
|
||||
|
||||
// BulkDismissJobLeads is the resolver for the bulkDismissJobLeads field.
|
||||
func (r *mutationResolver) BulkDismissJobLeads(ctx context.Context, ids []int) ([]*models.JobLead, error) {
|
||||
return services.BulkLeadState(r.Store.DB, ids, services.LeadNew, services.LeadDismissed)
|
||||
}
|
||||
|
||||
// BulkRestoreJobLeads is the resolver for the bulkRestoreJobLeads field.
|
||||
func (r *mutationResolver) BulkRestoreJobLeads(ctx context.Context, ids []int) ([]*models.JobLead, error) {
|
||||
return services.BulkLeadState(r.Store.DB, ids, services.LeadDismissed, services.LeadNew)
|
||||
}
|
||||
|
||||
// BulkPromoteJobLeads is the resolver for the bulkPromoteJobLeads field.
|
||||
func (r *mutationResolver) BulkPromoteJobLeads(ctx context.Context, ids []int) ([]*models.JobLead, error) {
|
||||
return services.BulkPromoteJobLeads(r.Store.DB, ids, time.Now())
|
||||
}
|
||||
|
||||
// UpdateJobSearchProfile is the resolver for the updateJobSearchProfile field.
|
||||
func (r *mutationResolver) UpdateJobSearchProfile(ctx context.Context, input model.UpdateJobSearchProfileInput) (*models.JobSearchProfile, error) {
|
||||
profile, err := services.LoadJobSearchProfile(r.Store.DB)
|
||||
@@ -173,7 +188,7 @@ func (r *queryResolver) JobSources(ctx context.Context) ([]*models.JobSource, er
|
||||
}
|
||||
|
||||
// JobLeads is the resolver for the jobLeads field.
|
||||
func (r *queryResolver) JobLeads(ctx context.Context, state *string, includeUnmatched *bool) ([]*models.JobLead, error) {
|
||||
func (r *queryResolver) JobLeads(ctx context.Context, state *string, includeUnmatched *bool, filters *model.JobLeadFilters) ([]*models.JobLead, error) {
|
||||
// Omit, not Select: every column but the description, which is tens of
|
||||
// kilobytes a row and is fetched one lead at a time through jobLead. A
|
||||
// client that asks for description here gets "".
|
||||
@@ -186,6 +201,23 @@ func (r *queryResolver) JobLeads(ctx context.Context, state *string, includeUnma
|
||||
// about it; `matched` only decides what the inbox offers.
|
||||
query = query.Where("(matched = ? OR state <> ?)", true, services.LeadNew)
|
||||
}
|
||||
if filters != nil {
|
||||
if filters.SourceKind != nil && strings.TrimSpace(*filters.SourceKind) != "" {
|
||||
query = query.Where("source_kind = ?", strings.TrimSpace(*filters.SourceKind))
|
||||
}
|
||||
if filters.MinScore != nil {
|
||||
query = query.Where("score >= ?", *filters.MinScore)
|
||||
}
|
||||
if filters.MaxScore != nil {
|
||||
query = query.Where("score <= ?", *filters.MaxScore)
|
||||
}
|
||||
if filters.Location != nil && strings.TrimSpace(*filters.Location) != "" {
|
||||
query = query.Where("location ILIKE ?", "%"+strings.TrimSpace(*filters.Location)+"%")
|
||||
}
|
||||
if filters.Company != nil && strings.TrimSpace(*filters.Company) != "" {
|
||||
query = query.Where("company ILIKE ?", "%"+strings.TrimSpace(*filters.Company)+"%")
|
||||
}
|
||||
}
|
||||
var leads []*models.JobLead
|
||||
// Best first, unscored after scored, newest first within a score. The
|
||||
// limit is a backstop for includeUnmatched on a database holding several
|
||||
|
||||
Reference in New Issue
Block a user