Skip to content

Commit b955e70

Browse files
Fixed formatting, also added script to run dependents_calculator.sql before pushing in index_new_repo, also fixed the formetter file
1 parent b8047ee commit b955e70

8 files changed

Lines changed: 50 additions & 39 deletions

.github/workflows/codeberg_automatic_update.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525

2626
- name: uv sync and install important things
2727
run: |
28-
cd ./src/readme_keyword_extraction
28+
cd ./src/readme_keyword_extraction
2929
30-
uv sync
30+
uv sync
3131
32-
uv run uvicorn main:app --host 0.0.0.0 --port 8000 &
32+
uv run uvicorn main:app --host 0.0.0.0 --port 8000 &
3333
3434
- name: wait for 20 seconds before starting, for server to start
3535
run: |
@@ -39,7 +39,6 @@ jobs:
3939
- name: install hf
4040
run: curl -LsSf https://hf.co/cli/install.sh | bash
4141

42-
4342
- name: Download cron-codeberg binary
4443
run: wget -O cron-codeberg https://github.com/Zigistry/database/releases/download/executables/cron-codeberg
4544

@@ -54,4 +53,3 @@ jobs:
5453

5554
- name: push updated database
5655
run: hf cp ./zigistry.db hf://buckets/Zigistry/Zigistry/zigistry.db
57-

.github/workflows/github_automatic_update.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525

2626
- name: uv sync and install important things
2727
run: |
28-
cd ./src/readme_keyword_extraction
28+
cd ./src/readme_keyword_extraction
2929
30-
uv sync
30+
uv sync
3131
32-
uv run uvicorn main:app --host 0.0.0.0 --port 8000 &
32+
uv run uvicorn main:app --host 0.0.0.0 --port 8000 &
3333
3434
- name: wait for 20 seconds before starting, for server to start
3535
run: |

.github/workflows/index_safe_repos_automatic_update.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626

2727
- name: uv sync and install important things
2828
run: |
29-
cd ./src/readme_keyword_extraction
29+
cd ./src/readme_keyword_extraction
3030
31-
uv sync
31+
uv sync
3232
33-
uv run uvicorn main:app --host 0.0.0.0 --port 8000 &
33+
uv run uvicorn main:app --host 0.0.0.0 --port 8000 &
3434
3535
- name: wait for 20 seconds before starting, for server to start
3636
run: |
@@ -40,7 +40,6 @@ jobs:
4040
- name: install hf
4141
run: curl -LsSf https://hf.co/cli/install.sh | bash
4242

43-
4443
- name: Download index-safe-repos binary
4544
run: wget -O index-safe-repos https://github.com/Zigistry/database/releases/download/executables/index-safe-repos
4645

@@ -53,6 +52,8 @@ jobs:
5352
- name: Run index-safe-repos
5453
run: ./index-safe-repos
5554

55+
- name: Run dependents calculator
56+
run: sqlite3 ./zigistry.db < ./Database_SQL_Files/dependents_calculator.sql
57+
5658
- name: push updated database
5759
run: hf cp ./zigistry.db hf://buckets/Zigistry/Zigistry/zigistry.db
58-

Database_SQL_Files/database_schema.sql

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CREATE TABLE users (
44
platform VARCHAR(10) NOT NULL,
55
bio VARCHAR(260)
66
);
7+
78
CREATE TABLE repos (
89
-- The username is 40 characters at max, repo name is 100 and the key and slashes is 5
910
-- Hence, I can keep this at 150.
@@ -24,15 +25,9 @@ CREATE TABLE repos (
2425
created_at TIMESTAMP NOT NULL,
2526
-- I just realised that the boolean type is like an integer only.
2627
-- I added check that it should only be either true or false. i.e 0, 1
27-
is_archived BOOLEAN NOT NULL CHECK (
28-
is_archived IN (0, 1)
29-
),
30-
is_disabled BOOLEAN NOT NULL CHECK (
31-
is_disabled IN (0, 1)
32-
),
33-
is_fork BOOLEAN NOT NULL CHECK (
34-
is_fork IN (0, 1)
35-
),
28+
is_archived BOOLEAN NOT NULL CHECK (is_archived IN (0, 1)),
29+
is_disabled BOOLEAN NOT NULL CHECK (is_disabled IN (0, 1)),
30+
is_fork BOOLEAN NOT NULL CHECK (is_fork IN (0, 1)),
3631
-- Making this only 30 characters limit, it shouldn't be more than that.
3732
-- Simple google tells, its just 36 characters, so, ok?
3833
license VARCHAR(40) NOT NULL,
@@ -42,9 +37,9 @@ CREATE TABLE repos (
4237
last_updated_in_this_database TIMESTAMP NOT NULL,
4338
FOREIGN KEY (owner) REFERENCES users (id) ON DELETE CASCADE
4439
);
45-
CREATE VIRTUAL TABLE repo_search USING fts5 (
46-
repo_id, keywords, tokenize = 'porter'
47-
);
40+
41+
CREATE VIRTUAL TABLE repo_search USING fts5 (repo_id, keywords, tokenize = 'porter');
42+
4843
-- Doing this to make sure, no duplicate repo_id is added.
4944
-- I will be using this query:
5045
-- INSERT OR REPLACE INTO repo_search (repo_id, keywords) VALUES (?, ?)
@@ -55,12 +50,14 @@ CREATE TABLE repo_topics (
5550
FOREIGN KEY (repo_id) REFERENCES repos (id) ON DELETE CASCADE,
5651
UNIQUE (repo_id, topic)
5752
);
53+
5854
CREATE TABLE repo_dependents (
5955
repo_id VARCHAR(150) NOT NULL,
6056
dependent VARCHAR(260) NOT NULL,
6157
FOREIGN KEY (repo_id) REFERENCES repos (id) ON DELETE CASCADE,
6258
UNIQUE (repo_id, dependent)
6359
);
60+
6461
CREATE TABLE releases (
6562
id INTEGER PRIMARY KEY AUTOINCREMENT,
6663
repo_id VARCHAR(150) NOT NULL,
@@ -74,32 +71,35 @@ CREATE TABLE releases (
7471
FOREIGN KEY (repo_id) REFERENCES repos (id) ON DELETE CASCADE,
7572
UNIQUE (repo_id, version)
7673
);
74+
7775
CREATE TABLE release_dependencies (
7876
release_id INTEGER NOT NULL,
7977
name VARCHAR(260) NOT NULL,
8078
hash VARCHAR(260) NOT NULL,
81-
is_lazy BOOLEAN NOT NULL CHECK (
82-
is_lazy IN (0, 1)
83-
),
79+
is_lazy BOOLEAN NOT NULL CHECK (is_lazy IN (0, 1)),
8480
url VARCHAR(260) NOT NULL,
8581
path VARCHAR(260) NOT NULL,
8682
FOREIGN KEY (release_id) REFERENCES releases (id) ON DELETE CASCADE,
8783
UNIQUE (release_id, name)
8884
);
85+
8986
CREATE TABLE index_sections (
9087
section_name VARCHAR(10) NOT NULL,
9188
repo_id VARCHAR(150) NOT NULL,
9289
FOREIGN KEY (repo_id) REFERENCES repos (id) ON DELETE CASCADE,
9390
UNIQUE (section_name, repo_id)
9491
);
92+
9593
CREATE TABLE packages (
9694
repo_id VARCHAR(150) NOT NULL PRIMARY KEY,
9795
FOREIGN KEY (repo_id) REFERENCES repos (id) ON DELETE CASCADE
9896
);
97+
9998
CREATE TABLE programs (
10099
repo_id VARCHAR(150) NOT NULL PRIMARY KEY,
101100
FOREIGN KEY (repo_id) REFERENCES repos (id) ON DELETE CASCADE
102101
);
102+
103103
CREATE TABLE index_new_repo (
104104
id VARCHAR(150) PRIMARY KEY,
105105
type_of_repo VARCHAR(10) NOT NULL -- This is like, package or program.
@@ -109,44 +109,51 @@ CREATE TABLE safe_to_index_new_repo (
109109
id VARCHAR(150) PRIMARY KEY,
110110
type_of_repo VARCHAR(10) NOT NULL -- This is like, package or program.
111111
);
112+
112113
-- For this specifically, I will create a AI model, I will train it to detect
113114
-- all the scam repos, if my AI algorithm flags a repo
114115
-- to review it will be added to this table, if no problem, it will continue.
115116
CREATE TABLE quarantined_repos (
116117
id VARCHAR(150) PRIMARY KEY,
117118
type_of_repo VARCHAR(10) NOT NULL
118119
);
120+
119121
-- These are only the users who are either spamming or
120122
-- shipping malware.
121-
CREATE TABLE banned_user_list (
122-
id VARCHAR(45) PRIMARY KEY
123-
);
123+
CREATE TABLE banned_user_list (id VARCHAR(45) PRIMARY KEY);
124+
124125
-- This is for making it easier to fetch
125126
-- details of these repositories
126127
-- to improve the accuracy of the algorithm
127128
-- which detects such repos.
128-
CREATE TABLE banned_repo_list (
129-
id VARCHAR(150) PRIMARY KEY
130-
);
129+
CREATE TABLE banned_repo_list (id VARCHAR(150) PRIMARY KEY);
130+
131131
-- Needs update
132132
CREATE TABLE needs_updates (
133133
id VARCHAR(150) PRIMARY KEY,
134134
-- All the repos that need updates.
135135
type_of_repo VARCHAR(10) NOT NULL -- This is like, package or program.
136-
);
136+
);
137+
137138
-- I do search for "All repos where username is username"
138139
CREATE INDEX repo_owner_index ON repos (owner);
140+
139141
-- Again, I do this, specially for the top 10 latest repos
140142
CREATE INDEX repo_created_at_index ON repos (created_at);
143+
141144
-- again, for repos with most stars
142145
CREATE INDEX repo_star_count_index ON repos (stargazer_count);
146+
143147
-- Whenever someone visits a repo page, that page
144148
-- needs "ALl the releases with of that repo."
145149
CREATE INDEX releases_repo_index ON releases (repo_id, published_at DESC);
150+
146151
-- Also, for every release, I need to get
147152
-- all the dependencies of that release
148153
CREATE INDEX release_dependencies_release_id_index ON release_dependencies (release_id);
154+
149155
-- Ok, on every package I also need number of repo topics.
150156
CREATE INDEX repo_topics_repo_id_index ON repo_topics (repo_id);
157+
151158
-- Ok, on every package I also need number of repo dependents.
152159
CREATE INDEX repo_dependents_repo_id_index ON repo_dependents (repo_id);

GitHub_GQL_API_Files/fetch-search-query-everything.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ fragment RepoFields on Repository {
7575
name
7676
}
7777
}
78-
}
78+
}

GitHub_GQL_API_Files/fetch-search-query-partial.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ fragment RepoFields on Repository {
3434
name
3535
}
3636
}
37-
}
37+
}

formater.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ taplo fmt
33
npx prettier --write "**/*.{md,yaml,yml,gql}"
44
npx sql-formatter -l sqlite --fix ./Database_SQL_Files/database_schema.sql
55
npx sql-formatter -l sqlite --fix ./Database_SQL_Files/dependents_calculator.sql
6-
zig fmt ./src/search_preparer.zig
6+

src/bin/fetch-readmes-and-process.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ async fn get_readme(
6363
)
6464
.await;
6565
let (_, content) = codeberg::helper_functions::get_readme_url(
66-
&owner, &name, &branch, false, true, &directory_files,
66+
&owner,
67+
&name,
68+
&branch,
69+
false,
70+
true,
71+
&directory_files,
6772
)
6873
.await;
6974
content

0 commit comments

Comments
 (0)