Commit graph

47 commits

Author SHA1 Message Date
c4935ac70d Move rest stuff into nap subdir.
Nap is a quick REST. Silly joke really, but hey, 3 letters.
Great namespace name.
2020-08-29 12:34:55 +01:00
05c03c2daf Working on a replacement for restc-cpp 2020-08-29 01:54:52 +01:00
be1a19f7c7 Move backend name to config file
Still, only one backend is available at this point.
2020-08-22 02:30:00 +01:00
c5e0b01b06 Add OriginsDB base class and a make() function
This fixes the build. The make function for the moment
just takes a string since that's all that's ever needed.
This is supposed to change since the postgresql database
will need a port, an url, password etc. Maybe
connection strings are still a thing, but if not then
I'll probably need to find a way to accept arbitrary
parameters in OriginsDB::make().
2020-08-22 01:57:14 +01:00
217c844893 Move OriginsDB sqlite files
This breaks the build
2020-08-22 01:53:04 +01:00
2a407294e1 Add an option to enable/disable sqlite backend
Currently you can't disable it since sqlite is the only
supported backend and you must have at least one enabled
and available on the system. This will be needed for later.
2020-08-22 01:30:04 +01:00
a1aeb3c587 Server is returning some shops selling unknown items, add support for it
Previously the code would just throw an exception and
quit (foreign key constraint violation). Add an empty
row with the missing id so it will work. When the item
list returns that item the next time, the empty row will
be filled.
2020-08-16 22:29:46 +01:00
d5ee1cd11b Add some debug printing 2020-08-16 16:29:43 +01:00
1fcd7bd749 Append the version number to the name reported to the server 2020-08-16 15:42:45 +01:00
b06456e4b0 Restore timeouts from previous run
This is quite a big update, the new feature is that when the
program starts it loads the next update time from the db if
present. If so it resumes the timers from there. Maximum wait
time is currently capped at 24h.

TimerOroApi is not templated on methods anymore, rather on
the new DBOperation enum. This is so that it has that enum
value to pass it to other functions. This could've been a
separate commit, but wth...

Magic enum allows me to iterate over an enum's values at
build time, it's useful for building the query in OriginsDB
for the SELECT in the access table
(see make_select_last_access_str()).
2020-08-16 06:28:58 +01:00
0faa8fb18f Keep the db connection open throughout the lifetime of OriginsDB 2020-08-15 23:32:22 +01:00
1b65162a18 Update last_seen in shop snapshot table 2020-08-15 02:49:03 +01:00
ce892691f3 Use the new bind_all() everywhere 2020-08-15 02:34:51 +01:00
5df60661d3 Improve sqlite helpers a bit 2020-08-15 02:29:43 +01:00
928cabfe34 Making progress with shop snapshots 2020-08-15 01:55:46 +01:00
afb4fd2d4d Replace boost::optional with std::optional 2020-08-15 01:45:35 +01:00
29f11d3f57 Extract strings from functions because they are too verbose and drive me crazy 2020-08-14 22:27:01 +01:00
d4fd25b151 Add shop snapshots table
It contains the snapshot of each shop and a unique hash.
This is not complete yet, running this update twice will
just corrupt the table.
2020-08-14 19:48:14 +01:00
3262ce8d25 Fix wrong hash string sometimes 2020-08-14 19:46:09 +01:00
7e48ee94c2 Organise files into a private subdir.
Move files that are not supposed to be used directly to
get oro functionalities into a private subdirectory.
2020-08-14 18:58:47 +01:00
33fe2bc8cd Add tiger. It depends on duckhandy, so add that too. 2020-08-14 00:46:36 +01:00
80ef2afbee Same treatment as items table, don't drop/re-create
This works in a much simpler way than the items table.
Here we just upsert new values, with the unique constraint
on the internal item_id (not the upstream one, which is
never entered into this table).
This should mean that if an item from the items table with
eg: item_id=501,id=9 gets marked as deleted and re-entered as
item_id=501,id=5000, then icon with item_id=9 should remain
in the table (there is no delete ever), and a new one with
item_id=5000 gets added. Originally they both referred to
item 501 and they still do, but because of how the items
table now works, icons should also benefit and historical
data should remain in the face of upstream changes.
2020-08-12 01:33:13 +01:00
1b5e1f4365 Improve sql for items table
Now if item_id or unique_name change, that counts as a record
being deleted and a new one inserted.
If neither of that changed but any other field did, the old
field gets updated with the new value.
2020-08-12 01:07:34 +01:00
ef39dee43e Fix issue with items table; enable foreign key constraints
Program receives the full items list periodically. I don't think
they will ever remove records from there, but if they do the
program should not corruct the db. So far the simple approach
drop table items/create table items ensured the items list is
always fresh, but it prevented foreign key constraints on shop
items. Also, if an item was removed from items, any entry in
shop would become orphaned or worse point to the wrong item if
they recycled the id. Solution is to not use item_id at all for
the relationship between shop items and items table, instead
have my own internal id that is valid forever. Now records
removed upstream get just marked as deleted (by adding a removal
timestamp). The same item_id can be reused since the unique part
now must be (item_id, removal_date), in other words there is only
one non-deleted item_id, but there can be several deleted ones.

Code stores the full items set into items_staging, marks records
in items but not in items_staging as deleted, then adds any
missing records to items from items_staging, then drops items_staging.
2020-08-12 00:07:22 +01:00
cb500fd67c Add TimerCreators 2020-08-11 02:10:43 +01:00
bc0de0cf8b Populate slotted_cards table
It contains the list of cards inserted into the
slots of the items in the shop_items table

I can't enable the foreign key on card_id because
the items table gets razed periodically - need
to find a solution to this
2020-08-10 23:40:05 +01:00
b76a2f22a4 Populate shop_items table 2020-08-10 23:17:17 +01:00
bf055b5b87 Rename property 2020-08-10 23:15:25 +01:00
a930622569 Add more timestamp conversion functions to dateconv.hpp 2020-08-10 22:17:42 +01:00
616ac36a34 Populate the shops table 2020-08-10 21:52:56 +01:00
417030f4fe Parse the YYYY-MM-DDTHH:MM:SSZ dates correctly
Dates in the json reply seem to come in two different formats.
One is the reply timestamp, second one is the actual
content (for example shop opening dates)
2020-08-10 21:52:56 +01:00
c1e21bb8d6 Add TimerShops 2020-08-10 21:52:56 +01:00
9f4a5baebb Store icons into their own separate table 2020-08-10 21:52:56 +01:00
35118dbe4e Get db path from settings file instead of using a hardcoded value 2020-08-10 13:21:04 +01:00
2717817958 Attach GPL3+ licence 2020-08-10 11:22:25 +01:00
ab8f8b1533 I don't think I need transactions for those 2020-08-10 10:18:15 +01:00
53ba7febf4 This stuff doesn't need to be in oro 2020-08-10 02:47:55 +01:00
eeab1d5c5e Add base64 decoding function 2020-08-10 02:35:27 +01:00
6b9502ea3e Store items and icons into the db 2020-08-10 02:34:09 +01:00
b4c9b013a0 Add fame_list() to Api.
With this commit the whole remote API is currently covered.
2020-06-23 10:29:59 +02:00
5b480f3ae5 Add market_list() to Api. 2020-06-23 10:19:02 +02:00
fd5c29ca54 Add items_icons() to Api. 2020-06-22 22:29:14 +02:00
fd147c4f2a Add items_list() to Api. 2020-06-22 20:53:56 +02:00
939bcffc61 Add who_am_i() method to Api. 2020-06-22 19:40:37 +02:00
b1376f7379 Default initalise values 2020-06-20 02:02:43 +02:00
bab47fbd0b Parse the date from the responce header 2020-06-20 02:01:52 +02:00
96e35a5814 Giving code some initial structure 2020-06-20 01:27:47 +02:00