Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Project detail page #605

Merged
merged 44 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d3841c9
navigate to project page
ZibanPirate Sep 21, 2024
c4e8883
mvp for project page
ZibanPirate Sep 21, 2024
f7f6a2f
project title on project page
ZibanPirate Sep 21, 2024
14337f0
added back button
ZibanPirate Sep 21, 2024
0cd0218
added project stats
ZibanPirate Sep 21, 2024
4d7e91d
don't rate limit in development
ZibanPirate Sep 21, 2024
bee976a
added repos and contors
ZibanPirate Sep 21, 2024
7301626
show open contributions of project
ZibanPirate Sep 21, 2024
ac9cff2
return project stats via api
ZibanPirate Sep 22, 2024
b46d35a
adjust project ranking to account for stars
ZibanPirate Sep 22, 2024
91ebbc9
return project repositories via api
ZibanPirate Sep 22, 2024
a3e8c54
return project contributors via api
ZibanPirate Sep 22, 2024
1b2a7bd
return project contributions via api
ZibanPirate Sep 22, 2024
d93341b
remove debug code
ZibanPirate Sep 22, 2024
a00efa4
fix lhci server shutdown while at it
ZibanPirate Sep 22, 2024
91aa3ef
responsive design for project detail on mobile app
ZibanPirate Sep 23, 2024
f01ca86
only show contributions of a project when there are some
ZibanPirate Sep 23, 2024
cbc25f5
relaxed rate limit
ZibanPirate Sep 23, 2024
868a33c
show stats in projects page
ZibanPirate Sep 23, 2024
d48d080
style tweaks for projects page
ZibanPirate Sep 23, 2024
bbd55ec
setup cloudflare functions
ZibanPirate Sep 23, 2024
30eab4f
first dynamic cloudflare route
ZibanPirate Sep 23, 2024
4858718
first stab at dynamic html
ZibanPirate Sep 23, 2024
3e6164e
moved functions folder to the top
ZibanPirate Sep 23, 2024
2c119a1
get project name from api
ZibanPirate Sep 23, 2024
147410a
removed dead config
ZibanPirate Sep 28, 2024
005df12
generate template html
ZibanPirate Sep 28, 2024
dc2d045
use template.html to render project
ZibanPirate Sep 28, 2024
5af30eb
localized project page title in cloudflare worker
ZibanPirate Sep 28, 2024
0e3e559
localized project page description in cloudflare worker
ZibanPirate Sep 28, 2024
23184e4
render not found page in case of 404 response
ZibanPirate Sep 28, 2024
6670ead
return 404 in api when not project found
ZibanPirate Sep 28, 2024
44fd8fe
return 404 in cloudflare when not project found
ZibanPirate Sep 28, 2024
f822f33
run pre-deploy in a separate step
ZibanPirate Sep 28, 2024
f43cab2
genrate and use wrangler.toml
ZibanPirate Sep 28, 2024
69d8602
Fix regex pattern for extracting project ID from URL
ZibanPirate Sep 28, 2024
12870da
handle /ar links
ZibanPirate Sep 28, 2024
5ac720e
localized project detail page
ZibanPirate Sep 29, 2024
d6395b3
temporarily handle detail page as part of list pages
ZibanPirate Sep 29, 2024
2fc55ba
api endpoint to list projects for sitemap
ZibanPirate Sep 30, 2024
f09ea4d
moved fetchV2 to utils package
ZibanPirate Sep 30, 2024
93a88bb
generate projects sitemap in cloudflare workers
ZibanPirate Sep 30, 2024
540e967
use fetchV2 in project detail worker
ZibanPirate Sep 30, 2024
651ce39
fixed linting errors
ZibanPirate Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cd.deploy.stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
run: npx lerna run bundle:alone --scope @dzcode.io/web
- name: "Sentry Release"
run: npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: "Pre-deploy"
run: npm run pre-deploy
- name: "Deploy"
run: npm run deploy:stg

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cd.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
run: npx lerna run bundle:alone --scope @dzcode.io/web
- name: "Sentry Release"
run: npm run generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: "Pre-deploy"
run: npm run pre-deploy
- name: "Deploy"
run: npm run deploy

Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ build
src/_e2e-test/downloads
src/_e2e-test/videos
src/_e2e-test/screenshots
cloudflare/public
**/cloudflare/public
cloudflare/public/*
**/cloudflare/public/*
**.lighthouseci
.wrangler
**/cloudflare/wrangler.toml

# mobile
mobile/.expo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ CREATE TABLE `contributions` (
FOREIGN KEY (`contributor_id`) REFERENCES `contributors`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `contributor_repository_relation` (
`contributor_id` integer NOT NULL,
`repository_id` integer NOT NULL,
`record_imported_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
`run_id` text DEFAULT 'initial-run-id' NOT NULL,
`score` integer NOT NULL,
PRIMARY KEY(`contributor_id`, `repository_id`),
FOREIGN KEY (`contributor_id`) REFERENCES `contributors`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `contributors` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`record_imported_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
Expand All @@ -39,6 +50,7 @@ CREATE TABLE `repositories` (
`name` text NOT NULL,
`run_id` text DEFAULT 'initial-run-id' NOT NULL,
`project_id` integer NOT NULL,
`stars` integer NOT NULL,
FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE no action
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a readme column here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what for? if for showing it in the project detail page, it will require more effort, we need to:

  • fetch the readme file and save it in the db in the crown job.
  • update the UI, and account for multiple repos case.

Copy link
Member

@omdxp omdxp Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about we fetch the readme file from backend and we static generate the readme section in project details? no need to save it in db

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's another way of doing it, thoe we will rich the Github rate-limit which is the reason why we had to switch to the cron-job, feel free to explore how we implement this in a separate task, but for now this will do 👌

);
--> statement-breakpoint
Expand Down
10 changes: 0 additions & 10 deletions api/db/migrations/0001_black_eternals.sql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this migration file was deleted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two reasons:

  • SQLite doesn't support altering tables, we may need to switch to another db engine later.
  • our data is refreshed on every cron job run, deleting the database and starting over is not a problem

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be better to have versioning in db structure that relates to the api version (some people might only need the api), that's why it is better to keep migrations

This file was deleted.

134 changes: 122 additions & 12 deletions api/db/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "ba41012f-4495-42ff-ace1-61bd7eaef476",
"id": "2fd49a6b-a3d6-4f53-a4f5-ac67492fc5dd",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"contributions": {
Expand Down Expand Up @@ -82,7 +82,9 @@
"indexes": {
"contributions_url_unique": {
"name": "contributions_url_unique",
"columns": ["url"],
"columns": [
"url"
],
"isUnique": true
}
},
Expand All @@ -91,24 +93,113 @@
"name": "contributions_repository_id_repositories_id_fk",
"tableFrom": "contributions",
"tableTo": "repositories",
"columnsFrom": ["repository_id"],
"columnsTo": ["id"],
"columnsFrom": [
"repository_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"contributions_contributor_id_contributors_id_fk": {
"name": "contributions_contributor_id_contributors_id_fk",
"tableFrom": "contributions",
"tableTo": "contributors",
"columnsFrom": ["contributor_id"],
"columnsTo": ["id"],
"columnsFrom": [
"contributor_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"contributor_repository_relation": {
"name": "contributor_repository_relation",
"columns": {
"contributor_id": {
"name": "contributor_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"repository_id": {
"name": "repository_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"record_imported_at": {
"name": "record_imported_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
},
"run_id": {
"name": "run_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'initial-run-id'"
},
"score": {
"name": "score",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"contributor_repository_relation_contributor_id_contributors_id_fk": {
"name": "contributor_repository_relation_contributor_id_contributors_id_fk",
"tableFrom": "contributor_repository_relation",
"tableTo": "contributors",
"columnsFrom": [
"contributor_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"contributor_repository_relation_repository_id_repositories_id_fk": {
"name": "contributor_repository_relation_repository_id_repositories_id_fk",
"tableFrom": "contributor_repository_relation",
"tableTo": "repositories",
"columnsFrom": [
"repository_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"contributor_repository_relation_pk": {
"columns": [
"contributor_id",
"repository_id"
],
"name": "contributor_repository_relation_pk"
}
},
"uniqueConstraints": {}
},
"contributors": {
"name": "contributors",
"columns": {
Expand Down Expand Up @@ -167,7 +258,9 @@
"indexes": {
"contributors_url_unique": {
"name": "contributors_url_unique",
"columns": ["url"],
"columns": [
"url"
],
"isUnique": true
}
},
Expand Down Expand Up @@ -219,7 +312,9 @@
"indexes": {
"projects_slug_unique": {
"name": "projects_slug_unique",
"columns": ["slug"],
"columns": [
"slug"
],
"isUnique": true
}
},
Expand Down Expand Up @@ -280,12 +375,23 @@
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"stars": {
"name": "stars",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"repositories_provider_owner_name_unique": {
"name": "repositories_provider_owner_name_unique",
"columns": ["provider", "owner", "name"],
"columns": [
"provider",
"owner",
"name"
],
"isUnique": true
}
},
Expand All @@ -294,8 +400,12 @@
"name": "repositories_project_id_projects_id_fk",
"tableFrom": "repositories",
"tableTo": "projects",
"columnsFrom": ["project_id"],
"columnsTo": ["id"],
"columnsFrom": [
"project_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand All @@ -313,4 +423,4 @@
"internal": {
"indexes": {}
}
}
}
Loading
Loading