-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename org to nonprofit (so we can use 'org' to refer to an organizat…
…ion member is a user of)
- Loading branch information
1 parent
186287d
commit 2708b35
Showing
25 changed files
with
234 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import _ from 'lodash' | ||
import { GraphqlFormatter, Loader } from 'backend-shared' | ||
|
||
import IrsNonprofit from './model.js' | ||
import IrsNonprofit990 from '../irs_nonprofit_990/model.js' | ||
|
||
const nonprofitLoader = Loader.withContext((eins, context) => { | ||
return IrsNonprofit.getAllByEins(eins) | ||
.then((irsNonprofits) => { | ||
irsNonprofits = _.keyBy(irsNonprofits, 'ein') | ||
return _.map(eins, ein => irsNonprofits[ein]) | ||
}) | ||
}) | ||
|
||
export default { | ||
Query: { | ||
irsNonprofit (rootValue, { ein }) { | ||
return IrsNonprofit.getByEin(ein) | ||
}, | ||
|
||
irsNonprofits (rootValue, { query, sort, limit }) { | ||
return IrsNonprofit.search({ query, sort, limit }) | ||
.then(GraphqlFormatter.fromElasticsearch) | ||
} | ||
}, | ||
|
||
IrsNonprofit: { | ||
async yearlyStats (irsNonprofit) { | ||
let irs990s = await IrsNonprofit990.getAllByEin(irsNonprofit.ein) | ||
irs990s = _.orderBy(irs990s, 'year') | ||
return { | ||
years: _.map(irs990s, irs990 => ({ | ||
year: irs990.year, | ||
assets: irs990.assets?.eoy, | ||
employeeCount: irs990.employeeCount, | ||
volunteerCount: irs990.volunteerCount | ||
})) | ||
} | ||
} | ||
}, | ||
|
||
IrsPerson: { | ||
async irsNonprofit (irsPerson, __, context) { | ||
if (irsPerson.entityType === 'nonprofit') { | ||
return await nonprofitLoader(context).load(irsPerson.ein) | ||
} else { | ||
return null | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { GraphqlFormatter } from 'backend-shared' | ||
|
||
import IrsNonprofit990 from './model.js' | ||
|
||
export default { | ||
Query: { | ||
irsNonprofit990s (rootValue, { ein, query, limit }) { | ||
if (ein) { | ||
return IrsNonprofit990.getAllByEin(ein, { limit }) | ||
.then(GraphqlFormatter.fromScylla) | ||
} else { | ||
return IrsNonprofit990.search({ query, limit }) | ||
.then(GraphqlFormatter.fromElasticsearch) | ||
} | ||
} | ||
}, | ||
|
||
IrsNonprofit: { | ||
irsNonprofit990s (irsNonprofit, { limit }) { | ||
return IrsNonprofit990.getAllByEin(irsNonprofit.ein, { limit }) | ||
.then(GraphqlFormatter.fromScylla) | ||
} | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.