Skip to content

Commit

Permalink
Extra endpoints (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn authored Jun 5, 2024
1 parent 1d1f4ef commit d25d3d5
Show file tree
Hide file tree
Showing 18 changed files with 611 additions and 33 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Messages.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
link = "https://github.com/race-of-sloths"
leaderboard_link = "https://github.com/race-of-sloths"
form = "https://github.com/race-of-sloths"
picture_api_link = "https://race-of-sloths.fly.dev/api/badges"
picture_api_link = "https://race-of-sloths.fly.dev/api/user/{pr_author_username}/badge"

[include_basic_messages]
variables = [
Expand All @@ -23,7 +23,7 @@ Thank you @{pr_author_username} for your contribution!
<details>
<summary><strong>More info about the author - @{pr_author_username}</strong></summary>
![sloth_stats]({picture_api_link}/{pr_author_username})
![sloth_stats]({picture_api_link})
</details>
Expand Down
9 changes: 5 additions & 4 deletions contract/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ impl Contract {
}
}

pub fn prs(&self, page: u64, limit: u64) -> Vec<PR> {
/// Returns a list of PRs with the execution status
pub fn prs(&self, limit: u64, page: u64) -> Vec<(PR, bool)> {
self.prs
.values()
.into_iter()
.chain(self.executed_prs.iter())
.skip((page * limit) as usize)
.take(limit as usize)
.cloned()
.map(Into::into)
.map(|(id, pr)| (pr.clone().into(), !self.prs.contains_key(id)))
.collect()
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ dotenv.workspace = true
envy.workspace = true
rocket = { workspace = true, features = ["json"] }
rocket_db_pools = { workspace = true, features = ["sqlx_postgres"] }
sqlx = { workspace = true, features = ["postgres", "macros"] }
sqlx = { workspace = true, features = ["postgres", "macros", "chrono"] }
serde.workspace = true
base64.workspace = true
reqwest.workspace = true
chrono.workspace = true
chrono = { workspace = true, features = ["serde"] }
usvg.workspace = true
rocket_prometheus.workspace = true

Expand Down
23 changes: 23 additions & 0 deletions server/migrations/20240605105927_prs_and_repo_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE IF NOT EXISTS organizations (
id SERIAL PRIMARY KEY,
name TEXT UNIQUE NOT NULL
);

CREATE TABLE IF NOT EXISTS repos (
id SERIAL PRIMARY KEY,
organization_id INTEGER REFERENCES organizations(id) ON DELETE CASCADE,
name TEXT NOT NULL,
UNIQUE (organization_id, name)
);

CREATE TABLE IF NOT EXISTS pull_requests (
id SERIAL PRIMARY KEY,
repo_id INTEGER REFERENCES repos(id) ON DELETE CASCADE,
number INTEGER NOT NULL,
author_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMP NOT NULL,
merged_at TIMESTAMP,
executed BOOLEAN NOT NULL,
score INTEGER,
UNIQUE (repo_id, number)
);
Loading

0 comments on commit d25d3d5

Please sign in to comment.