Add repository settings
parent: tbd commit: f8eaf38
1 | use Error; |
2 | use StreamExt; |
3 | use ; |
4 | use Value; |
5 | use ; |
6 | |
7 | use SettingsBackend; |
8 | |
9 | |
10 | pub pg_pool: PgPool, |
11 | |
12 | |
13 | |
14 | |
15 | async |
16 | let settings = query_as! |
17 | UserSettingRow, |
18 | r#"SELECT * FROM user_settings WHERE username = $1"#, |
19 | user.username |
20 | |
21 | .fetch_many |
22 | .filter_map |
23 | if let Ok = result |
24 | Some |
25 | else |
26 | None |
27 | |
28 | |
29 | .filter_map |
30 | if let Ok = from_str |
31 | Some |
32 | else |
33 | None |
34 | |
35 | |
36 | . |
37 | .await; |
38 | |
39 | Ok |
40 | |
41 | async |
42 | &mut self, |
43 | user: &User, |
44 | settings: &[ ], |
45 | |
46 | for in settings |
47 | ! | query
48 | user.username, name, value |
49 | .execute .await?; |
50 | |
51 | |
52 | Ok |
53 | |
54 | |
55 | async |
56 | &mut self, |
57 | repository: &Repository, |
58 | |
59 | let settings = query_as! |
60 | RepositorySettingRow, |
61 | r#"SELECT * FROM repository_settings WHERE repository = $1"#, |
62 | repository.to_string |
63 | |
64 | .fetch_many |
65 | .filter_map |
66 | if let Ok = result |
67 | Some |
68 | else |
69 | None |
70 | |
71 | |
72 | .filter_map |
73 | if let Ok = from_str |
74 | Some |
75 | else |
76 | None |
77 | |
78 | |
79 | . |
80 | .await; |
81 | |
82 | Ok |
83 | |
84 | async |
85 | &mut self, |
86 | repository: &Repository, |
87 | settings: &[ ], |
88 | |
89 | for in settings |
90 | ! | query
91 | repository.to_string, name, value |
92 | .execute .await?; |
93 | |
94 | |
95 | Ok |
96 | |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | pub username: String, |
103 | pub name: String, |
104 | pub value: String, |
105 | |
106 | |
107 | |
108 | |
109 | |
110 | pub repository: String, |
111 | pub name: String, |
112 | pub value: String, |
113 | |
114 |