path: root/util
AgeCommit message (Collapse)AuthorFilesLines
2020-01-01ulist: Time to put this live2.27Yorhel1-0/+0
Decided to change the naming scheme of files in util/updates/
2019-12-30Minor refactor: Move all trigger functions and declarations to separate fileYorhel6-336/+351
This keeps the function body and the trigger declaration closer to each other, so it's easier to tell when the function will be called and which cases it needs to handle. If you ignore errors from existing trigger declarations, the triggers.sql script is idempotent and can be used in from scripts.
2019-12-30Merge branch 'ulist'Yorhel10-259/+227
2019-12-30Actually, let's get rid of v3 now that it doesn't work anymore anywayYorhel3-86/+4
2019-12-30ulist: Remove remnants of old votes/vnlists/wlists tablesYorhel4-45/+7
2019-12-27ulists: Update devdump.plYorhel2-19/+21
2019-12-24ulist: Export new lists in, unexport old listsYorhel2-39/+46
Ended up exporting the 'users.ign_votes' column as well, as that's both easier and (potentially) more useful than not exporting ignored votes in the first place.
2019-12-22ulist: Update "My lists" VN filters to use new ulists featureYorhel1-1/+1
This is just a simple backwards-compatible port, proper integration should allow one to filter on individual labels. The "On my VN list" filter now works slightly differently in that it considers *everything* in ulist_vns to be on the users' VN list, including votes and wishlist. I've removed the option to display a "Wishlist" column. The wishlist works rather differently now, maybe this should instead just display all assigned labels - but that would consume quite a bit of space. :(
2019-12-22ulist: Use new lists for VN vote stats & listingYorhel2-0/+4
To my surprise, I actually managed to achieve acceptable performance by just adding two indices. I totally expected I'd have to keep a cache column in ulist_vns whether the row is private or not. The partial index on the users table in fact improves the performance of the vote graph query. A covering index improves that even further, but that requires Postgres 11+, which the Docker image doesn't have yet (and isn't all that crucial anyway). There's a rather annoying potential for confusion regarding the private flag on votes. The user page & list stats only look at whether the 'Voted' label is private, whereas the VN stats use the "proper" approach of checking for any public label. Not entirely sure which of the two is more intuitive.
2019-12-20ulist: Remove deprecated hide_list user preferenceYorhel1-1/+1
Old VNDB::* code still uses that preference in a few places, that needs to be fixed.
2019-12-20Keep track of poll vote datesYorhel2-0/+3
That'd make it much easier to find fake accounts.
2019-12-19ulist: Update user list with vnlist/votes/wishlist statsYorhel5-24/+36
This adds the users.c_vns and c_wish columns and a function to update the cache. Unlike my previous cache update approaches, I did not use SQL triggers here, as that seemed more complex and less efficient than updating the cache manually. That's not to say that I'm happy with the current approach, but meh... The cache update function is not automatically run for all users, but that could be added to Multi::Maintenance if it turns out that the cached values will not be updated properly in some cases.
2019-12-17ulist: Synchronize changes between rlists and ulist_vnsYorhel3-32/+29
These ensure that, for each row in rlists, all the linked VNs have an entry in ulist_vns. This implementation should be more robust than before; It now isn't possible to remove an item from ulist_vns without also removing all relevant rows from rlists, and adding more VNs to an existing release entry will ensure that those VNs are also added to ulist_vns.
2019-12-16ulist: Convert vn.c_* vote stat updating to use ulist_vns tableYorhel2-13/+31
It turned out that naively changing the existing queries to refer to ulist_vns with a (WHERE vote IS NOT NULL) made them ultra slow (like, DNF-slow), for a reason I haven't been able to figure out yet. I had to rewrite the queries to use CTEs and in doing so figured that I could get an extra performance improvement by combining the popularity and rating updates in one query. The combined update function now runs faster than the old queries.
2019-12-16ulist: Integrate update script into SQL + update notify_listdel()Yorhel5-35/+83 Do an explicit rollback before disconnecting the DBYorhel1-0/+1
Fixes a (harmless) warning: Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=vndb at util/ line 247. Ensure consistent exportsYorhel1-1/+2
Today's export had a little inconsistency caused by a database update while the export script was running.
2019-12-03API: Add "get ulist-labels" and "get ulist"Yorhel1-0/+4
To directly query the new list feature. I'll migrate the old vnlist/wishlist/votelist APIs later to query the 'ulist' tables.
2019-12-01v2rw: Convert thread display + poll votingYorhel1-2/+2
I did not reimplement the 'poll_recast' and 'poll_preview' settings, these actions are now always permitted. Updated CSS a little bit to highlight the linked post and fix the double border at the bottom. The nice thing about the sql_visible_threads() function I wrote earlier is that is can also be used for access control on a single thread. More code re-use. \o/
2019-11-10ulist: Fix migration script to properly delete tables & handle concurrent ↵Yorhel1-2/+7
2019-11-10ulist: SQL: Create labels for new users + auto-assign Voted label + import ↵Yorhel1-5/+57
rlisted VNs
2019-11-10ulist: Rename tables to something more sensibleYorhel1-16/+16
2019-11-10ulist: Use lower numbers for custom labels + add VN listingYorhel1-54/+17
2019-11-10ulist: Add data model for new lists + Perl/Elm for label managementYorhel2-0/+135
Very much experimental. I'm not sure this is even the right model.
2019-11-08Wikidata: Add support for author linksYorhel2-1/+3
2019-11-02Add character age field + conversionYorhel2-8/+31
2019-11-02Add character cup size field + conversion + filterYorhel3-2/+57
2019-10-17Fix the devdumpYorhel1-2/+2
2019-10-13Sort languages by name rather than tagYorhel1-1/+1
2019-10-10rewards: Add user settingsYorhel3-5/+23
They don't do anything yet.
2019-10-07SQL: Improve performance of update_vnpopularity()Yorhel1-15/+12
Goes from 1.5 minutes to 1.5 seconds. Temporary views instead of CTEs and self-joins instead of window functions. That code was *old*.
2019-10-07SQL: Perform incremental updates on traits_chars when characters are editedYorhel2-9/+22
Same thing as 65ed955890c7ee7250a2bce4467c8c092c1bbbbe, with the same limitations (except this does take hiding/unhiding characters into account).
2019-10-07SQL: Perform incremental updates on tags_vn_inherit when tags are modifiedYorhel2-10/+22
This has some limitations: - tags.c_items is not updated, so that may be out of sync. (The UPDATE takes about 400ms, so doing that more regularly from Multi::Maintenance should be a viable option) - When the hidden flag of a VN is changed, the tags will also be out of sync. - I don't see a way to do fast incremental updates when tag entries themselves are changed, e.g. to handle changes in the tag tree or searchable flag
2019-10-07SQL: Adjust tag_vn_inherit and trait_chars calculationsYorhel5-53/+51
Most importantly, downvoted parent tags are now still included for searching as per - in particular, a downvoted tag is considered to be exactly the same thing as a tag with no votes at all. Also made a few other adjustments: - Removed the "ignore child tags/traits if parent has its own value" rule. This was done because the 'spoiler' rating would get inherited using the average, but that should just have been the minimum (i.e. if a single child tag is not a spoiler, then neither is the parent). - The score of a parent tag is now avg(avg(votes_on_child_tags)) rather than avg(votes_on_child_tags), i.e. tags with more votes don't have more weight than tags with fewer votes. I don't think vote counts really matter in determining the parent score. - Deleted VNs now don't count towards tag statistics (this is consistent with traits). - Performance improvements: Smaller indices and more clever querying.
2019-10-03Disallow changing email address to one already used by another accountYorhel2-2/+3
2019-10-03Require email confirmation when changing email addressYorhel3-8/+29
This ensures that the email address linked to a user is always valid and actually belong(s|ed) to that user.
2019-10-03SQL: Add session types + use sessions for password reset tokensYorhel3-22/+41
This improves the password reset workflow a bit. The users.passwd field is now no longer used for reset tokens, meaning that the current password isn't affected until the user actually clicks the link and changes it. It is now also possible to have multiple active password reset tokens, in case one of the emails got lost. All existing tokens are invalidated when the user finally changes their password. Tokens are now valid for at most 1 week instead of indefinitely.
2019-10-03SQL: Change sessions.lastused into sessions.expiresYorhel4-13/+18
This will be helpful when adding other types of sessions with different expiration.
2019-10-03Fix spoilers preference to be a smallint rather than booleanYorhel2-3/+3
And for those who (like me) already applied update_20191003.sql, here's a partial fix: alter table users alter column spoilers drop default; alter table users alter column spoilers type smallint using (case when spoilers then 1 else 0 end); alter table users alter column spoilers set default 0; But you'll still need to import the old preference for users who had spoilers=2, because those will have been lost.
2019-10-03SQL: Get rid of the users_prefs table, store preferences in users tableYorhel7-43/+84
This bloats the users table a little bit, but that's fine. The main advantage of this change is that we now have a proper schema for user preferences, rather than the schemaless key-value mess we had before. This commit also splits the 'tags_cat' preference up into tags_cont, tags_ero and tags_tech bools, as that's more compact to store and easier to work with. This commit also changes the 'notify_nodbedit' preference to 'notify_dbedit' with inverted meaning. The reason the value was negated in the first place was because the old schemaless approach did not support positive defaults.
2019-09-27Add Malay languageYorhel2-1/+2
Sorry for re-using update_20190923.sql, but I'm not sure anyone even uses those scripts. For documentation purposes it's neat to have similar things in a short time window combined, anyway.
2019-09-26Disallow usernames that look like DB identifiers + minor BBCode fixYorhel1-3/+3
A '-' before or after a DB identifier now counts as a "word character", meaning in "d5-something" won't turn that "d5" into a link.
2019-09-25v2rw: Add Elm & db_edit framework + Convert doc page editingYorhel1-2/+36
Most of this is copied from v3. I did improve on a few aspects: - db_edit() and db_entry() use VNDB::Schema rather than dynamically querying the DB. This has the minor advantage of a faster startup. - The Elm code generator now writes to multiple files, this avoids the namespace pollution seen in v3's Lib.Gen and makes the dependency graph a bit more lean (i.e. faster incremental builds). - The Elm code generator doesn't update the timestamp of files that haven't been modified. This also speeds up incremental builds, the elm compiler can now skip rebuilding unmodified files. - The Elm API response generator code now uses plain functions rather than code references and all possible responses are now defined in Turns out most API responses were used from more than a single place, so it makes sense to have them centrally defined. The doc page preview function is also much nicer; I'd like to apply this to all BBCode textareas as well. ( itself is ugly as hell though. And we will prolly need some HTML form generation functions in Elm to make that part less verbose)
2019-09-24Add language: Scottish GaelicYorhel2-1/+2
2019-09-23Add 4 new languagesYorhel2-1/+5
2019-09-18v2rw: Convert authentication code to VNWeb::AuthYorhel1-53/+33
More churn! Also converted v3 to use VNWeb::Auth, considering the API is pretty much the same. Converted VNWeb::* to use VNDB::Config directly rather than read from tuwf->{}, converted VNWeb::HTML to use VNWeb::Auth, and updated util/ with the new code style. I tested as much as I could, but I'm sure I broke something.
2019-09-17v2rw: Initial start on an incremental rewrite; Layout HTML firstYorhel1-1/+1
I copied and modified VN3::DB to VNWeb::DB, but it isn't used yet. Now that I think about it, that module isn't "web" specific at all and should perhaps be in the VNDB:: namespace. Oh well.
2019-09-17Rename VNDBSchema to VNDB::Schema and let it figure out the root path itselfYorhel3-7/+7
I always avoided using the VNDB::* schema for non-web related utility modules, but thats pretty silly (especially as I'm slowly trying to move away from the old VNDB::* web code).
2019-09-17Don't send db edit notifications for changes made by MultiYorhel1-0/+1
2019-09-14SQL: Replace "shop_*.found" with "deadsince" timestampYorhel2-4/+23
Has the inverted meaning. Keeping track of how long we've been unable to find a certain shop link is useful in weeding out temporary unavailability when querying for dead links.