Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
radegast
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jan Hrabal
radegast
Commits
0c445d9c
Commit
0c445d9c
authored
Jul 08, 2019
by
jhrabal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
aad7e508
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
129 additions
and
31 deletions
+129
-31
RatingApiController.java
.../src/main/java/com/jh/rateit/api/RatingApiController.java
+19
-0
Rating.java
backend/src/main/java/com/jh/rateit/model/Rating.java
+43
-0
RatingRepository.java
.../src/main/java/com/jh/rateit/rating/RatingRepository.java
+10
-0
RatingService.java
...end/src/main/java/com/jh/rateit/rating/RatingService.java
+1
-1
pom.properties
...get/classes/META-INF/maven/com.jh/redegast/pom.properties
+1
-1
Rating.class
backend/target/classes/com/jh/rateit/model/Rating.class
+0
-0
RatingRepository.class
...arget/classes/com/jh/rateit/rating/RatingRepository.class
+0
-0
RatingService.class
...d/target/classes/com/jh/rateit/rating/RatingService.class
+0
-0
App.js
mobile/App.js
+55
-29
No files found.
backend/src/main/java/com/jh/rateit/api/RatingApiController.java
0 → 100644
View file @
0c445d9c
package
com
.
jh
.
rateit
.
api
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
@Controller
@RequestMapping
(
"/api"
)
public
class
RatingApiController
{
@RequestMapping
(
path
=
"ratings"
,
method
=
RequestMethod
.
POST
)
@ResponseStatus
(
HttpStatus
.
CREATED
)
public
void
bulkRating
()
{
}
}
backend/src/main/java/com/jh/rateit/model/Rating.java
View file @
0c445d9c
...
...
@@ -2,19 +2,62 @@ package com.jh.rateit.model;
import
java.util.Date
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
com.jh.common.jpa.AbstractIdEntity
;
@Entity
@Table
(
name
=
"RATING"
)
public
class
Rating
extends
AbstractIdEntity
{
@Column
(
name
=
"DEVICE_ID"
)
private
String
deviceId
;
@Column
(
name
=
"CREATED"
)
private
Date
created
;
@Column
(
name
=
"RATING"
)
private
Integer
rating
;
@Transient
private
Section
section
;
public
Rating
()
{
}
public
String
getDeviceId
()
{
return
deviceId
;
}
public
void
setDeviceId
(
String
deviceId
)
{
this
.
deviceId
=
deviceId
;
}
public
Date
getCreated
()
{
return
created
;
}
public
void
setCreated
(
Date
created
)
{
this
.
created
=
created
;
}
public
Integer
getRating
()
{
return
rating
;
}
public
void
setRating
(
Integer
rating
)
{
this
.
rating
=
rating
;
}
public
Section
getSection
()
{
return
section
;
}
public
void
setSection
(
Section
section
)
{
this
.
section
=
section
;
}
}
backend/src/main/java/com/jh/rateit/rating/RatingRepository.java
View file @
0c445d9c
package
com
.
jh
.
rateit
.
rating
;
import
java.util.Collection
;
import
org.hibernate.Session
;
import
org.springframework.stereotype.Repository
;
import
com.jh.common.jpa.AbstractHibernateRepository
;
import
com.jh.rateit.model.Rating
;
@Repository
public
class
RatingRepository
extends
AbstractHibernateRepository
{
public
void
saveBulk
(
Collection
<
Rating
>
ratings
)
{
Session
session
=
getSession
();
//TODO implement properly
}
}
backend/src/main/java/com/jh/rateit/rating/RatingService.java
View file @
0c445d9c
...
...
@@ -17,7 +17,7 @@ public class RatingService {
@Transactional
public
void
saveBulk
(
Collection
<
Rating
>
ratings
)
{
repo
.
saveBulk
(
ratings
);
}
}
backend/target/classes/META-INF/maven/com.jh/redegast/pom.properties
View file @
0c445d9c
#Generated by Maven Integration for Eclipse
#
Sat Jun 29 08:55:48
CEST 2019
#
Mon Jul 08 09:32:30
CEST 2019
version
=
0.0.1
groupId
=
com.jh
m2e.projectName
=
radegast
...
...
backend/target/classes/com/jh/rateit/model/Rating.class
View file @
0c445d9c
No preview for this file type
backend/target/classes/com/jh/rateit/rating/RatingRepository.class
View file @
0c445d9c
No preview for this file type
backend/target/classes/com/jh/rateit/rating/RatingService.class
View file @
0c445d9c
No preview for this file type
mobile/App.js
View file @
0c445d9c
...
...
@@ -2,24 +2,10 @@ import React from 'react';
import
{
StyleSheet
,
Text
,
View
,
TouchableOpacity
,
AsyncStorage
,
Alert
,
StatusBar
}
from
'react-native'
;
const
sendData
=
async
()
=>
{
try
{
let
response
=
await
fetch
(
'https://radegast.janhrabal.com'
,
{
method
:
"POST"
});
let
responseJson
=
await
response
.
json
();
return
responseJson
.
movies
;
}
catch
(
error
)
{
console
.
error
(
error
);
}
}
const
SEND_DATA_TIMER
=
10000
;
const
INFO_TIMER
=
1500
;
const
storeRating
=
async
(
rating
)
=>
{
let
key
=
new
Date
().
getTime
();
await
AsyncStorage
.
setItem
(
JSON
.
stringify
(
key
),
JSON
.
stringify
({
rating
}));
}
class
App
extends
React
.
PureComponent
{
...
...
@@ -29,16 +15,54 @@ class App extends React.PureComponent {
this
.
state
=
{
mode
:
'rating'
,
stats
:
{},
statsLoading
:
false
statsLoading
:
false
,
buffer
:
[]
};
this
.
sendData
=
this
.
sendData
.
bind
(
this
);
this
.
onPress
=
this
.
onPress
.
bind
(
this
);
}
componentDidMount
()
{
//this.timer = setInterval(sendData, 10000
);
this
.
timer
=
setTimeout
(
this
.
sendData
,
SEND_DATA_TIMER
);
}
componentWillUnmount
()
{
//clearInterval(this.timer);
if
(
this
.
timer
)
{
clearTimeout
(
this
.
timer
);
}
}
async
sendData
()
{
let
{
buffer
}
=
this
.
state
;
let
body
=
[];
//prepare body
while
(
buffer
.
length
)
{
body
.
push
(
buffer
.
shift
());
}
try
{
let
response
=
await
fetch
(
'https://radegast.janhrabal.com/api/ratings/bulk'
,
{
method
:
"POST"
,
body
:
JSON
.
stringify
(
body
)
});
let
responseJson
=
await
response
.
json
();
return
responseJson
.
movies
;
}
catch
(
error
)
{
//console.error(error);
// return to buffer
while
(
body
.
length
)
{
buffer
.
push
(
body
.
shift
());
}
}
//set other timeout
this
.
timer
=
setTimeout
(
this
.
sendData
,
SEND_DATA_TIMER
);
}
...
...
@@ -64,18 +88,20 @@ class App extends React.PureComponent {
}
onPress
(
r
ating
)
{
onPress
(
r
)
{
return
async
()
=>
{
let
{
buffer
}
=
this
.
state
;
let
key
=
new
Date
().
getTime
();
let
rating
=
{
rating
:
r
,
key
};
try
{
this
.
setState
({
mode
:
"info"
});
await
storeRating
(
rating
);
setTimeout
(()
=>
this
.
setState
({
mode
:
"rating"
}),
2000
);
await
AsyncStorage
.
setItem
(
JSON
.
stringify
(
key
),
JSON
.
stringify
(
rating
));
// TODO
let
keys
=
await
AsyncStorage
.
getAllKeys
();
let
s
=
keys
.
join
(
",
\
n"
);
//add to buffer
buffer
.
push
(
rating
);
Alert
.
alert
(
"stats"
,
s
);
setTimeout
(()
=>
this
.
setState
({
mode
:
"rating"
}),
INFO_TIMER
);
}
catch
(
e
)
{
console
.
error
(
e
);
...
...
@@ -86,12 +112,12 @@ class App extends React.PureComponent {
renderResults
()
{
return
null
;
return
<
View
><
/View
>
}
renderInfo
()
{
return
<
Text
>
XXX
<
/Text>
;
return
<
View
><
Text
>
D
ě
kujeme
za
hodnocen
í
<
/Text></
View
>
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment