Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
highlander-ticketing-go-ss2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yannick Ege
highlander-ticketing-go-ss2023
Commits
16f6ce92
Commit
16f6ce92
authored
Jul 10, 2023
by
Yege1893
Browse files
Options
Downloads
Patches
Plain Diff
fixed match api
parent
0bcbbc0f
No related branches found
No related tags found
1 merge request
!4
Master
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/highlanderticketing/api/match.go
+13
-9
13 additions, 9 deletions
src/highlanderticketing/api/match.go
src/highlanderticketing/main.go
+1
-1
1 addition, 1 deletion
src/highlanderticketing/main.go
with
14 additions
and
10 deletions
src/highlanderticketing/api/match.go
+
13
−
9
View file @
16f6ce92
...
...
@@ -10,14 +10,14 @@ import (
"gitlab.reutlingen-university.de/ege/highlander-ticketing-go-ss2023/src/highlanderticketing/model"
)
func
GetMatchesOfApi
(
apiUrl
string
)
(
error
,
[]
*
model
.
Match
)
{
func
GetMatchesOfApi
(
apiUrl
string
)
([]
*
model
.
Match
,
error
)
{
data
:=
getData
(
apiUrl
)
err
,
matches
:=
formatJsonCreateMatch
(
data
)
matches
,
err
:=
formatJsonCreateMatch
(
data
)
if
err
!=
nil
{
return
err
,
make
(
[]
*
model
.
Match
,
0
)
return
[]
*
model
.
Match
{},
err
}
fmt
.
Println
(
matches
)
return
nil
,
matches
return
matches
,
nil
}
func
getData
(
apiUrl
string
)
[]
byte
{
...
...
@@ -43,19 +43,22 @@ func getData(apiUrl string) []byte {
return
responseBody
}
func
formatJsonCreateMatch
(
jsonArray
[]
byte
)
(
error
,
[]
*
model
.
Match
)
{
var
match
model
.
Match
func
formatJsonCreateMatch
(
jsonArray
[]
byte
)
([]
*
model
.
Match
,
error
)
{
var
matches
[]
*
model
.
Match
var
results
[]
map
[
string
]
interface
{}
json
.
Unmarshal
([]
byte
(
jsonArray
),
&
results
)
if
err
:=
json
.
Unmarshal
(
jsonArray
,
&
results
);
err
!=
nil
{
return
nil
,
err
}
for
_
,
result
:=
range
results
{
var
match
model
.
Match
match
.
ExternalID
=
int64
(
result
[
"matchID"
]
.
(
float64
))
match
.
LeagueName
=
result
[
"leagueName"
]
.
(
string
)
matchDate
,
err
:=
time
.
Parse
(
"2006-01-02T15:04:05"
,
result
[
"matchDateTime"
]
.
(
string
))
if
err
!=
nil
{
return
err
,
matches
return
nil
,
err
}
match
.
Date
=
matchDate
...
...
@@ -72,6 +75,7 @@ func formatJsonCreateMatch(jsonArray []byte) (error, []*model.Match) {
}
}
}
if
team2
,
ok
:=
result
[
"team2"
]
.
(
map
[
string
]
interface
{});
ok
{
if
name
,
ok
:=
team2
[
"teamName"
]
.
(
string
);
ok
{
if
name
==
"VfB Stuttgart"
{
...
...
@@ -84,5 +88,5 @@ func formatJsonCreateMatch(jsonArray []byte) (error, []*model.Match) {
}
matches
=
append
(
matches
,
&
match
)
}
return
nil
,
matches
return
matches
,
nil
}
This diff is collapsed.
Click to expand it.
src/highlanderticketing/main.go
+
1
−
1
View file @
16f6ce92
...
...
@@ -21,7 +21,7 @@ func main() {
fmt.Println(userArray)
*/
service
.
DeleteAllMatches
()
errM
atches
,
m
atches
:=
api
.
GetMatchesOfApi
(
"https://api.openligadb.de/getmatchesbyteamid/16/10/0"
)
m
atches
,
errM
atches
:=
api
.
GetMatchesOfApi
(
"https://api.openligadb.de/getmatchesbyteamid/16/10/0"
)
if
errMatches
!=
nil
{
return
}
...
...
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