Updating local cache #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently, whenever all
ContestNoderefs are present in the cache,wbijwill refuse to download any data from the server. How to identify that some nodes had been added to the remote server?In contrast to submissions, most platforms does not provide any API calls to fetch "newly created contests/rounds/problems". So the question is rather: how can the user indicate the will to refresh some subtree?
I have the following idea. We can have a
wbij neworwbij updatesubcommand that will just try to sensibly update all data and will report to stdout all the new stuff that it downloaded. For example, we can display a list of ten recent submissions (with new ones being highlighted) and a tree of new contestnodes (tree can be formatted the same way as std.progress?).Every
wbij newcall, we will refetch all contestnodes and fetch all new submissions (thankfully, it will require very few api calls, see #14), sowbij newwon't be even interactive -> user won't have to select what nodes to fetch!But do we really need to refetch all contestnodes every time? I don't think so. We can be wise about it.
First of all, the majority of contests does not change at all once they are settled. We can mark most of them as "archived" and update only these contests that exhibit some kind of activity. Then, we can implement
wbij newsimply by refetching only non-archived contests. Just in case, we can provide awbij new -aflag that refetches also archived contests.But how to indicate that contest is archived?
Strategy 1: last submission date
We can consider archived every contest that hasn't received any submission in the past 6 months. This strategy is almost perfect, apart from the fact that:
wbij newwe would have to fetch new submissions first, then refetch nodes, then probably once again fetch new submissions (cause we can potentially obtain new submission feeds); so we need to write iterations logic (although that's not a huge problem)Strategy 2: ContestNode stores last_modified attribute
Each ContestNode stores an additional date that is updated every time: given node is refetched, we submit to given node, we receive some submission connected to given node. If some node is modified, all its ancestor should be considered modified. So last_modified attribute will be basically a maximum over children.
It's also good, but:
contest_nodesrelation and this attribute will likely have a lot of redundancy (due to the fact that last_modified is at least max of children)Strategy 3: we store last_time_selected attribute for each node
Like strategy 2, but the date is just updated every time
wbijselects a contest ref in subtree (whether it's using fzf or modeline or.wbij.zon, see #3) and additionally set to at least the date of the last submission in the subtree.In practice, we can implement this fully on the front-end site and simply store a relation with all the selects that we've made in the past
(timestamp, contest_ref, lang), where timestamp can serve a role of a primary key. Maybe we could use this information inwbij statsto display, e.g. the number of solutions submitted withwbij. Potentially, it could serve us as a bonus indicator when we will be implementing our own fuzzy search engine.It should be noted that we can as well use the submission info to provide both the stats and bonuses in fuzzy search engine. Using a cache-local history of selects will have this disadvantage that it's disconnected (unrelated) with the information found on the web platform and it also does not synchronize across devices.
@kbity do you have some ideas for other strategies? Which one do you is the best?
I think we can choose this design:
Every contest node will have a
last_modifieddate attribute which indicates when the node was fetched and was found to be actually different from what we had already got in the cache.Now, we will provide two flags for the user:
--drop-cachewhich ignores all loaded relations and-u,--update [Xm,Xd,all]which runs our update routine with given parameter X (set to 3 months by default?).The update routine will do the following:
last_modified >= today - X months)Options
--drop-cacheand-u,--updatewill be global options andwbijcommands will not perform update by default. We can introduce laterwbij new [Xm,Xd]command that display all contest nodes that were modified in some last period of time. In the future, we will havewbijthat simply displays some kind of dashboard with new nodes and nodes with close deadlines. @kbity sounds good?So, if I understand correctly, by tweaking X we change the threshold for considering a node to be archived? If so, then it sounds pretty reasonable 👍
I mean, I would depart from this idea of marking contests as "archived". Instead, it would work this way that although wbij usually uses cached data, you can add
--update Xmflag and wbij will download new data (but only for contests that changed in any way in last X months)I already introduced the
last_modifiedattribute, cause I'm pretty sure about this onemaleszka/wbij@8c2377139f.I wanted to introduce this change early enough that we will actually get some reasonable data to work with by the time we get here.
--updateflag and show new contest nodes #19Implemented in #19