LSS-Manager / LSSM-V.4

The Official Repository for LSS Manager V4
https://lss-manager.de
Other
54 stars 91 forks source link

[Concept] API Query Language LSSMAQL #51

Open jxn-30 opened 3 years ago

jxn-30 commented 3 years ago

A Query Language to get API-Results from cached API Values.

Note: This is not yet a full concept and may change at any time

An LSSMAQL-Query Always returns an List of return Values.

Query should be able to process:

EBNF of a Query: We used EBNF used in Railroad Diagram Generator This may still contain errors

query ::= object getter* filter?
object ::= (identifier ("(" query ")")?) | query | identifier
getter ::= object_getter | list_getter
object_getter ::= "."+ identifier
list_getter ::= "[" number "]"

filter ::= where condition
condition ::= (condition (and | or) condition) | "(" condition ")" | object | comparison
comparison ::= (element ("=" | "!=" | "<" | ">") element) |( element "<" object "<" element)
element ::= object | number | string | object_getter

identifier ::= ("_" | lowercase_letter)+
lowercase_letter ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"

number ::= ((digit - "0") digit+) | "0"
digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

where ::= "WHERE "
and ::= "AND "
or ::= "OR "

Examples can be found in lssmaql@LSSM-V.4/lssmaql/specs/examples.md

jxn-30 commented 3 years ago

Version V.0.0.1 merged into master with #53

RagingLightning commented 2 years ago

I've been looking into the examples given and found one thing that is a bit weird:

sum of personal in all buildings that have more than 3 vehicles sum((buildings WHERE len(vehicles WHERE .building_id = ..id) > 3).personal_count)

in this example, personal_count strikes me as odd. I know that much of the LSSM is german (since the game is german), but as this is a query language, where everything is in english, I do believe that using the english personnel_count would be better suited. Especially since personal refers to something completely different in english

JRH-1997 commented 2 years ago

I've been looking into the examples given and found one thing that is a bit weird:

sum of personal in all buildings that have more than 3 vehicles sum((buildings WHERE len(vehicles WHERE .building_id = ..id) > 3).personal_count)

in this example, personal_count strikes me as odd. I know that much of the LSSM is german (since the game is german), but as this is a query language, where everything is in english, I do believe that using the english personnel_count would be better suited. Especially since personal refers to something completely different in english

Thats just a name used in the API of the game. And LSSMAQL is just something to use the APi of the game. So they need to use the exact names of that.

jxn-30 commented 2 years ago

The attributes are the same as used in the APIs: https://www.missionchief.com/api/buildings https://www.missionchief.com/api/vehicles https://www.missionchief.com/api/allianceinfo https://www.missionchief.com/api/credits https://www.missionchief.com/einsaetze.json

This is because Sebastian, the original founder of the game, used some "denglish" (mixing german and english) terms internally and the new developer team also does this now and then.

As the idea of LSSMAQL was/is to provide a Language to query these APIs, the exact same attribute names are required. There are also plans to provide a GUI for LSSMAQL but unfortunately the project is on hold currently.

kdev commented 4 months ago

I just found something that would be an interesting change to this idea. There is a query language for JSON that is perfect for our usecase and should be easy to implement. I understand that it's not "made" by us but would provide a feature till we do.

Cr4zyc4k3 commented 4 months ago

Possible alternatives:

Cr4zyc4k3 commented 4 months ago

after fiddling around with JSONata and GROQ in tend to favorite JSONata since a more complete feature set. Eg. string/number conversion is not possible with groq.