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
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
//----------------------
|
//----------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// Generated REST API Client Code Generator v1.8.7.0 on 13.10.2023 10:51:41
|
// Generated REST API Client Code Generator v1.8.4.0 on 23.10.2023 09:06:40
|
||||||
// Using the tool OpenAPI Generator v7.0.1
|
// Using the tool OpenAPI Generator v7.0.0
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//----------------------
|
//----------------------
|
||||||
|
|
||||||
@ -139,9 +139,10 @@ namespace BreCalClient.misc.Api
|
|||||||
/// Gets a list of ship calls
|
/// Gets a list of ship calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <returns>List<Shipcall></returns>
|
/// <returns>List<Shipcall></returns>
|
||||||
List<Shipcall> ShipcallsGet(int operationIndex = 0);
|
List<Shipcall> ShipcallsGet(int? pastDays = default(int?), int operationIndex = 0);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of ship calls
|
/// Gets a list of ship calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -149,9 +150,10 @@ namespace BreCalClient.misc.Api
|
|||||||
///
|
///
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <returns>ApiResponse of List<Shipcall></returns>
|
/// <returns>ApiResponse of List<Shipcall></returns>
|
||||||
ApiResponse<List<Shipcall>> ShipcallsGetWithHttpInfo(int operationIndex = 0);
|
ApiResponse<List<Shipcall>> ShipcallsGetWithHttpInfo(int? pastDays = default(int?), int operationIndex = 0);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new ship call
|
/// Create a new ship call
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -413,10 +415,11 @@ namespace BreCalClient.misc.Api
|
|||||||
///
|
///
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <returns>Task of List<Shipcall></returns>
|
/// <returns>Task of List<Shipcall></returns>
|
||||||
System.Threading.Tasks.Task<List<Shipcall>> ShipcallsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
System.Threading.Tasks.Task<List<Shipcall>> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of ship calls
|
/// Gets a list of ship calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -424,10 +427,11 @@ namespace BreCalClient.misc.Api
|
|||||||
///
|
///
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <returns>Task of ApiResponse (List<Shipcall>)</returns>
|
/// <returns>Task of ApiResponse (List<Shipcall>)</returns>
|
||||||
System.Threading.Tasks.Task<ApiResponse<List<Shipcall>>> ShipcallsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
System.Threading.Tasks.Task<ApiResponse<List<Shipcall>>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new ship call
|
/// Create a new ship call
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1217,20 +1221,22 @@ namespace BreCalClient.misc.Api
|
|||||||
/// Gets a list of ship calls
|
/// Gets a list of ship calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <returns>List<Shipcall></returns>
|
/// <returns>List<Shipcall></returns>
|
||||||
public List<Shipcall> ShipcallsGet(int operationIndex = 0)
|
public List<Shipcall> ShipcallsGet(int? pastDays = default(int?), int operationIndex = 0)
|
||||||
{
|
{
|
||||||
BreCalClient.misc.Client.ApiResponse<List<Shipcall>> localVarResponse = ShipcallsGetWithHttpInfo();
|
BreCalClient.misc.Client.ApiResponse<List<Shipcall>> localVarResponse = ShipcallsGetWithHttpInfo(pastDays);
|
||||||
return localVarResponse.Data;
|
return localVarResponse.Data;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of ship calls
|
/// Gets a list of ship calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <returns>ApiResponse of List<Shipcall></returns>
|
/// <returns>ApiResponse of List<Shipcall></returns>
|
||||||
public BreCalClient.misc.Client.ApiResponse<List<Shipcall>> ShipcallsGetWithHttpInfo(int operationIndex = 0)
|
public BreCalClient.misc.Client.ApiResponse<List<Shipcall>> ShipcallsGetWithHttpInfo(int? pastDays = default(int?), int operationIndex = 0)
|
||||||
{
|
{
|
||||||
BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions();
|
BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions();
|
||||||
string[] _contentTypes = new string[] {
|
string[] _contentTypes = new string[] {
|
||||||
@ -1249,6 +1255,10 @@ namespace BreCalClient.misc.Api
|
|||||||
{
|
{
|
||||||
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
||||||
}
|
}
|
||||||
|
if (pastDays != null)
|
||||||
|
{
|
||||||
|
localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "past_days", pastDays));
|
||||||
|
}
|
||||||
localVarRequestOptions.Operation = "DefaultApi.ShipcallsGet";
|
localVarRequestOptions.Operation = "DefaultApi.ShipcallsGet";
|
||||||
localVarRequestOptions.OperationIndex = operationIndex;
|
localVarRequestOptions.OperationIndex = operationIndex;
|
||||||
// authentication (ApiKey) required
|
// authentication (ApiKey) required
|
||||||
@ -1272,22 +1282,24 @@ namespace BreCalClient.misc.Api
|
|||||||
/// Gets a list of ship calls
|
/// Gets a list of ship calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <returns>Task of List<Shipcall></returns>
|
/// <returns>Task of List<Shipcall></returns>
|
||||||
public async System.Threading.Tasks.Task<List<Shipcall>> ShipcallsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
public async System.Threading.Tasks.Task<List<Shipcall>> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
BreCalClient.misc.Client.ApiResponse<List<Shipcall>> localVarResponse = await ShipcallsGetWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false);
|
BreCalClient.misc.Client.ApiResponse<List<Shipcall>> localVarResponse = await ShipcallsGetWithHttpInfoAsync(pastDays, operationIndex, cancellationToken).ConfigureAwait(false);
|
||||||
return localVarResponse.Data;
|
return localVarResponse.Data;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of ship calls
|
/// Gets a list of ship calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="BreCalClient.misc.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="pastDays">number of days in the past to include in the result. *Example: 7*. (optional)</param>
|
||||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <returns>Task of ApiResponse (List<Shipcall>)</returns>
|
/// <returns>Task of ApiResponse (List<Shipcall>)</returns>
|
||||||
public async System.Threading.Tasks.Task<BreCalClient.misc.Client.ApiResponse<List<Shipcall>>> ShipcallsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
public async System.Threading.Tasks.Task<BreCalClient.misc.Client.ApiResponse<List<Shipcall>>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions();
|
BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions();
|
||||||
string[] _contentTypes = new string[] {
|
string[] _contentTypes = new string[] {
|
||||||
@ -1306,6 +1318,10 @@ namespace BreCalClient.misc.Api
|
|||||||
{
|
{
|
||||||
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
||||||
}
|
}
|
||||||
|
if (pastDays != null)
|
||||||
|
{
|
||||||
|
localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "past_days", pastDays));
|
||||||
|
}
|
||||||
localVarRequestOptions.Operation = "DefaultApi.ShipcallsGet";
|
localVarRequestOptions.Operation = "DefaultApi.ShipcallsGet";
|
||||||
localVarRequestOptions.OperationIndex = operationIndex;
|
localVarRequestOptions.OperationIndex = operationIndex;
|
||||||
// authentication (ApiKey) required
|
// authentication (ApiKey) required
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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