-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Regolith Grant Report Builder #523
Open
vivianlin2000
wants to merge
12
commits into
regro:main
Choose a base branch
from
vivianlin2000:proposalreportbuilder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
85feb2b
Create proposalreportbuilder.py
vivianlin2000 78d735d
Create initial files
vivianlin2000 b9700cc
Changed Proposal Report Builder to Grant Report Builder
vivianlin2000 d549f98
Added template
vivianlin2000 65e7261
progress
vivianlin2000 83e178c
more edits
vivianlin2000 8e20314
Suggestions Implemented
vivianlin2000 db0168d
updates
vivianlin2000 d2410ba
Retrieved prums and people associated with grant and active during re…
vivianlin2000 bc72627
More Updates
vivianlin2000 0490554
updates
vivianlin2000 6546f6e
Updates
vivianlin2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
|
||
|
||
def subparser(subpi): | ||
subpi.add_argument("authorFullName", help="full name of the author of this grant report") | ||
subpi.add_argument("start_date", help="start date of the reporting period, formatted as YYYY-MM-DD", | ||
default=None) | ||
subpi.add_argument("end_date", help="end date of the reporting period, formatted as YYYY-MM-DD") | ||
|
@@ -32,7 +33,7 @@ def subparser(subpi): | |
class GrantReportBuilder(LatexBuilderBase): | ||
"""Build a proposal review from database entries""" | ||
btype = "grantreport" | ||
needed_dbs = ['presentations', 'projecta', 'people', 'grants', 'institutions', 'expenses', 'citations'] | ||
needed_dbs = ['presentations', 'projecta', 'people', 'grants', 'institutions', 'expenses', 'citations', 'contacts'] | ||
|
||
def construct_global_ctx(self): | ||
"""Constructs the global context""" | ||
|
@@ -100,32 +101,78 @@ def latex(self): | |
defended_theses.append(id) | ||
|
||
# Products | ||
# need rg-db-public's citation.yml... how to access that instead of the rg-db-group's citation.yml file | ||
# need rg-db-public's citation.yml | ||
publications = filter_publications(self.gtx["citations"], grant_people, since=rp_start_date, before=rp_end_date) | ||
|
||
# Participants/Organizations | ||
participants = {} | ||
for person in grant_people: | ||
p = self.gtx["people"].get(person) | ||
months = 0 | ||
if p['active']: | ||
difference = datetime.today() - rp_start_date | ||
if difference.day > 15: | ||
months = months + 1 | ||
months = difference.year * 12 + difference.month | ||
else: | ||
for name in grant_people: | ||
person = self.gtx["people"].get(name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to get things from a collection we use things like |
||
months_on_grant, months_left = self.months_on(grant_name, person, rp_start_date, rp_end_date) | ||
participants[name] = [person.get('position'), months_on_grant] | ||
|
||
# Other Collaborators | ||
collaborator_ids = [] | ||
for prum in grant_prums: | ||
collabs = prum.get("collaborators") | ||
if collabs: | ||
for id in collabs: | ||
collaborator_ids.append(id) | ||
collaborator_ids = set(collaborator_ids) | ||
|
||
collaborators = {} | ||
for id in collaborator_ids: | ||
contact = self.gtx["contacts"].get(id) | ||
aka = contact.get("aka") | ||
institution = contact.get("institution") | ||
collaborators[id] = { | ||
"aka": aka, | ||
"institution": institution | ||
} | ||
|
||
# Impacts | ||
|
||
end_date = datetime.date(p['year']) | ||
info = [p.get('position'), months] | ||
self.render( | ||
"grantreport.txt", | ||
"billinge_grant_report.txt", | ||
authorFullName=rc.authorFullName, | ||
beginYear=rp_start_date.year, | ||
endYear=rp_end_date.year, | ||
majorActivities=major_activities, | ||
significantResults=significant_results, | ||
trainingAndProfessionalDevelopment=training_and_professional_development, | ||
defendedTheses=defended_theses, | ||
products=publications, | ||
grantPeople=grant_people | ||
grantPeople=grant_people, | ||
participants=participants, | ||
collaborators=collaborators | ||
) | ||
|
||
def months_on(self, grant, person, since=datetime(1970, 1, 1), before=datetime.today()): | ||
# print('Looking at months on grant {} in period since {} until {}'.format( | ||
# grant, since, before), ) | ||
total_months = 0 | ||
appts = person.get('appointments') | ||
if appts: | ||
months = 0 | ||
for k1, v1 in appts.items(): | ||
if grant in v1.get('grant'): | ||
dates = get_dates(v1) | ||
startdate = dates.get('start_date') | ||
enddate = dates.get('end_date') | ||
loading = v1.get('loading') | ||
if startdate >= since and enddate <= before: | ||
months = months + ( | ||
enddate - startdate).days * loading / 30.4 | ||
elif startdate >= since and enddate > before: | ||
months = months + ( | ||
before - startdate).days * loading / 30.4 | ||
elif startdate < since and enddate <= before: | ||
months = months + ( | ||
enddate - since).days * loading / 30.4 | ||
elif startdate < since and enddate > before: | ||
months = months + (before - since).days * loading / 30.4 | ||
if months > 0: | ||
total_months = total_months + months | ||
months_left = (before - datetime.today()) | ||
return total_months, months_left |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very brittle. I doubt I will ever remember the full name of people and whether it is capitalized and spaces and whatnot. We have two choices here.
(2) is probably better because (1) is also covered by (2)