Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
d4633e09
Commit
d4633e09
authored
6 years ago
by
Julia Friesel
Committed by
emelko
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Get previous temperature and fill it as placeholder
parent
2f58db84
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
db.js
+13
-7
13 additions, 7 deletions
db.js
temperature.js
+11
-3
11 additions, 3 deletions
temperature.js
with
24 additions
and
10 deletions
db.js
+
13
−
7
View file @
d4633e09
import
realm
from
'
realm
'
import
realm
from
'
realm
'
let
db
let
db
let
bleedingDaysSortedByDate
=
[]
let
cycleDaysSortedbyDate
=
[]
let
cycleDaysSortedbyDate
=
[]
let
bleedingDaysSortedByDate
=
[]
const
TemperatureSchema
=
{
const
TemperatureSchema
=
{
name
:
'
Temperature
'
,
name
:
'
Temperature
'
,
...
@@ -48,11 +47,8 @@ async function openDatabase() {
...
@@ -48,11 +47,8 @@ async function openDatabase() {
deleteRealmIfMigrationNeeded
:
true
deleteRealmIfMigrationNeeded
:
true
})
})
bleedingDaysSortedByDate
=
db
.
objects
(
'
CycleDay
'
).
fil
<<<<<<<
933
b64056a13d04c3bfdebf531962b84d9daa4ce
// just for testing purposes, the highest temperature will be topmost
// because I was too layz to make a scroll view
cycleDaysSortedbyTempValueView
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
temperature != null
'
).
sorted
(
'
temperature.value
'
,
true
)
tered
(
'
bleeding != null
'
).
sorted
(
'
date
'
,
true
)
cycleDaysSortedbyDate
=
db
.
objects
(
'
CycleDay
'
).
sorted
(
'
date
'
,
true
)
cycleDaysSortedbyDate
=
db
.
objects
(
'
CycleDay
'
).
sorted
(
'
date
'
,
true
)
bleedingDaysSortedByDate
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
bleeding != null
'
).
sorted
(
'
date
'
,
true
)
}
}
function
saveTemperature
(
cycleDay
,
temperature
)
{
function
saveTemperature
(
cycleDay
,
temperature
)
{
...
@@ -79,10 +75,20 @@ function getOrCreateCycleDay(localDate) {
...
@@ -79,10 +75,20 @@ function getOrCreateCycleDay(localDate) {
return
result
return
result
}
}
function
getPreviousTemperature
(
cycleDay
)
{
const
cycleDayIndex
=
cycleDaysSortedbyDate
.
findIndex
(
day
=>
day
===
cycleDay
)
const
previousCycleDays
=
cycleDaysSortedbyDate
.
slice
(
cycleDayIndex
+
1
)
const
winner
=
previousCycleDays
.
find
(
cycleDay
=>
cycleDay
.
temperature
)
if
(
!
winner
)
return
null
return
winner
.
temperature
.
value
}
export
{
export
{
cycleDaysSortedbyDate
,
openDatabase
,
openDatabase
,
saveTemperature
,
saveTemperature
,
saveBleeding
,
saveBleeding
,
getOrCreateCycleDay
,
getOrCreateCycleDay
,
bleedingDaysSortedByDate
bleedingDaysSortedByDate
,
getPreviousTemperature
}
}
This diff is collapsed.
Click to expand it.
temperature.js
+
11
−
3
View file @
d4633e09
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
}
from
'
react-native
'
}
from
'
react-native
'
import
styles
from
'
./styles
'
import
styles
from
'
./styles
'
import
{
saveTemperature
}
from
'
./db
'
import
{
saveTemperature
,
getPreviousTemperature
}
from
'
./db
'
import
{
formatDateForViewHeader
}
from
'
./format
'
import
{
formatDateForViewHeader
}
from
'
./format
'
import
getCycleDay
from
'
./get-cycle-day
'
import
getCycleDay
from
'
./get-cycle-day
'
...
@@ -16,10 +16,18 @@ export default class Temp extends Component {
...
@@ -16,10 +16,18 @@ export default class Temp extends Component {
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
const
cycleDay
=
props
.
navigation
.
state
.
params
.
cycleDay
const
cycleDay
=
props
.
navigation
.
state
.
params
.
cycleDay
console
.
log
(
cycleDay
.
temperature
?
cycleDay
.
temperature
.
value
:
''
)
let
initialValue
if
(
cycleDay
.
temperature
)
{
initialValue
=
cycleDay
.
temperature
.
toString
()
}
else
{
const
prevTemp
=
getPreviousTemperature
(
cycleDay
)
initialValue
=
prevTemp
?
prevTemp
.
toString
()
:
''
}
this
.
state
=
{
this
.
state
=
{
cycleDay
,
cycleDay
,
currentValue
:
cycleDay
.
temperature
?
cycleDay
.
temperature
.
value
.
toString
()
:
''
,
currentValue
:
initialValue
,
exclude
:
cycleDay
.
temperature
?
cycleDay
.
temperature
.
exclude
:
false
exclude
:
cycleDay
.
temperature
?
cycleDay
.
temperature
.
exclude
:
false
}
}
}
}
...
...
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