With new v2 flight-offers endpoint includedAirlineCodes & exlcludedAirlineCodes cannot be used together? - amadeus

In the previous version, V1, Low-fare search, these two parameters could both be used. Is that no longer possible? These parameters:
{'adults': 1, 'children': 0, 'currencyCode': 'USD', 'departureDate': '2020-09-30', 'destinationLocationCode': 'FLL', 'excludedAirlineCodes': 'NK,B6', 'includedAirlineCodes': 'DL', 'infants': 0, 'nonStop': 'false', 'originLocationCode': 'MSP', 'returnDate': '2020-10-07', 'travelClass': 'ECONOMY'}
Generate this error:
{'errors': [{'status': 400, 'code': 2668, 'title': 'PARAMETER COMBINATION INVALID/RESTRICTED', 'detail': 'excludedAirlineCodes and includedAirlineCodes are not compatible'}]}

In the Flight Offers Search API (v2) we fixed something that was confusing for users: if you use includedAirlineCodes you only get the flights of the airline(s) specified (so it excludes all other airlines). Using includedAirlineCodes and excludedAirlineCodes at the same time is not possible.

Related

How can I convert SuiteQL query code into corresponding json format for REST API call

I have the following SuiteQL code generated using the NetSuite: Workbook Export chrome extension:
`
SELECT
BUILTIN_RESULT.TYPE_DATE(TRANSACTION.trandate) AS trandate,
BUILTIN_RESULT.TYPE_STRING(TRANSACTION.tranid) AS tranid,
BUILTIN_RESULT.TYPE_STRING(item.displayname) AS displayname,
BUILTIN_RESULT.TYPE_CURRENCY(BUILTIN.CONSOLIDATE(transactionLine.rate, 'LEDGER', 'DEFAULT', 'DEFAULT', 1, 100, 'DEFAULT'), BUILTIN.CURRENCY(BUILTIN.CONSOLIDATE(transactionLine.rate, 'LEDGER', 'DEFAULT', 'DEFAULT', 1, 100, 'DEFAULT'))) AS rate,
BUILTIN_RESULT.TYPE_FLOAT(transactionLine.quantity) AS quantity
FROM
TRANSACTION,
item,
transactionLine,
(SELECT
PreviousTransactionLink.nextdoc AS nextdoc,
PreviousTransactionLink.nextdoc AS nextdoc_join,
transaction_SUB.name_crit AS name_crit_0
FROM
PreviousTransactionLink,
(SELECT
transaction_0.ID AS ID,
transaction_0.ID AS id_join,
CUSTOMLIST234.name AS name_crit
FROM
TRANSACTION transaction_0,
CUSTOMLIST234
WHERE
transaction_0.custbody1 = CUSTOMLIST234.ID(+)
) transaction_SUB
WHERE
PreviousTransactionLink.previousdoc = transaction_SUB.ID(+)
) PreviousTransactionLink_SUB
WHERE
(((transactionLine.item = item.ID(+) AND TRANSACTION.ID = transactionLine.TRANSACTION) AND TRANSACTION.ID = PreviousTransactionLink_SUB.nextdoc(+)))
AND ((TRANSACTION.TYPE IN ('CustInvc') AND transactionLine.itemtype IN ('InvtPart', 'Kit') AND NVL(transactionLine.mainline, 'F') = ? AND (UPPER(PreviousTransactionLink_SUB.name_crit_0) NOT LIKE ? OR PreviousTransactionLink_SUB.name_crit_0 IS NULL) AND TRUNC(TRANSACTION.trandate) > TO_DATE(?, 'YYYY-MM-DD')))
`
When I try to paste it into Power Automate's API call, I get the following 400 error:
"Invalid search query. Detailed unprocessed description follows. Invalid number of parameters. Expected: 3. Provided: 0."
My call's query was formatted as follows:
`
{
"q": "SELECT BUILTIN_RESULT.TYPE_DATE(TRANSACTION.trandate) AS trandate, BUILTIN_RESULT.TYPE_STRING(TRANSACTION.tranid) AS tranid, BUILTIN_RESULT.TYPE_STRING(item.displayname) AS displayname, BUILTIN_RESULT.TYPE_CURRENCY(BUILTIN.CONSOLIDATE(transactionLine.rate, 'LEDGER', 'DEFAULT', 'DEFAULT', 1, 100, 'DEFAULT'), BUILTIN.CURRENCY(BUILTIN.CONSOLIDATE(transactionLine.rate, 'LEDGER', 'DEFAULT', 'DEFAULT', 1, 100, 'DEFAULT'))) AS rate, BUILTIN_RESULT.TYPE_FLOAT(transactionLine.quantity) AS quantity FROM TRANSACTION, item, transactionLine, (SELECT PreviousTransactionLink.nextdoc AS nextdoc, PreviousTransactionLink.nextdoc AS nextdoc_join, transaction_SUB.name_crit AS name_crit_0 FROM PreviousTransactionLink, (SELECT transaction_0.ID AS ID,transaction_0.ID AS id_join, CUSTOMLIST234.name AS name_crit FROM TRANSACTION transaction_0, CUSTOMLIST234 WHERE transaction_0.custbody1 = CUSTOMLIST234.ID(+) ) transaction_SUB WHERE PreviousTransactionLink.previousdoc = transaction_SUB.ID(+) ) PreviousTransactionLink_SUB WHERE (((transactionLine.item = item.ID(+) AND TRANSACTION.ID = transactionLine.TRANSACTION) AND TRANSACTION.ID = PreviousTransactionLink_SUB.nextdoc(+))) AND ((TRANSACTION.TYPE IN ('CustInvc') AND transactionLine.itemtype IN ('InvtPart', 'Kit') AND NVL(transactionLine.mainline, 'F') = ? AND (UPPER(PreviousTransactionLink_SUB.name_crit_0) NOT LIKE ? OR PreviousTransactionLink_SUB.name_crit_0 IS NULL) AND TRUNC(TRANSACTION.trandate) > TO_DATE(?, 'YYYY-MM-DD')))"
}
`
When I try using SuiteQL in my API calls using a simple query, my API calls work, so I'm pretty sure I'm screwing up the fomrat of the above's json format. I tried the following simple query call and it was succesfull:
`
{
"q": "SELECT email, COUNT(*) as count FROM transaction GROUP BY email"
}
`
I have tried using json beautifier to try to fix my json but I haven't been able to do so successfully.
Below is a pic of the HTTP action I'm using in power Automate to make the query:
HTTP POST Action
For context, I'm an accountant by trade trying to learn how to do some basic coding. Any hint that will help me correctly format the above query will be greatly appreciated. Thanks!
As per my comment, typically, question marks in an SQL statement are deemed as being parameters.
Code based frameworks use them as placeholders for filling the parameters to abstract them from the string itself.
Now, in PowerAutomate and with your question, I think it's just a little bit of seeing the forest for the trees.
The easiest way to populate the question marks is to literally replace them in the string itself with the relevant variable or expression.
So if I took an SQL statement with a parameter like you have ...
SELECT * FROM [dbo].[Test] WHERE Parameter = ?
... I can do the following (this is an EXTREMELY basic example) ...
Using the expressions, you can populate strings within other variables or steps in the flow.
Just be careful when it comes to encapsulating your different parameters with quotes, either single or double. The SQL statement will need them in the cases where values are numbers.

Database independent grouped count distinct "days ago" in Rails 6

I want to find out on how many different 24 hour intervals a word occurred (note that the actual application is different and more complicated, but this is equivalent and needs no context).
I could do that with an SQL query like this in Postgresql:
SELECT
word,
COUNT(DISTINCT FLOOR(EXTRACT(EPOCH FROM AGE(created_at)) / 86400)) AS num_distinct_days_with_occurrence
FROM word_occurrences
GROUP BY word
I even managed to write Rails code that generates this query:
WordOccurrence.select(:word).group(:word).distinct.count('FLOOR(EXTRACT(EPOCH FROM AGE(created_at)) / 86400)')
However, it doesn't work in Sqlite3 with the same code.
I guess if I put in some time, I could probably also find a way to make it work in Sqlite3, but I can't figure out how to get both to work. I saw the count API had more features in past rails versions, but I think even that wouldn't be enough given that my main problem is timestamp handling and not counting. Also, I couldn't figure out where these features went in Rails 6.
Is there a way to make this work for both adapters? And if not, what is the best way to handle such snippets of database dependent code and choose the right one?
Example data:
[
{ word: 'a', created_at: '2020-01-10 22:30' },
{ word: 'a', created_at: '2020-01-10 23:30' },
{ word: 'a', created_at: '2020-01-11 22:30' },
{ word: 'b', created_at: '2020-01-10 22:30' }
]
If I query this at 2020-04-08, I should get this result:
[
{ word: 'a', num_distinct_days_with_occurrence: 2 },
{ word: 'b', num_distinct_days_with_occurrence: 1 }
]

Select all Valid starting letters with Sequelize

I have a list of countries which will be separated by starting letter so for example when you click on 'A' it will make an API call to return all the countries beginning with 'A'.
However there are some letters that don't have any countries in our system, and these may change as we update out data.
I want to have a query that will let me know which letters do not have any countries that begin with them, so that I can disable them.
I can do this be running a findOne query for every single letter in the alphabet... but that is not neat or performant. Is there a way to get the data from a single query?
I am able to get the desired result by using a substring function within a distinct function.
const result = await Countries.findAll({
attributes: [
[
sequelize.fn(
'DISTINCT',
sequelize.fn('substring', sequelize.col('countryName'), 1, 1),
),
'letter',
],
],
group: [sequelize.fn('substring', sequelize.col('countryName'), 1, 1)],
raw: true,
})

SQL server query on json string for stats

I have this SQL Server database that holds contest participations. In the Participation table, I have various fields and a special one called ParticipationDetails. It's a varchar(MAX). This field is used to throw in all contest specific data in json format. Example rows:
Id,ParticipationDetails
1,"{'Phone evening': '6546546541', 'Store': 'StoreABC', 'Math': '2', 'Age': '01/01/1951'}"
2,"{'Phone evening': '6546546542', 'Store': 'StoreABC', 'Math': '2', 'Age': '01/01/1952'}"
3,"{'Phone evening': '6546546543', 'Store': 'StoreXYZ', 'Math': '2', 'Age': '01/01/1953'}"
4,"{'Phone evening': '6546546544', 'Store': 'StoreABC', 'Math': '3', 'Age': '01/01/1954'}"
I'm trying to get a a query runing, that will yield this result:
Store, Count
StoreABC, 3
StoreXYZ, 1
I used to run this query:
SELECT TOP (20) ParticipationDetails, COUNT(*) Count FROM Participation GROUP BY ParticipationDetails ORDER BY Count DESC
This works as long as I want unique ParticipationDetails. How can I change this to "sub-query" into my json strings. I've gotten to this query, but I'm kind of stuck here:
SELECT 'StoreABC' Store, Count(*) Count FROM Participation WHERE ParticipationDetails LIKE '%StoreABC%'
This query gets me the results I want for a specific store, but I want the store value to be "anything that was put in there".
Thanks for the help!
first of all, I suggest to avoid any json management with t-sql, since is not natively supported. If you have an application layer, let it to manage those kind of formatted data (i.e. .net framework and non MS frameworks have json serializers available).
However, you can convert your json strings using the function described in this link.
You can also write your own query which works with strings. Something like the following one:
SELECT
T.Store,
COUNT(*) AS [Count]
FROM
(
SELECT
STUFF(
STUFF(ParticipationDetails, 1, CHARINDEX('"Store"', ParticipationDetails) + 9, ''),
CHARINDEX('"Math"',
STUFF(ParticipationDetails, 1, CHARINDEX('"Store"', ParticipationDetails) + 9, '')) - 3, LEN(STUFF(ParticipationDetails, 1, CHARINDEX('"Store"', ParticipationDetails) + 9, '')), '')
AS Store
FROM
Participation
) AS T
GROUP BY
T.Store

django order by date in datetime / extract date from datetime

I have a model with a datetime field and I want to show the most viewed entries for the day today.
I thought I might try something like dt_published__date to extract the date from the datetime field but obviously it didn't work.
popular = Entry.objects.filter(type='A', is_public=True).order_by('-dt_published__date', '-views', '-dt_written', 'headline')[0:5]
How can I do this?
AFAIK the __date syntax is not supported yet by Django. There is a ticket open for this.
If your database has a function to extract date part then you can do this:
popular = Entry.objects.filter(**conditions).extra(select =
{'custom_dt': 'to_date(dt_published)'}).order_by('-custom_dt')
In the new Django, it should work out of the box [tested on 3.2] with Mysql 5.7
Dataset
[
{ "id": 82148, "paid_date": "2019-09-30 20:51:11"},
{ "id": 82315, "paid_date": "2019-09-30 00:00:00"},
]
Query
Payment.objects.filter(order_id=135342).order_by('paid_date__date', 'id').values_list('id', 'paid_date__date')
Results
`<QuerySet [(82148, datetime.date(2019, 9, 30)), (82315, datetime.date(2019, 9, 30))]>`