@pratik7368patil/anchor-core 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/db/schema.sql +0 -2
package/dist/index.js
CHANGED
|
@@ -718,8 +718,6 @@ CREATE INDEX IF NOT EXISTS idx_org_repositories_org ON org_repositories(org);
|
|
|
718
718
|
CREATE INDEX IF NOT EXISTS idx_org_repo_state_org ON org_repo_state(org);
|
|
719
719
|
CREATE INDEX IF NOT EXISTS idx_org_edges_source ON org_cross_repo_edges(org, source_repo);
|
|
720
720
|
CREATE INDEX IF NOT EXISTS idx_org_edges_target ON org_cross_repo_edges(org, target_repo);
|
|
721
|
-
CREATE INDEX IF NOT EXISTS idx_org_edges_layer ON org_cross_repo_edges(org, layer, confidence);
|
|
722
|
-
CREATE INDEX IF NOT EXISTS idx_org_edges_repo_pair ON org_cross_repo_edges(org, layer, source_repo, target_repo, relationship);
|
|
723
721
|
CREATE INDEX IF NOT EXISTS idx_org_consumers_provider ON org_api_consumers(org, provider_repo);
|
|
724
722
|
CREATE INDEX IF NOT EXISTS idx_org_consumers_consumer ON org_api_consumers(org, consumer_repo);
|
|
725
723
|
CREATE INDEX IF NOT EXISTS idx_org_consumers_contract ON org_api_consumers(org, contract);
|
|
@@ -8957,20 +8955,42 @@ function count(db, table, where = "", params = []) {
|
|
|
8957
8955
|
const row = db.prepare(`SELECT COUNT(*) AS count FROM ${table} ${where}`).get(...params);
|
|
8958
8956
|
return row.count;
|
|
8959
8957
|
}
|
|
8958
|
+
function tableHasColumn(db, table, column) {
|
|
8959
|
+
try {
|
|
8960
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
8961
|
+
return rows.some((row) => row.name === column);
|
|
8962
|
+
} catch {
|
|
8963
|
+
return false;
|
|
8964
|
+
}
|
|
8965
|
+
}
|
|
8966
|
+
function orgEdgeCountWhere(hasLayer, hasWeakFlag, filter) {
|
|
8967
|
+
const clauses = ["org = ?"];
|
|
8968
|
+
if (hasLayer) clauses.push("layer = 'repo'");
|
|
8969
|
+
if (filter === "visible" && hasWeakFlag) clauses.push("is_weak = 0");
|
|
8970
|
+
if (filter === "weak") {
|
|
8971
|
+
if (hasWeakFlag) clauses.push("is_weak = 1");
|
|
8972
|
+
else clauses.push("1 = 0");
|
|
8973
|
+
}
|
|
8974
|
+
return `WHERE ${clauses.join(" AND ")}`;
|
|
8975
|
+
}
|
|
8960
8976
|
function getOrgGraphCounts(db, org) {
|
|
8961
8977
|
initializeSchema(db);
|
|
8978
|
+
const hasLayer = tableHasColumn(db, "org_cross_repo_edges", "layer");
|
|
8979
|
+
const hasWeakFlag = tableHasColumn(db, "org_cross_repo_edges", "is_weak");
|
|
8962
8980
|
return {
|
|
8963
|
-
edges: count(db, "org_cross_repo_edges",
|
|
8981
|
+
edges: count(db, "org_cross_repo_edges", orgEdgeCountWhere(hasLayer, hasWeakFlag, "all"), [
|
|
8982
|
+
org
|
|
8983
|
+
]),
|
|
8964
8984
|
visibleEdges: count(
|
|
8965
8985
|
db,
|
|
8966
8986
|
"org_cross_repo_edges",
|
|
8967
|
-
|
|
8987
|
+
orgEdgeCountWhere(hasLayer, hasWeakFlag, "visible"),
|
|
8968
8988
|
[org]
|
|
8969
8989
|
),
|
|
8970
8990
|
weakEdges: count(
|
|
8971
8991
|
db,
|
|
8972
8992
|
"org_cross_repo_edges",
|
|
8973
|
-
|
|
8993
|
+
orgEdgeCountWhere(hasLayer, hasWeakFlag, "weak"),
|
|
8974
8994
|
[org]
|
|
8975
8995
|
),
|
|
8976
8996
|
apiContracts: count(db, "org_api_contracts", "WHERE org = ?", [org]),
|
|
@@ -8999,16 +9019,18 @@ function getOrgStatus(db, config, baseDir, options = {}) {
|
|
|
8999
9019
|
const codeFileCount = count(db, "code_files");
|
|
9000
9020
|
const codeChunkCount = count(db, "code_chunks");
|
|
9001
9021
|
const wisdomUnitCount = count(db, "wisdom_units");
|
|
9022
|
+
const hasLayer = tableHasColumn(db, "org_cross_repo_edges", "layer");
|
|
9023
|
+
const hasWeakFlag = tableHasColumn(db, "org_cross_repo_edges", "is_weak");
|
|
9002
9024
|
const crossRepoEdgeCount = count(
|
|
9003
9025
|
db,
|
|
9004
9026
|
"org_cross_repo_edges",
|
|
9005
|
-
|
|
9027
|
+
orgEdgeCountWhere(hasLayer, hasWeakFlag, "visible"),
|
|
9006
9028
|
[config.org]
|
|
9007
9029
|
);
|
|
9008
9030
|
const graphWeakEdgeCount = count(
|
|
9009
9031
|
db,
|
|
9010
9032
|
"org_cross_repo_edges",
|
|
9011
|
-
|
|
9033
|
+
orgEdgeCountWhere(hasLayer, hasWeakFlag, "weak"),
|
|
9012
9034
|
[config.org]
|
|
9013
9035
|
);
|
|
9014
9036
|
const apiContractCount = count(db, "org_api_contracts", "WHERE org = ?", [config.org]);
|