Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibreHomework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HGEpro
LibreHomework
Commits
0023680a
Commit
0023680a
authored
3 years ago
by
HGEpro
Browse files
Options
Downloads
Patches
Plain Diff
updated model for task, fixed errors
parent
cabce21f
No related branches found
Branches containing commit
Tags
0.0.1
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/config.rs
+0
-2
0 additions, 2 deletions
daemon/src/config.rs
daemon/src/db.rs
+10
-6
10 additions, 6 deletions
daemon/src/db.rs
with
10 additions
and
8 deletions
daemon/src/config.rs
+
0
−
2
View file @
0023680a
...
...
@@ -19,13 +19,11 @@ pub struct DaemonConfig {
impl
DaemonConfig
{
pub
fn
read_config
()
->
Option
<
DaemonConfig
>
{
let
path
=
config_dir
()
?
.join
(
"LibreHomework/daemonconfig.json"
);
println!
(
"{:?}"
,
path
.exists
());
if
!
path
.exists
()
{
println!
(
"Daemon config file not found, creating default config"
);
DaemonConfig
::
write_config
(
default_daemon_config
());
}
let
config_file
=
std
::
fs
::
read_to_string
(
path
)
.ok
()
?
;
println!
(
"here"
);
serde_json
::
from_str
::
<
HashMap
<&
str
,
DaemonConfig
>>
(
&
config_file
)
.ok
()
?
.get
(
"daemon"
)
.cloned
()
}
...
...
This diff is collapsed.
Click to expand it.
daemon/src/db.rs
+
10
−
6
View file @
0023680a
...
...
@@ -3,6 +3,7 @@ use dirs_next::config_dir;
#[derive(Debug)]
pub
struct
Task
{
pub
id
:
u32
,
pub
name
:
String
,
pub
subject
:
String
,
pub
description
:
String
,
...
...
@@ -14,6 +15,7 @@ pub struct Database {
impl
Database
{
pub
fn
new
()
->
Option
<
Self
>
{
let
path
=
config_dir
()
.unwrap
()
.join
(
"LibreHomework/LibreHomework.db"
);
if
!
path
.exists
()
{
return
None
;
}
else
{
...
...
@@ -30,20 +32,22 @@ impl Database {
let
conn
=
self
.init_connection
()
?
;
let
mut
stmt
=
conn
.prepare
(
"SELECT * FROM tasks"
)
?
;
let
mut
rows
=
stmt
.query
([])
?
;
println!
(
"what"
);
while
let
Some
(
row
)
=
rows
.next
()
?
{
let
name
=
row
.get
(
0
)
?
;
let
subject
=
row
.get
(
1
)
?
;
let
description
=
row
.get
(
2
)
?
;
let
expires_at
=
row
.get
(
3
)
?
;
let
id
=
row
.get
(
0
)
?
;
let
name
=
row
.get
(
1
)
?
;
let
subject
=
row
.get
(
2
)
?
;
let
description
=
row
.get
(
3
)
?
;
let
expires_at
=
row
.get
(
4
)
?
;
tasks
.push
(
Task
{
id
,
name
,
subject
,
description
,
expires_at
});
println!
(
"pushed"
)
}
Ok
(
tasks
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment