Skip to content
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

fix(feedback): store service id rather than schedule id #5374

Merged
merged 6 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 10 additions & 7 deletions src/dispatch/feedback/service/scheduled.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging
from datetime import datetime

from dispatch.database.core import SessionLocal
from sqlalchemy.orm import Session

from dispatch.decorators import scheduled_project_task, timer
from dispatch.individual import service as individual_service
from dispatch.plugin import service as plugin_service
Expand Down Expand Up @@ -30,20 +31,20 @@
@scheduler.add(every(1).day.at("16:00"), name="oncall-shift-feedback-ucan")
@timer
@scheduled_project_task
def oncall_shift_feedback_ucan(db_session: SessionLocal, project: Project):
def oncall_shift_feedback_ucan(db_session: Session, project: Project):
oncall_shift_feedback(db_session=db_session, project=project, hour=16)
find_expired_reminders_and_send(db_session=db_session, project=project)


@scheduler.add(every(1).day.at("06:00"), name="oncall-shift-feedback-emea")
@timer
@scheduled_project_task
def oncall_shift_feedback_emea(db_session: SessionLocal, project: Project):
def oncall_shift_feedback_emea(db_session: Session, project: Project):
oncall_shift_feedback(db_session=db_session, project=project, hour=6)
find_expired_reminders_and_send(db_session=db_session, project=project)


def find_expired_reminders_and_send(*, db_session: SessionLocal, project: Project):
def find_expired_reminders_and_send(*, db_session: Session, project: Project):
reminders = reminder_service.get_all_expired_reminders_by_project_id(
db_session=db_session, project_id=project.id
)
Expand All @@ -65,10 +66,11 @@ def find_expired_reminders_and_send(*, db_session: SessionLocal, project: Projec

def find_schedule_and_send(
*,
db_session: SessionLocal,
db_session: Session,
project: Project,
oncall_plugin: PluginInstance,
schedule_id: str,
service_id: str,
hour: int,
):
"""
Expand Down Expand Up @@ -133,15 +135,15 @@ def count_active_participants(participants):
send_oncall_shift_feedback_message(
project=project,
individual=individual,
schedule_id=schedule_id,
schedule_id=service_id,
whitdog47 marked this conversation as resolved.
Show resolved Hide resolved
shift_end_at=current_oncall["shift_end"],
schedule_name=current_oncall["schedule_name"],
details=details,
db_session=db_session,
)


def oncall_shift_feedback(db_session: SessionLocal, project: Project, hour: int):
def oncall_shift_feedback(db_session: Session, project: Project, hour: int):
"""
Experimental: collects feedback from individuals participating in an oncall service that has health metrics enabled
when their oncall shift ends. For now, only for one project and schedule.
Expand Down Expand Up @@ -174,5 +176,6 @@ def oncall_shift_feedback(db_session: SessionLocal, project: Project, hour: int)
project=project,
oncall_plugin=oncall_plugin,
schedule_id=schedule_id,
service_id=external_id,
hour=hour,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
<project-combobox v-model="local_project" label="Projects" />
</v-list-item>
<v-list-item>
<service-select v-model="local_service" label="Oncall service" />
<service-select
v-model="local_service"
:health-metrics="true"
:project="local_project"
label="Oncall service"
/>
</v-list-item>
</v-list>
<v-card-actions>
Expand Down
44 changes: 32 additions & 12 deletions src/dispatch/static/dispatch/src/service/ServiceSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
chips
multiple
closable-chips
/>
><template #append-item>

Check warning on line 19 in src/dispatch/static/dispatch/src/service/ServiceSelect.vue

View workflow job for this annotation

GitHub Actions / build

Expected 1 line break after opening tag (`<v-combobox>`), but no line breaks found
<v-list-item v-if="more" @click="loadMore">
<v-list-item-subtitle>Load More</v-list-item-subtitle>
</v-list-item>
</template>
</v-combobox>
</template>

<script>
import { cloneDeep } from "lodash"

import { debounce } from "lodash"
import SearchUtils from "@/search/utils"
import ServiceApi from "@/service/api"

Expand All @@ -48,9 +53,13 @@
},
},
project: {
type: [Object],
type: Object,
default: null,
},
healthMetrics: {
type: Boolean,
default: false,
},
},

data() {
Expand All @@ -59,6 +68,9 @@
search: null,
select: null,
items: [],
more: false,
numItems: 5,
total: 0,
}
},

Expand All @@ -84,30 +96,38 @@
},

methods: {
fetchData() {
loadMore() {
this.numItems += 5
this.fetchData()
},
fetchData: debounce(function () {
this.error = null
this.loading = "error"
let filterOptions = {
q: this.search,
sortBy: ["name"],
descending: [false],
itemsPerPage: this.numItems,
filters: { is_active: ["true"] },
}

if (this.project) {
filterOptions = {
...filterOptions,
filters: {
project: [this.project],
},
}
filterOptions = SearchUtils.createParametersFromTableOptions({ ...filterOptions })
filterOptions.filters.project_id = this.project.map((p) => p.id)
}

if (this.healthMetrics) {
filterOptions.filters.health_metrics = ["true"]
}

filterOptions = SearchUtils.createParametersFromTableOptions({ ...filterOptions })

ServiceApi.getAll(filterOptions).then((response) => {
this.items = response.data.items
this.total = response.data.total
this.more = this.items.length < this.total
this.loading = false
})
},
}, 300),
},
created() {
this.fetchData()
Expand Down
Loading