Add application workflow and lead analytics
This commit is contained in:
@@ -31,14 +31,14 @@ export const useJobLeadsStore = defineStore("jobLeads", () => {
|
||||
* Load every lead, all states. `includeUnmatched` also returns the ones the
|
||||
* keyword pre-filter rejected, which is most of a company board.
|
||||
*/
|
||||
async function fetch({ includeUnmatched = false } = {}) {
|
||||
async function fetch({ includeUnmatched = false, filters = null } = {}) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await gql(
|
||||
`query JobLeads($includeUnmatched: Boolean) {
|
||||
jobLeads(includeUnmatched: $includeUnmatched) { ${LEAD_FIELDS} }
|
||||
`query JobLeads($includeUnmatched: Boolean, $filters: JobLeadFilters) {
|
||||
jobLeads(includeUnmatched: $includeUnmatched, filters: $filters) { ${LEAD_FIELDS} }
|
||||
}`,
|
||||
{ includeUnmatched },
|
||||
{ includeUnmatched, filters },
|
||||
);
|
||||
leads.value = data.jobLeads || [];
|
||||
error.value = null;
|
||||
@@ -63,11 +63,23 @@ export const useJobLeadsStore = defineStore("jobLeads", () => {
|
||||
return replace(data[mutation]);
|
||||
}
|
||||
|
||||
async function bulkTransition(mutation, ids) {
|
||||
const data = await gql(
|
||||
`mutation ${mutation}($ids: [ID!]!) { ${mutation}(ids: $ids) { ${LEAD_FIELDS} } }`,
|
||||
{ ids },
|
||||
);
|
||||
for (const lead of data[mutation] || []) replace(lead);
|
||||
return data[mutation] || [];
|
||||
}
|
||||
|
||||
/** Each returns the updated lead and throws on failure. */
|
||||
const dismiss = (id) => transition("dismissJobLead", id);
|
||||
const restore = (id) => transition("restoreJobLead", id);
|
||||
/** Adds the lead to the tracker as a saved application. */
|
||||
const promote = (id) => transition("promoteJobLead", id);
|
||||
const bulkDismiss = (ids) => bulkTransition("bulkDismissJobLeads", ids);
|
||||
const bulkRestore = (ids) => bulkTransition("bulkRestoreJobLeads", ids);
|
||||
const bulkPromote = (ids) => bulkTransition("bulkPromoteJobLeads", ids);
|
||||
|
||||
/** The posting text for one lead; `""` when the source gave none. Throws. */
|
||||
async function fetchDescription(id) {
|
||||
@@ -117,5 +129,5 @@ export const useJobLeadsStore = defineStore("jobLeads", () => {
|
||||
return data.rescoreJobLeads;
|
||||
}
|
||||
|
||||
return { leads, loading, error, status, fetch, dismiss, restore, promote, fetchDescription, fetchStatus, runSync, scoreAll, rescoreAll };
|
||||
return { leads, loading, error, status, fetch, dismiss, restore, promote, bulkDismiss, bulkRestore, bulkPromote, fetchDescription, fetchStatus, runSync, scoreAll, rescoreAll };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user