Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2016104120
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ma Suhyeon
2021-05-15 15:22:17 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
537b0450e95f5c3c3d7186c3bc0b4cb47f1155ca
537b0450
1 parent
e10bd551
Implement calendar API
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
src/server/app.go
src/server/data.go
src/server/extraction.go
src/server/app.go
View file @
537b045
...
...
@@ -81,6 +81,7 @@ func NewApp(config Config) *App {
extraction
.
GET
(
"/messages/analyses"
,
app
.
GetMessagesAnalyses
)
extraction
.
GET
(
"/processes"
,
app
.
GetProcesses
)
extraction
.
GET
(
"/alarms"
,
app
.
GetAlarms
)
extraction
.
GET
(
"/schedules"
,
app
.
GetSchedules
)
app
.
echo
.
GET
(
"/graph/:extractions"
,
app
.
GetGraph
)
...
...
src/server/data.go
View file @
537b045
...
...
@@ -306,3 +306,20 @@ func (app *App) GetAlarms(c echo.Context) error {
return
c
.
JSON
(
http
.
StatusOK
,
results
)
}
type
Schedule
struct
{
ID
int
`json:"id" db:"id"`
Name
string
`json:"name" db:"name"`
Begin
time
.
Time
`json:"begin" db:"begin"`
End
time
.
Time
`json:"end" db:"end"`
}
func
(
app
*
App
)
GetSchedules
(
c
echo
.
Context
)
error
{
schedules
:=
[]
Schedule
{}
query
:=
"SELECT * FROM schedules WHERE `extraction_no`=?"
if
err
:=
app
.
db
.
Unsafe
()
.
Select
(
&
schedules
,
query
,
c
.
Param
(
"no"
));
err
!=
nil
{
return
err
}
return
c
.
JSON
(
http
.
StatusOK
,
schedules
)
}
...
...
src/server/extraction.go
View file @
537b045
...
...
@@ -84,11 +84,11 @@ func (app *App) PostExtractions(c echo.Context) error {
}
}
sql
:=
`SELECT
query
:=
`SELECT
a.packagename, a.name, a.version, a.wifiusage, a.cellularusage,
u.lasttimeused, u.totaltimeforeground
FROM AppInfo a JOIN AppUsageYear u ON a.packagename=u.packagename`
rows
,
err
=
db
.
Queryx
(
sql
)
rows
,
err
=
db
.
Queryx
(
query
)
if
err
==
nil
{
for
rows
.
Next
()
{
vals
,
_
:=
rows
.
SliceScan
()
...
...
@@ -121,13 +121,23 @@ func (app *App) PostExtractions(c echo.Context) error {
rows
,
err
=
db
.
Queryx
(
"SELECT PID, UID, PPID, STIME, TIME, CMD FROM process"
)
if
err
==
nil
{
for
rows
.
Next
()
{
vals
,
_
:=
rows
.
SliceScan
()
tx
.
Exec
(
"INSERT INTO processes VALUES (?, ?, ?, ?, ?, ?, ?)"
,
append
([]
interface
{}{
extNo
},
vals
...
)
...
)
}
}
query
=
"SELECT `id`, `calendar_id`, `dtstart`, `dtend` FROM calendar "
+
"WHERE `calendar_id` != '' "
+
"AND owner_name NOT IN ('local', 'ko.south_korea#holiday@group.v.calendar.google.com')"
rows
,
err
=
db
.
Queryx
(
query
)
if
err
==
nil
{
for
rows
.
Next
()
{
vals
,
_
:=
rows
.
SliceScan
()
tx
.
Exec
(
"INSERT INTO schedules VALUES (?, ?, ?, ?, ?)"
,
append
([]
interface
{}{
extNo
},
vals
...
)
...
)
}
}
/*alarms := map[string]Alarm{}
rows, _ = db.Queryx("SELECT * FROM alarm ORDER BY TIME")
...
...
Please
register
or
login
to post a comment