save biology assets on model
and start in comments on pet states :)
This commit is contained in:
parent
ff3fc943d7
commit
5332c9e265
4 changed files with 186 additions and 10 deletions
|
@ -133,4 +133,4 @@ UNLOCK TABLES;
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2020-09-19 3:12:59
|
-- Dump completed on 2020-09-19 3:34:44
|
||||||
|
|
|
@ -88,6 +88,28 @@ CREATE TABLE `pet_types` (
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=4795 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=4795 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `pet_states`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `pet_states`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
|
CREATE TABLE `pet_states` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`pet_type_id` mediumint(9) NOT NULL,
|
||||||
|
`swf_asset_ids` text COLLATE utf8_unicode_ci NOT NULL,
|
||||||
|
`female` tinyint(1) DEFAULT NULL,
|
||||||
|
`mood_id` int(11) DEFAULT NULL,
|
||||||
|
`unconverted` tinyint(1) DEFAULT NULL,
|
||||||
|
`labeled` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`glitched` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`artist_neopets_username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `pet_states_pet_type_id` (`pet_type_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=28561 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `swf_assets`
|
-- Table structure for table `swf_assets`
|
||||||
--
|
--
|
||||||
|
@ -126,4 +148,4 @@ CREATE TABLE `swf_assets` (
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2020-09-19 3:12:53
|
-- Dump completed on 2020-09-19 3:34:36
|
||||||
|
|
|
@ -191,7 +191,7 @@ Array [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"SELECT * FROM swf_assets WHERE (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?)",
|
"SELECT * FROM swf_assets WHERE (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?)",
|
||||||
Array [
|
Array [
|
||||||
"object",
|
"object",
|
||||||
"6829",
|
"6829",
|
||||||
|
@ -209,6 +209,18 @@ Array [
|
||||||
"51959",
|
"51959",
|
||||||
"object",
|
"object",
|
||||||
"56478",
|
"56478",
|
||||||
|
"biology",
|
||||||
|
"7942",
|
||||||
|
"biology",
|
||||||
|
"7941",
|
||||||
|
"biology",
|
||||||
|
"24008",
|
||||||
|
"biology",
|
||||||
|
"21060",
|
||||||
|
"biology",
|
||||||
|
"21057",
|
||||||
|
"biology",
|
||||||
|
"7946",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
|
@ -367,7 +379,7 @@ Array [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"INSERT INTO swf_assets (body_id, created_at, remote_id, type, url, zone_id, zones_restrict) VALUES (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?);",
|
"INSERT INTO swf_assets (body_id, created_at, remote_id, type, url, zone_id, zones_restrict) VALUES (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?);",
|
||||||
Array [
|
Array [
|
||||||
180,
|
180,
|
||||||
2020-01-01T00:00:00.000Z,
|
2020-01-01T00:00:00.000Z,
|
||||||
|
@ -425,6 +437,48 @@ Array [
|
||||||
"http://images.neopets.com/cp/items/swf/000/000/056/56478_eabc28e7c7.swf",
|
"http://images.neopets.com/cp/items/swf/000/000/056/56478_eabc28e7c7.swf",
|
||||||
27,
|
27,
|
||||||
"",
|
"",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"7942",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/007/7942_2eab06fd7b.swf",
|
||||||
|
5,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"7941",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/007/7941_2c4cc4b846.swf",
|
||||||
|
15,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"24008",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/024/24008_a05fe9876a.swf",
|
||||||
|
30,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"21060",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/021/21060_d77ba93b7b.swf",
|
||||||
|
33,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"21057",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/021/21057_4550efbb2f.swf",
|
||||||
|
34,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"7946",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/007/7946_0348dad587.swf",
|
||||||
|
37,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
@ -545,6 +599,15 @@ Array [
|
||||||
"48313",
|
"48313",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
Array [
|
||||||
|
"SELECT * FROM pet_states
|
||||||
|
WHERE pet_type_id IN (?)
|
||||||
|
ORDER BY (mood_id IS NULL) ASC, mood_id ASC, female DESC,
|
||||||
|
unconverted DESC, glitched ASC, id DESC",
|
||||||
|
Array [
|
||||||
|
"4795",
|
||||||
|
],
|
||||||
|
],
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -584,7 +647,7 @@ Array [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"SELECT * FROM swf_assets WHERE (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?)",
|
"SELECT * FROM swf_assets WHERE (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?) OR (type = ? AND remote_id = ?)",
|
||||||
Array [
|
Array [
|
||||||
"object",
|
"object",
|
||||||
"6829",
|
"6829",
|
||||||
|
@ -602,6 +665,18 @@ Array [
|
||||||
"51959",
|
"51959",
|
||||||
"object",
|
"object",
|
||||||
"56478",
|
"56478",
|
||||||
|
"biology",
|
||||||
|
"7942",
|
||||||
|
"biology",
|
||||||
|
"7941",
|
||||||
|
"biology",
|
||||||
|
"24008",
|
||||||
|
"biology",
|
||||||
|
"21060",
|
||||||
|
"biology",
|
||||||
|
"21057",
|
||||||
|
"biology",
|
||||||
|
"7946",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
|
@ -743,7 +818,7 @@ Array [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"INSERT INTO swf_assets (body_id, created_at, remote_id, type, url, zone_id, zones_restrict) VALUES (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?);",
|
"INSERT INTO swf_assets (body_id, created_at, remote_id, type, url, zone_id, zones_restrict) VALUES (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?);",
|
||||||
Array [
|
Array [
|
||||||
180,
|
180,
|
||||||
2020-01-01T00:00:00.000Z,
|
2020-01-01T00:00:00.000Z,
|
||||||
|
@ -801,6 +876,48 @@ Array [
|
||||||
"http://images.neopets.com/cp/items/swf/000/000/056/56478_eabc28e7c7.swf",
|
"http://images.neopets.com/cp/items/swf/000/000/056/56478_eabc28e7c7.swf",
|
||||||
27,
|
27,
|
||||||
"",
|
"",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"7942",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/007/7942_2eab06fd7b.swf",
|
||||||
|
5,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"7941",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/007/7941_2c4cc4b846.swf",
|
||||||
|
15,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"24008",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/024/24008_a05fe9876a.swf",
|
||||||
|
30,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"21060",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/021/21060_d77ba93b7b.swf",
|
||||||
|
33,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"21057",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/021/21057_4550efbb2f.swf",
|
||||||
|
34,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
|
0,
|
||||||
|
2020-01-01T00:00:00.000Z,
|
||||||
|
"7946",
|
||||||
|
"biology",
|
||||||
|
"http://images.neopets.com/cp/bio/swf/000/000/007/7946_0348dad587.swf",
|
||||||
|
37,
|
||||||
|
"0000000000000000000000000000000000000000000000000000",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
|
|
|
@ -163,9 +163,8 @@ async function saveModelingData(
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const customPet = customPetData.custom_pet;
|
const customPet = customPetData.custom_pet;
|
||||||
const objectInfos = Object.values(customPetData.object_info_registry);
|
|
||||||
const objectAssets = Object.values(customPetData.object_asset_registry);
|
|
||||||
|
|
||||||
|
const objectInfos = Object.values(customPetData.object_info_registry);
|
||||||
const incomingItems = objectInfos.map((objectInfo) => ({
|
const incomingItems = objectInfos.map((objectInfo) => ({
|
||||||
id: String(objectInfo.obj_info_id),
|
id: String(objectInfo.obj_info_id),
|
||||||
zonesRestrict: objectInfo.zones_restrict,
|
zonesRestrict: objectInfo.zones_restrict,
|
||||||
|
@ -176,7 +175,6 @@ async function saveModelingData(
|
||||||
price: objectInfo.price,
|
price: objectInfo.price,
|
||||||
weightLbs: objectInfo.weight_lbs,
|
weightLbs: objectInfo.weight_lbs,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const incomingItemTranslations = objectInfos.map((objectInfo) => ({
|
const incomingItemTranslations = objectInfos.map((objectInfo) => ({
|
||||||
itemId: String(objectInfo.obj_info_id),
|
itemId: String(objectInfo.obj_info_id),
|
||||||
locale: "en",
|
locale: "en",
|
||||||
|
@ -185,6 +183,7 @@ async function saveModelingData(
|
||||||
rarity: objectInfo.rarity,
|
rarity: objectInfo.rarity,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const objectAssets = Object.values(customPetData.object_asset_registry);
|
||||||
const incomingItemSwfAssets = objectAssets.map((objectAsset) => ({
|
const incomingItemSwfAssets = objectAssets.map((objectAsset) => ({
|
||||||
type: "object",
|
type: "object",
|
||||||
remoteId: String(objectAsset.asset_id),
|
remoteId: String(objectAsset.asset_id),
|
||||||
|
@ -197,6 +196,18 @@ async function saveModelingData(
|
||||||
bodyId: customPet.body_id,
|
bodyId: customPet.body_id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const biologyAssets = Object.values(customPet.biology_by_zone);
|
||||||
|
const incomingPetSwfAssets = biologyAssets.map((biologyAsset) => ({
|
||||||
|
type: "biology",
|
||||||
|
remoteId: String(biologyAsset.part_id),
|
||||||
|
url: biologyAsset.asset_url,
|
||||||
|
zoneId: biologyAsset.zone_id,
|
||||||
|
zonesRestrict: biologyAsset.zones_restrict,
|
||||||
|
bodyId: 0,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const incomingSwfAssets = [...incomingItemSwfAssets, ...incomingPetSwfAssets];
|
||||||
|
|
||||||
const incomingPetTypes = [
|
const incomingPetTypes = [
|
||||||
{
|
{
|
||||||
colorId: String(customPet.color_id),
|
colorId: String(customPet.color_id),
|
||||||
|
@ -240,7 +251,7 @@ async function saveModelingData(
|
||||||
row.itemId,
|
row.itemId,
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
syncToDb(db, incomingItemSwfAssets, {
|
syncToDb(db, incomingSwfAssets, {
|
||||||
loader: swfAssetByRemoteIdLoader,
|
loader: swfAssetByRemoteIdLoader,
|
||||||
tableName: "swf_assets",
|
tableName: "swf_assets",
|
||||||
buildLoaderKey: (row) => ({ type: row.type, remoteId: row.remoteId }),
|
buildLoaderKey: (row) => ({ type: row.type, remoteId: row.remoteId }),
|
||||||
|
@ -252,6 +263,23 @@ async function saveModelingData(
|
||||||
includeUpdatedAt: false,
|
includeUpdatedAt: false,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// TODO: If we look up the potentially existing pet state earlier, then I
|
||||||
|
// think we can prime the cache and avoid creating a waterfall of
|
||||||
|
// queries here, even though it looks waterfall-y!
|
||||||
|
// NOTE: This pet type should have been looked up when syncing pet type, so
|
||||||
|
// this should be cached.
|
||||||
|
// const petType = await petTypeBySpeciesAndColorLoader.load({
|
||||||
|
// colorId: String(customPet.color_id),
|
||||||
|
// speciesId: String(customPet.species_id),
|
||||||
|
// });
|
||||||
|
// const incomingPetStates = [
|
||||||
|
// {
|
||||||
|
// petTypeId: petType.id,
|
||||||
|
// swfAssetIds: incomingPetSwfAssets.map(a => a.remoteId).sort().join(","),
|
||||||
|
// female:
|
||||||
|
// },
|
||||||
|
// ];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,6 +326,11 @@ async function syncToDb(
|
||||||
insert.updatedAt = new Date();
|
insert.updatedAt = new Date();
|
||||||
}
|
}
|
||||||
inserts.push(insert);
|
inserts.push(insert);
|
||||||
|
|
||||||
|
// Remove this from the loader cache, so that loading again will fetch
|
||||||
|
// the inserted row.
|
||||||
|
loader.clear(buildLoaderKey(incomingRow));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +348,10 @@ async function syncToDb(
|
||||||
update.updatedAt = new Date();
|
update.updatedAt = new Date();
|
||||||
}
|
}
|
||||||
updates.push({ incomingRow, update });
|
updates.push({ incomingRow, update });
|
||||||
|
|
||||||
|
// Remove this from the loader cache, so that loading again will fetch
|
||||||
|
// the updated row.
|
||||||
|
loader.clear(buildLoaderKey(incomingRow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue