Skip to content

Commit

Permalink
cast survey type, remove filters change
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasheriques committed Feb 22, 2025
1 parent 4154fec commit 858973d
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,11 @@ export const surveyLogic = kea<surveyLogicType>([
activationLogic.findMounted()?.actions.markTaskAsCompleted(ActivationTask.LaunchSurvey)
}

// Initialize date range based on survey dates when survey is loaded
if ('created_at' in values.survey) {
const dateRange = {
date_from: getSurveyStartDateForQuery(values.survey),
date_to: getSurveyEndDateForQuery(values.survey),
}
actions.setDateRange(dateRange)
const dateRange = {
date_from: getSurveyStartDateForQuery(values.survey as Survey),
date_to: getSurveyEndDateForQuery(values.survey as Survey),
}
actions.setDateRange(dateRange)
},
resetSurveyResponseLimits: () => {
actions.setSurveyValue('responses_limit', null)
Expand Down Expand Up @@ -1424,17 +1421,11 @@ export const surveyLogic = kea<surveyLogicType>([
(survey: Survey): IntervalType => {
const start = getSurveyStartDateForQuery(survey)
const end = getSurveyEndDateForQuery(survey)
const diffInDays = dayjs(end).diff(dayjs(start), 'days')
const diffInWeeks = dayjs(end).diff(dayjs(start), 'weeks')

if (diffInDays < 2) {
return 'hour'
}
// less than a month
if (diffInDays < 30) {
if (diffInWeeks <= 4) {
return 'day'
}
// more than a month, less than 3 months
if (diffInDays < 90) {
} else if (diffInWeeks <= 12) {
return 'week'
}
return 'month'
Expand Down

0 comments on commit 858973d

Please sign in to comment.