Skip to content

Commit 0a8c845

Browse files
committed
- Updated README.md
- Added a reference SQL
1 parent 6b98661 commit 0a8c845

File tree

2 files changed

+47
-61
lines changed

2 files changed

+47
-61
lines changed

README.md

+13-61
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,30 @@ Lorekeeper is a framework for managing deviantART-based ARPGs/closed species mas
44

55
Demo site: [http://lorekeeper.me/](http://lorekeeper.me/)
66
Wiki for users: [http://lorekeeper-arpg.wikidot.com/](http://lorekeeper-arpg.wikidot.com/)
7+
Original git repository: [https://github.com/corowne/lorekeeper](https://github.com/corowne/lorekeeper)
78

8-
# Features
9+
# Info
910

10-
- Users can create an account which will hold their characters and earnings from participating in the game.
11-
- Mods can add characters to the masterlist, which can also record updates to a character's design. (Yes, multiple mods can work on the masterlist at the same time.)
12-
- Characters get a little bio section on their profile that their owners can edit. Personalisation!
13-
- Users' ownership histories (including whether they are an FTO) and characters' previous owners are tracked.
14-
- Users can submit art to the submission queue, which mods can approve/reject. This dispenses rewards automagically.
15-
- Users can spend their hard-earned rewards immediately, without requiring mods to look over their trackers (because it's all been pre-approved).
16-
- Characters, items and currency can be transferred between users. Plus...secure trading between users for game items/currency/characters on-site is also a thing.
17-
- Logs for all transfers are kept, so it's easy to check where everything went.
18-
- The masterlist is king, so ownership can't be ambiguous, and the current design of a character is always easily accessible.
19-
- Speaking of which, you can search for characters based on traits, rarity, etc. Also, trait/item/etc. data get their own searchable lists - no need to create additional pages detailing restrictions on how a trait should be drawn/described.
20-
- Unless you want to, in which case you can add custom pages in HTML without touching the codebase!
21-
- A raffle roller for consecutive raffles! Mods can add/remove tickets and users who have already won something will be automatically removed from future raffles in the sequence.
22-
- ...and more! Please refer to the [Wiki](http://lorekeeper-arpg.wikidot.com/) for more information and instructions for usage.
11+
This fork was set up for the purpose of sharing some of the changes I made. These changes are usually merged to master, but can also be found in their own branches.
2312

24-
# Setup
13+
## inventory_stacks
2514

26-
Important: For those who are not familiar with web dev, please refer to the [Wiki](http://lorekeeper-arpg.wikidot.com/) for a much more detailed set of instructions!!
15+
This changes the default inventory in Lorekeeper from displaying each user_item row as a stack of 1, and instead condenses duplicate entries into stacks. This has affected Inventory, Trades, and Design Updates the most, though there could still be remnants of code that still aren't using the new system.
2716

28-
## Obtain a copy of the code
17+
Once the changes are pulled, the database needs to be updated as well - this can be done with:
2918

3019
```
31-
$ git clone https://github.com/corowne/lorekeeper.git
32-
```
33-
34-
## Configure .env in the directory
35-
36-
```
37-
$ cp .env.example .env
38-
```
39-
40-
deviantART client ID and secret are required for this step.
41-
While obtaining the ID and secret, also add whitelist entries for redirection for your site URL (if being hosted) or localhost (if working locally).
42-
Add the following to .env, filling them in as required (also fill in the rest of .env where relevant):
43-
```
44-
CONTACT_ADDRESS=(contact email address)
45-
DEVIANTART_ACCOUNT=(username of ARPG group account)
46-
47-
DEVIANTART_CLIENT_ID=(client ID as supplied by deviantART)
48-
DEVIANTART_CLIENT_SECRET=(client secret as supplied by deviantART)
49-
DEVIANTART_CALLBACK_URL=/
50-
```
51-
52-
## Setting up
53-
54-
Composer install:
55-
```
56-
$ composer install
57-
```
58-
59-
Generate app key and run database migrations:
60-
```
61-
$ php artisan key:generate
6220
$ php artisan migrate
6321
```
6422

65-
Add basic site data:
66-
```
67-
$ php artisan add-site-settings
68-
$ php artisan add-text-pages
69-
$ php artisan copy-default-images
70-
```
23+
The migrations will add 2 new columns to user_items: trade_count and update_count, for tracking items held in trades and updates respectively. It will also change the default value of count in user_items to 0.
7124

72-
Finally, set up the admin account for logging in:
73-
```
74-
$ php artisan setup-admin-user
75-
```
25+
Note that existing data in the database will need to be edited such that duplicate entries (where the item_id, user_id, and data are the same) need to be combined separately.
26+
27+
You could just update each row's count column to reflect the total count at that point in time, leaving the duplicate entries alone. I'm unsure if it will break anything, but I don't think so.
7628

77-
You will need to send yourself the verification email and then link your dA account as prompted.
29+
You can also delete the duplicate rows once the count column is updated. However, this will probably require deleting the item logs associated with the affected stacks, unless you create your own workaround.
7830

79-
## Contact
31+
I have included some SQL that you can reference in creating a query, but it is unlikely to work out of the box. Alternatively, you can also edit the database manually. Either way, ALWAYS backup your database before making changes.
8032

81-
If you have any questions, please feel free to contact me through email: [email protected]
33+
The migrations do not remove holding_type and holding_id, which are not used in this version of the inventory; these may be left in or removed on your own.

sql/sum_duplicates.sql

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- PLEASE NOTE THAT THIS SQL IS NOT TESTED AND IS BETTER USED AS A REFERENCE
2+
3+
-- Create a temp table that duplicates the user_items table
4+
CREATE TABLE `db_name`.`temp` SELECT `*` FROM `db_name`.`user_items`;
5+
6+
-- Update the count column of all user_items rows
7+
-- This does not remove duplicates, but each duplicate should now reflect the total count before this statement was executed
8+
UPDATE `db_name`.`user_items` AS t
9+
SET t.`count` = (SELECT SUM(t1.`count`) FROM `db_name`.`temp` t1 WHERE t1.`item_id` = t.`item_id` AND t1.`user_id` = t.`user_id` AND t1.`data` = t.`data`);
10+
11+
-- Drop and re-add the foreign key temporarily, implementing ON DELETE CASCADE to remove item logs related to the removed rows
12+
ALTER TABLE `db_name`.`user_items_log`
13+
DROP FOREIGN KEY `user_items_log_stack_id_foreign`;
14+
15+
ALTER TABLE `db_name`.`user_items_log`
16+
ADD CONSTRAINT `user_items_log_stack_id_foreign`
17+
FOREIGN KEY (`stack_id`) REFERENCES `db_name`.`user_items` (`id`) ON DELETE CASCADE;
18+
19+
-- Delete all duplicate rows
20+
DELETE FROM `db_name`.`user_items` WHERE `db_name`.`user_items`.`id` not in
21+
(SELECT * FROM
22+
(SELECT min(`db_name`.`user_items`.`id`) FROM `db_name`.`user_items` GROUP BY `db_name`.`user_items`.`item_id`, `db_name`.`user_items`.`user_id`, `db_name`.`user_items`.`data`) as temp_tab
23+
);
24+
25+
-- Change the foreign key back
26+
ALTER TABLE `db_name`.`user_items_log`
27+
DROP FOREIGN KEY `user_items_log_stack_id_foreign`;
28+
29+
ALTER TABLE `db_name`.`user_items_log`
30+
ADD CONSTRAINT `user_items_log_stack_id_foreign`
31+
FOREIGN KEY (`stack_id`) REFERENCES `db_name`.`user_items` (`id`);
32+
33+
-- Drop the temp table
34+
DROP TABLE `db_name`.`temp`;

0 commit comments

Comments
 (0)