Skip to content

Issue #327: VolunteerHistory and Donations show most recent 3 #333

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

Merged
merged 2 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/client/src/pages/DataView360/View/components/Donations.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const customStyles = theme => ({
}
});

const ROWS_TO_SHOW = 5
const ROWS_TO_SHOW = 3

class Donations extends Component {
constructor(props) {
Expand Down Expand Up @@ -57,7 +57,7 @@ class Donations extends Component {

render() {
const {classes} = this.props;

const headerText = `Financial Support Activity (Most Recent ${ROWS_TO_SHOW})`
return (
<Container component={Paper} style={{"marginTop": "1em"}}>
<Typography variant='h5'>
Expand All @@ -66,7 +66,7 @@ class Donations extends Component {
<AttachMoneyIcon color='primary' fontSize='inherit'/>
</Grid>
<Grid item>
Financial Support Activity (Top 5)
{headerText}
</Grid>
</Grid>
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ const customStyles = theme => ({
},
});

const SHIFTS_TO_SHOW = 5;
const SHIFTS_TO_SHOW = 3;

class VolunteerHistory extends Component {

createShiftRows(shifts) {
const shiftsSorted = _.sortBy(shifts, shift => {
return new moment(shift.from);
const shiftsFiltered = _.filter(shifts, function(s) { return s.from !== "Invalid date"});
const shiftsSorted = _.sortBy(shiftsFiltered, shift => {
return new moment(shift.from).format("YYYY-MM-DD");
}).reverse();

const lastShifts = shiftsSorted.slice(shiftsSorted.length - SHIFTS_TO_SHOW, shiftsSorted.length)

const lastShifts = shiftsSorted.slice(0, SHIFTS_TO_SHOW)
const result = _.map(lastShifts, (shift, index) => {
shift.from = moment(shift.from).format("YYYY-MM-DD")
return(<TableRow key={index}>
<TableCell>{moment(shift.from).format("MM-DD-YYYY")}</TableCell>
<TableCell>{shift.from}</TableCell>
<TableCell>{shift.assignment}</TableCell>
</TableRow>);

Expand All @@ -53,7 +55,7 @@ class VolunteerHistory extends Component {
return (
<React.Fragment>
<Container component={Paper} style={{"marginTop": "1em"}}>
<DataTableHeader headerText={"Volunteer History (Top 5)"}
<DataTableHeader headerText={`Volunteer History (Most Recent ${SHIFTS_TO_SHOW})`}
emojiIcon={<TimelineIcon color='primary' fontSize='inherit'/>}
/>
<TableContainer component={Paper} style={{"marginBottom":"1em"}} variant='outlined'>
Expand Down
9 changes: 6 additions & 3 deletions src/server/api/common_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ def get_360(matching_id):
for r in volgistics_shifts_query_result:
shifts = dict(r)
# normalize date string
parsed_date_from = dateutil.parser.parse(shifts["from"], ignoretz=True)
normalized_date_from = parsed_date_from.strftime("%Y-%m-%d")
shifts["from"] = normalized_date_from
if shifts["from"]:
parsed_date_from = dateutil.parser.parse(shifts["from"], ignoretz=True)
normalized_date_from = parsed_date_from.strftime("%Y-%m-%d")
shifts["from"] = normalized_date_from
else:
shifts["from"] = "Invalid date"
volgisticsshifts_results.append(shifts)

result['shifts'] = volgisticsshifts_results
Expand Down