Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit e584b65

Browse files
committed
Add Discussions GraphQL query
Close #171
1 parent 0fb83ae commit e584b65

File tree

7 files changed

+788
-6
lines changed

7 files changed

+788
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1111
- Tracing with a filter set by `RUST_LOG` environment variable.
1212
- Added support for passing the SSH passphrase through the `SSH_PASSPHRASE`
1313
environment variable.
14+
- Exposed a new `discussions` query in the server’s GraphQL API to query the
15+
stored discussion data.
1416

1517
### Changed
1618

src/database.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,47 @@ use regex::Regex;
55
use serde::Serialize;
66
use sled::{Db, Tree};
77

8+
pub mod discussion;
9+
10+
pub(crate) use discussion::DiscussionDbSchema;
11+
812
use crate::{
913
github::{GitHubIssue, GitHubPullRequests},
1014
graphql::{Issue, PullRequest},
1115
};
16+
1217
const ISSUE_TREE_NAME: &str = "issues";
1318
const PULL_REQUEST_TREE_NAME: &str = "pull_requests";
19+
const DISCUSSION_TREE_NAME: &str = "discussions";
1420

1521
#[derive(Clone)]
1622
pub(crate) struct Database {
1723
db: Db,
1824
issue_tree: Tree,
1925
pull_request_tree: Tree,
26+
discussion_tree: Tree,
2027
}
2128

2229
impl Database {
2330
fn connect_db(path: &Path) -> Result<Db> {
2431
Ok(sled::open(path)?)
2532
}
2633

27-
fn connect_trees(db: &Db) -> Result<(Tree, Tree)> {
34+
fn connect_trees(db: &Db) -> Result<(Tree, Tree, Tree)> {
2835
let issue_tree = db.open_tree(ISSUE_TREE_NAME)?;
2936
let pull_request_tree = db.open_tree(PULL_REQUEST_TREE_NAME)?;
30-
Ok((issue_tree, pull_request_tree))
37+
let discussion_tree = db.open_tree(DISCUSSION_TREE_NAME)?;
38+
Ok((issue_tree, pull_request_tree, discussion_tree))
3139
}
3240

3341
pub(crate) fn connect(db_path: &Path) -> Result<Database> {
3442
let db = Database::connect_db(db_path)?;
35-
let (issue_tree, pull_request_tree) = Database::connect_trees(&db)?;
43+
let (issue_tree, pull_request_tree, discussion_tree) = Database::connect_trees(&db)?;
3644
Ok(Database {
3745
db,
3846
issue_tree,
3947
pull_request_tree,
48+
discussion_tree,
4049
})
4150
}
4251

0 commit comments

Comments
 (0)