Skip to content

Commit

Permalink
Merge pull request #785 from BIDMCDigitalPsychiatry/issue-777
Browse files Browse the repository at this point in the history
survey percentage settings - QA fix
  • Loading branch information
sarithapillai8 authored Oct 12, 2023
2 parents 6dc86b6 + cb2df2e commit 5bf8aae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/PreventSelectedActivities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,25 @@ export const strategies = {

const getPercentageSettings = async (participantId, activities: ActivityObj[]) => {
let percentage = []
let activityEvents = await LAMP.ActivityEvent.allByParticipant(participantId)
return await Promise.all(
percentage.concat(
activities.map(async (activity) => {
let tag = [await LAMP.Type.getAttachment(activity.id, "lamp.dashboard.percentage_settings")].map((y: any) =>
!!y.error ? undefined : y.data
)[0]
const endTime = getEndTime(tag)
let activityEvents = await LAMP.ActivityEvent.allByParticipant(participantId, null, tag.startDate, endTime)
return {
activityId: activity.id,
percentage: Math.round((activityEvents.length / tag.limit) * 100 * 100) / 100,
percentage:
Math.round(
(activityEvents.filter(
(a) => a.activity === activity.id && a.timestamp >= tag.startDate && a.timestamp <= endTime
).length /
tag.limit) *
100 *
100
) / 100,
}
})
)
Expand Down

0 comments on commit 5bf8aae

Please sign in to comment.