Skip to content

Commit 4ea43ea

Browse files
committed
refactor sql files to individual files
1 parent cba767d commit 4ea43ea

38 files changed

+267
-317
lines changed

Analyzer/AnalyzerTool.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
23
using System;
34
using System.Collections.Generic;
45
using System.Diagnostics;
@@ -46,7 +47,7 @@ public int Analyze(
4647
int i = 1;
4748
foreach (var file in files)
4849
{
49-
if (Path.GetExtension(file) == ".json")
50+
if (Path.GetExtension(file) == ".json" && IsAddressablesBuildReport(file))
5051
{
5152
ProcessAddressablesBuild(file, writer, i, files.Length);
5253
++i;
@@ -234,4 +235,45 @@ void EraseProgressLine()
234235
else
235236
Console.WriteLine();
236237
}
238+
239+
bool IsAddressablesBuildReport(string filename)
240+
{
241+
// Read the first line of the JSON file and check if it contains BuildResultHash
242+
string firstLine = "";
243+
try
244+
{
245+
using (StreamReader reader = new StreamReader(filename))
246+
{
247+
firstLine = reader.ReadLine();
248+
if (firstLine != null)
249+
{
250+
// Remove trailing comma if present and add closing brace to make it valid JSON
251+
if (firstLine.TrimEnd().EndsWith(","))
252+
{
253+
firstLine = firstLine.TrimEnd().TrimEnd(',') + "}";
254+
}
255+
256+
using (JsonTextReader jsonReader = new JsonTextReader(new StringReader(firstLine)))
257+
{
258+
JsonSerializer serializer = new JsonSerializer();
259+
var jsonObject = serializer.Deserialize<JObject>(jsonReader);
260+
261+
// If the file has BuildResultHash, process it as an Addressables build
262+
if (jsonObject != null && jsonObject["BuildResultHash"] != null)
263+
{
264+
return true;
265+
}
266+
}
267+
}
268+
}
269+
}
270+
catch (Exception e)
271+
{
272+
if (m_Verbose)
273+
{
274+
Console.Error.WriteLine($"Error reading JSON file {filename}: {e.Message}");
275+
}
276+
}
277+
return false;
278+
}
237279
}

Analyzer/Resources/AddrBuildBundleDependencies.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_bundle_dependencies
1+
CREATE TABLE IF NOT EXISTS addr_build_bundle_dependencies
22
(
33
bundle_id INTEGER,
44
build_id INTEGER,

Analyzer/Resources/AddrBuildBundleDependentBundles.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_bundle_dependent_bundles
1+
CREATE TABLE IF NOT EXISTS addr_build_bundle_dependent_bundles
22
(
33
bundle_id INTEGER,
44
build_id INTEGER,

Analyzer/Resources/AddrBuildBundleExpandedDependencies.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_bundle_expanded_dependencies
1+
CREATE TABLE IF NOT EXISTS addr_build_bundle_expanded_dependencies
22
(
33
bundle_id INTEGER,
44
build_id INTEGER,

Analyzer/Resources/AddrBuildBundleFiles.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_bundle_files
1+
CREATE TABLE IF NOT EXISTS addr_build_bundle_files
22
(
33
bundle_id INTEGER,
44
build_id INTEGER,

Analyzer/Resources/AddrBuildBundleRegularDependencies.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_bundle_regular_dependencies
1+
CREATE TABLE IF NOT EXISTS addr_build_bundle_regular_dependencies
22
(
33
bundle_id INTEGER,
44
build_id INTEGER,

Analyzer/Resources/AddrBuildBundles.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_bundles
1+
CREATE TABLE IF NOT EXISTS addr_build_bundles
22
(
33
id INTEGER,
44
build_id INTEGER,
@@ -17,4 +17,6 @@ create table addr_build_bundles
1717
provider TEXT,
1818
result_type TEXT,
1919
PRIMARY KEY (id, build_id)
20-
);
20+
);
21+
22+
CREATE VIEW IF NOT EXISTS addr_build_cached_bundles AS SELECT build_id, concat(internal_name, '.bundle') AS cached_name, name AS catalog_name FROM addr_build_bundles;

Analyzer/Resources/AddrBuildDataFromOtherAssetObjectReferences.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_data_from_other_asset_object_references
1+
CREATE TABLE IF NOT EXISTS addr_build_data_from_other_asset_object_references
22
(
33
data_from_other_asset_id INTEGER,
44
build_id INTEGER,

Analyzer/Resources/AddrBuildDataFromOtherAssetObjects.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_data_from_other_asset_objects
1+
CREATE TABLE IF NOT EXISTS addr_build_data_from_other_asset_objects
22
(
33
data_from_other_asset_id INTEGER,
44
build_id INTEGER,

Analyzer/Resources/AddrBuildDataFromOtherAssetReferencingAssets.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create table addr_build_data_from_other_asset_referencing_assets
1+
CREATE TABLE IF NOT EXISTS addr_build_data_from_other_asset_referencing_assets
22
(
33
data_from_other_asset_id INTEGER,
44
build_id INTEGER,

0 commit comments

Comments
 (0)