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:
|
||||
get:
|
||||
summary: Gets a list of ship calls
|
||||
#parameters:
|
||||
# - name: participant_id
|
||||
# in: query
|
||||
# required: true
|
||||
# description: "**Id of participant**. *Example: 2*. Id of participant entity requesting ship calls"
|
||||
# schema:
|
||||
# type: integer
|
||||
parameters:
|
||||
- name: past_days
|
||||
in: query
|
||||
required: false
|
||||
description: "number of days in the past to include in the result. *Example: 7*."
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
200:
|
||||
description: ship call list
|
||||
@ -348,7 +348,7 @@ components:
|
||||
required:
|
||||
- id
|
||||
- ship_id
|
||||
- type
|
||||
- type
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/shipcallId"
|
||||
|
||||
@ -47,6 +47,8 @@ namespace BreCalClient
|
||||
|
||||
private bool? _showCanceled = null;
|
||||
private SortOrder? _sortOrder;
|
||||
private int searchPastDays = 0;
|
||||
|
||||
// private bool _filterChanged = false;
|
||||
// private bool _sequenceChanged = false;
|
||||
|
||||
@ -293,7 +295,11 @@ namespace BreCalClient
|
||||
List<Shipcall>? shipcalls = null;
|
||||
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(() =>
|
||||
{
|
||||
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
|
||||
@ -430,6 +436,21 @@ namespace BreCalClient
|
||||
{
|
||||
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();
|
||||
// first add everything
|
||||
this._visibleControlModels.AddRange(_allShipcallsDict.Values);
|
||||
|
||||
@ -17,6 +17,7 @@ def GetShipcalls():
|
||||
token = request.headers.get('Authorization')
|
||||
options = {}
|
||||
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)
|
||||
else:
|
||||
|
||||
@ -19,10 +19,12 @@ def GetShipcalls(options):
|
||||
|
||||
pooledConnection = local_db.getPoolConnection()
|
||||
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, " +
|
||||
"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) " +
|
||||
"ORDER BY eta", model=model.Shipcall)
|
||||
"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"]) +
|
||||
"OR (type = 3 AND etd >= DATE(NOW() - INTERVAL %d DAY)) " % (options["past_days"]) +
|
||||
"ORDER BY eta" , model=model.Shipcall)
|
||||
for shipcall in data:
|
||||
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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user