mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-21 22:17:51 +00:00
Exclude disabled devices from Class-B/C scheduler.
Closes brocaar/chirpstack-network-server#612.
This commit is contained in:
parent
4f1a1bbce5
commit
ed9a9b0c88
@ -121,6 +121,7 @@ pub struct DeviceChangeset {
|
|||||||
pub external_power_source: Option<bool>,
|
pub external_power_source: Option<bool>,
|
||||||
pub battery_level: Option<Option<BigDecimal>>,
|
pub battery_level: Option<Option<BigDecimal>>,
|
||||||
pub scheduler_run_after: Option<Option<DateTime<Utc>>>,
|
pub scheduler_run_after: Option<Option<DateTime<Utc>>>,
|
||||||
|
pub is_disabled: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Device {
|
impl Device {
|
||||||
@ -699,6 +700,7 @@ pub async fn get_with_class_b_c_queue_items(limit: usize) -> Result<Vec<Device>>
|
|||||||
where
|
where
|
||||||
d.enabled_class in ('B', 'C')
|
d.enabled_class in ('B', 'C')
|
||||||
and (d.scheduler_run_after is null or d.scheduler_run_after < $2)
|
and (d.scheduler_run_after is null or d.scheduler_run_after < $2)
|
||||||
|
and d.is_disabled = false
|
||||||
and exists (
|
and exists (
|
||||||
select
|
select
|
||||||
1
|
1
|
||||||
@ -961,11 +963,26 @@ pub mod test {
|
|||||||
let res = get_with_class_b_c_queue_items(10).await.unwrap();
|
let res = get_with_class_b_c_queue_items(10).await.unwrap();
|
||||||
assert_eq!(0, res.len());
|
assert_eq!(0, res.len());
|
||||||
|
|
||||||
|
// Class-C item pending, but device is disabled.
|
||||||
|
let d = partial_update(
|
||||||
|
d.dev_eui,
|
||||||
|
&DeviceChangeset {
|
||||||
|
scheduler_run_after: Some(None),
|
||||||
|
is_disabled: Some(true),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let res = get_with_class_b_c_queue_items(10).await.unwrap();
|
||||||
|
assert_eq!(0, res.len());
|
||||||
|
|
||||||
// device in class C / downlink is pending.
|
// device in class C / downlink is pending.
|
||||||
let _ = partial_update(
|
let _ = partial_update(
|
||||||
d.dev_eui,
|
d.dev_eui,
|
||||||
&DeviceChangeset {
|
&DeviceChangeset {
|
||||||
scheduler_run_after: Some(None),
|
scheduler_run_after: Some(None),
|
||||||
|
is_disabled: Some(false),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user