Fixed eta / etd search error and evaluate searchFromEta as filter used against the back-end to retrieve shipcalls from the past
This commit is contained in:
parent
a763589587
commit
13c5866884
File diff suppressed because it is too large
Load Diff
@ -68,13 +68,13 @@ paths:
|
|||||||
/shipcalls:
|
/shipcalls:
|
||||||
get:
|
get:
|
||||||
summary: Gets a list of ship calls
|
summary: Gets a list of ship calls
|
||||||
#parameters:
|
parameters:
|
||||||
# - name: participant_id
|
- name: past_days
|
||||||
# in: query
|
in: query
|
||||||
# required: true
|
required: false
|
||||||
# description: "**Id of participant**. *Example: 2*. Id of participant entity requesting ship calls"
|
description: "number of days in the past to include in the result. *Example: 7*."
|
||||||
# schema:
|
schema:
|
||||||
# type: integer
|
type: integer
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: ship call list
|
description: ship call list
|
||||||
@ -348,7 +348,7 @@ components:
|
|||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- ship_id
|
- ship_id
|
||||||
- type
|
- type
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
$ref: "#/components/schemas/shipcallId"
|
$ref: "#/components/schemas/shipcallId"
|
||||||
|
|||||||
@ -47,6 +47,8 @@ namespace BreCalClient
|
|||||||
|
|
||||||
private bool? _showCanceled = null;
|
private bool? _showCanceled = null;
|
||||||
private SortOrder? _sortOrder;
|
private SortOrder? _sortOrder;
|
||||||
|
private int searchPastDays = 0;
|
||||||
|
|
||||||
// private bool _filterChanged = false;
|
// private bool _filterChanged = false;
|
||||||
// private bool _sequenceChanged = false;
|
// private bool _sequenceChanged = false;
|
||||||
|
|
||||||
@ -293,7 +295,11 @@ namespace BreCalClient
|
|||||||
List<Shipcall>? shipcalls = null;
|
List<Shipcall>? shipcalls = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
shipcalls = await _api.ShipcallsGetAsync();
|
if(this.searchPastDays != 0)
|
||||||
|
shipcalls = await _api.ShipcallsGetAsync(this.searchPastDays);
|
||||||
|
else
|
||||||
|
shipcalls = await _api.ShipcallsGetAsync();
|
||||||
|
|
||||||
this.Dispatcher.Invoke(new Action(() =>
|
this.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
|
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
|
||||||
@ -430,6 +436,21 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
SearchFilterModel sfm = this.searchFilterControl.SearchFilter;
|
SearchFilterModel sfm = this.searchFilterControl.SearchFilter;
|
||||||
|
|
||||||
|
if( sfm.EtaFrom.HasValue && sfm.EtaFrom < DateTime.Now.AddDays(-2))
|
||||||
|
{
|
||||||
|
int daysInThePast = (int)Math.Ceiling((DateTime.Now - sfm.EtaFrom.Value).TotalDays);
|
||||||
|
if (this.searchPastDays != daysInThePast)
|
||||||
|
{
|
||||||
|
this.searchPastDays = daysInThePast;
|
||||||
|
_refreshImmediately = true; // set flag to avoid timer loop termination
|
||||||
|
_tokenSource.Cancel(); // force timer loop end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
searchPastDays = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this._visibleControlModels.Clear();
|
this._visibleControlModels.Clear();
|
||||||
// first add everything
|
// first add everything
|
||||||
this._visibleControlModels.AddRange(_allShipcallsDict.Values);
|
this._visibleControlModels.AddRange(_allShipcallsDict.Values);
|
||||||
|
|||||||
@ -17,6 +17,7 @@ def GetShipcalls():
|
|||||||
token = request.headers.get('Authorization')
|
token = request.headers.get('Authorization')
|
||||||
options = {}
|
options = {}
|
||||||
options["participant_id"] = request.args.get("participant_id")
|
options["participant_id"] = request.args.get("participant_id")
|
||||||
|
options["past_days"] = request.args.get("past_days", default=2, type=int)
|
||||||
|
|
||||||
return impl.shipcalls.GetShipcalls(options)
|
return impl.shipcalls.GetShipcalls(options)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -19,10 +19,12 @@ def GetShipcalls(options):
|
|||||||
|
|
||||||
pooledConnection = local_db.getPoolConnection()
|
pooledConnection = local_db.getPoolConnection()
|
||||||
commands = pydapper.using(pooledConnection)
|
commands = pydapper.using(pooledConnection)
|
||||||
|
|
||||||
data = commands.query("SELECT id, ship_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, " +
|
data = commands.query("SELECT id, ship_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, " +
|
||||||
"flags, pier_side, bunkering, replenishing_terminal, replenishing_lock, draft, tidal_window_from, tidal_window_to, rain_sensitive_cargo, recommended_tugs, " +
|
"flags, pier_side, bunkering, replenishing_terminal, replenishing_lock, draft, tidal_window_from, tidal_window_to, rain_sensitive_cargo, recommended_tugs, " +
|
||||||
"anchored, moored_lock, canceled, evaluation, evaluation_message, created, modified FROM shipcall WHERE eta IS NULL OR eta >= DATE(NOW() - INTERVAL 2 DAY) " +
|
"anchored, moored_lock, canceled, evaluation, evaluation_message, created, modified FROM shipcall WHERE ((type = 1 OR type = 2) AND eta >= DATE(NOW() - INTERVAL %d DAY) " % (options["past_days"]) +
|
||||||
"ORDER BY eta", model=model.Shipcall)
|
"OR (type = 3 AND etd >= DATE(NOW() - INTERVAL %d DAY)) " % (options["past_days"]) +
|
||||||
|
"ORDER BY eta" , model=model.Shipcall)
|
||||||
for shipcall in data:
|
for shipcall in data:
|
||||||
participant_query = "SELECT participant_id, type FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?";
|
participant_query = "SELECT participant_id, type FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?";
|
||||||
for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False):
|
for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user