@@ -5,38 +5,47 @@ use regex::Regex;
55use serde:: Serialize ;
66use sled:: { Db , Tree } ;
77
8+ pub mod discussion;
9+
10+ pub ( crate ) use discussion:: DiscussionDbSchema ;
11+
812use crate :: {
913 github:: { GitHubIssue , GitHubPullRequests } ,
1014 graphql:: { Issue , PullRequest } ,
1115} ;
16+
1217const ISSUE_TREE_NAME : & str = "issues" ;
1318const PULL_REQUEST_TREE_NAME : & str = "pull_requests" ;
19+ const DISCUSSION_TREE_NAME : & str = "discussions" ;
1420
1521#[ derive( Clone ) ]
1622pub ( crate ) struct Database {
1723 db : Db ,
1824 issue_tree : Tree ,
1925 pull_request_tree : Tree ,
26+ discussion_tree : Tree ,
2027}
2128
2229impl 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