Skip to content

Commit

Permalink
Translation - DBT text change - conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
sarithapillai8 committed Aug 24, 2023
2 parents bf10367 + 8cee021 commit e362766
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion public/locales/it/translation.json

Large diffs are not rendered by default.

27 changes: 23 additions & 4 deletions src/components/NotificationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ const useStyles = makeStyles((theme) => ({
},
}))

const findLastEvent = (events, activityId, balance, n = 0) => {
let event = events.filter((event) => event.activity === activityId)[n] ?? {}
if ((event["temporal_slices"] || []).length === 0) {
return balance
} else if (
(event["temporal_slices"] || []).length === 1 &&
event["temporal_slices"][(event["temporal_slices"] || []).length - 1]?.type === "manual_exit" &&
events.filter((event) => event.activity === activityId).length > 1
) {
return findLastEvent(events, activityId, ++n)
} else if (
(event["temporal_slices"] || []).length > 1 &&
event["temporal_slices"][(event["temporal_slices"] || []).length - 1]?.type === "manual_exit"
) {
return event["temporal_slices"][(event["temporal_slices"] || []).length - 2]?.type
} else {
return event["temporal_slices"]
? event["temporal_slices"][(event["temporal_slices"] || []).length - 1]?.type ?? balance
: balance
}
}

export default function NotificationPage({ participant, activityId, mode, tab, ...props }) {
const classes = useStyles()
const [activity, setActivity] = useState(null)
Expand All @@ -129,10 +151,7 @@ export default function NotificationPage({ participant, activityId, mode, tab, .
if (data.spec == "lamp.spin_wheel") {
;(async () => {
const events = await LAMP.ActivityEvent.allByParticipant(participant)
let event = events.filter((event) => event.activity === activityId)[0] ?? {}
const balance = !!event["temporal_slices"]
? event["temporal_slices"][(event["temporal_slices"] || []).length - 1]?.type
: 2000
const balance = findLastEvent(events, activityId, data.settings?.balance ?? 2000)
data["settings"]["balance"] = balance
data = spliceCTActivity({ raw: data, tag })
setActivity(data)
Expand Down
2 changes: 1 addition & 1 deletion src/components/PreventSelectedActivities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const strategies = {
"lamp.balloon_risk": (slices, activity, scopedItem) => parseInt(slices.points ?? 0).toFixed(1) || 0,
"lamp.pop_the_bubbles": (slices, activity, scopedItem) => {
let temporalSlices = slices.filter(function (data) {
return data.type === true
return !!data && data.type === true
})
return temporalSlices.length > 0 && slices.length > 0 ? temporalSlices.length / slices.length : 0
},
Expand Down
10 changes: 9 additions & 1 deletion src/components/Researcher/ActivityList/ActivityMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const SchemaList = () => {
settings: {
title: i18n.t("Activity Settings"),
type: "object",
required: ["low_risk", "high_risk", "spins_per_game"],
required: ["low_risk", "high_risk", "spins_per_game", "balance"],
properties: {
low_risk: {
title: i18n.t("Low Risk"),
Expand Down Expand Up @@ -175,6 +175,14 @@ export const SchemaList = () => {
xs: 6,
},
},
balance: {
title: i18n.t("Starting Balance"),
type: "number",
default: 2000,
"ui:grid": {
xs: 6,
},
},
},
},
},
Expand Down

0 comments on commit e362766

Please sign in to comment.