Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit f3f754a

Browse files
committed
Fixes badspec exception
1 parent 9301882 commit f3f754a

File tree

6 files changed

+44
-23
lines changed

6 files changed

+44
-23
lines changed

src/dispatch/database/service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def apply_model_specific_filters(
280280
return query
281281

282282

283-
def apply_filters(query, filter_spec, do_auto_join=True):
283+
def apply_filters(query, filter_spec, model_cls, do_auto_join=True):
284284
"""Apply filters to a SQLAlchemy query.
285285
286286
:param query:
@@ -317,6 +317,8 @@ def apply_filters(query, filter_spec, do_auto_join=True):
317317
"""
318318
filters = build_filters(filter_spec)
319319
default_model = get_default_model(query)
320+
if not default_model:
321+
default_model = model_cls
320322
filter_models = get_named_models(filters)[0]
321323

322324
if do_auto_join:
@@ -470,7 +472,7 @@ def search_filter_sort_paginate(
470472

471473
if filter_spec:
472474
query = apply_filter_specific_joins(model_cls, filter_spec, query)
473-
query = apply_filters(query, filter_spec)
475+
query = apply_filters(query, filter_spec, model_cls)
474476

475477
if sort_by:
476478
sort_spec = create_sort_spec(model, sort_by, descending)

src/dispatch/static/dispatch/src/dashboard/DataOverview.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
<v-btn color="info" @click="copyView"> Share View </v-btn>
66
</v-flex>
77
<v-flex class="d-flex justify-end" lg6 sm6 xs12>
8-
<dialog-filter @filterOptions="setFilterOptions" @update="update" @loading="setLoading" :projects="defaultUserProjects" />
8+
<dialog-filter
9+
@filterOptions="setFilterOptions"
10+
@update="update"
11+
@loading="setLoading"
12+
:projects="defaultUserProjects"
13+
/>
914
</v-flex>
1015
</v-layout>
1116
<v-row>

src/dispatch/static/dispatch/src/dashboard/IncidentOverview.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
<v-btn color="info" @click="copyView"> Share View </v-btn>
1111
</v-flex>
1212
<v-flex class="d-flex justify-end" lg6 sm6 xs12>
13-
<incident-dialog-filter @update="update" @loading="setLoading" :projects="defaultUserProjects" />
13+
<incident-dialog-filter
14+
@update="update"
15+
@loading="setLoading"
16+
:projects="defaultUserProjects"
17+
/>
1418
</v-flex>
1519
</v-layout>
1620
<v-layout row wrap>

src/dispatch/static/dispatch/src/dashboard/TaskDialogFilter.vue

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<v-list dense>
1313
<v-list-item>
1414
<v-list-item-content>
15-
<incident-window-input v-model="filters.created_at" />
15+
<incident-window-input v-model="filters.created_at" label="Created At" />
1616
</v-list-item-content>
1717
</v-list-item>
1818
<v-list-item>
@@ -42,6 +42,7 @@
4242
<script>
4343
import { mapFields } from "vuex-map-fields"
4444
import { sum } from "lodash"
45+
import startOfMonth from "date-fns/startOfMonth"
4546
import subMonths from "date-fns/subMonths"
4647
4748
import IncidentPriorityCombobox from "@/incident_priority/IncidentPriorityCombobox.vue"
@@ -60,6 +61,13 @@ let today = function () {
6061
export default {
6162
name: "TaskOverviewFilterDialog",
6263
64+
components: {
65+
IncidentTypeCombobox,
66+
IncidentPriorityCombobox,
67+
ProjectCombobox,
68+
IncidentWindowInput,
69+
},
70+
6371
props: {
6472
projects: {
6573
type: Array,
@@ -81,8 +89,8 @@ export default {
8189
status: [],
8290
tag: [],
8391
created_at: {
84-
start: subMonths(today(), 6).toISOString().substr(0, 10),
85-
end: today().toISOString().substr(0, 10),
92+
start: null,
93+
end: null,
8694
},
8795
},
8896
}
@@ -117,26 +125,27 @@ export default {
117125
filters: { ...this.filters },
118126
}
119127
120-
filterOptions = SearchUtils.createParametersFromTableOptions(filterOptions)
121-
122128
this.$emit("loading", "error")
123-
this.$emit("filterOptions", filterOptions)
129+
filterOptions = SearchUtils.createParametersFromTableOptions(filterOptions)
130+
// this.$emit("filterOptions", filterOptions)
124131
TaskApi.getAll(filterOptions).then((response) => {
125132
this.$emit("update", response.data.items)
126133
this.$emit("loading", false)
127134
})
128135
},
129136
},
130137
131-
components: {
132-
IncidentTypeCombobox,
133-
IncidentPriorityCombobox,
134-
ProjectCombobox,
135-
IncidentWindowInput,
136-
},
137-
138138
created() {
139-
this.filters = { ...this.filters, ...RouterUtils.deserializeFilters(this.query) }
139+
this.filters = {
140+
...this.filters,
141+
...{
142+
created_at: {
143+
start: startOfMonth(subMonths(today(), 1)).toISOString().slice(0, -1),
144+
end: today().toISOString().slice(0, -1),
145+
},
146+
},
147+
...RouterUtils.deserializeFilters(this.query), // Order matters as values will overwrite
148+
}
140149
this.fetchData()
141150
},
142151
}

src/dispatch/static/dispatch/src/incident/Table.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export default {
220220
this.filters = {
221221
...this.filters,
222222
...RouterUtils.deserializeFilters(this.query),
223-
project: this.defaultUserProjects
223+
project: this.defaultUserProjects,
224224
}
225225
226226
this.getAll()

src/dispatch/task/views.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
from typing import List
23
from fastapi import APIRouter, Depends, HTTPException, Query, status
34

@@ -18,10 +19,10 @@
1819

1920
@router.get("", summary="Retrieve a list of all tasks.")
2021
def get_tasks(
21-
*, include: List[str] = Query([], alias="include[]"), commons: dict = Depends(common_parameters)
22+
*, common: dict = Depends(common_parameters), include: List[str] = Query([], alias="include[]")
2223
):
2324
"""Retrieve all tasks."""
24-
pagination = search_filter_sort_paginate(model="Task", **commons)
25+
pagination = search_filter_sort_paginate(model="Task", **common)
2526

2627
if include:
2728
# only allow two levels for now
@@ -34,8 +35,8 @@ def get_tasks(
3435
"total": ...,
3536
}
3637

37-
return TaskPagination(**pagination).dict(include=include_fields)
38-
return TaskPagination(**pagination).dict()
38+
return json.loads(TaskPagination(**pagination).json(include=include_fields))
39+
return json.loads(TaskPagination(**pagination).json())
3940

4041

4142
@router.post("", response_model=TaskRead, tags=["tasks"])

0 commit comments

Comments
 (0)