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
6bb6cc11
Commit
6bb6cc11
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Save date as local date string and make it the primary key
parent
80bf63ad
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bleeding.js
+0
-1
0 additions, 1 deletion
bleeding.js
calendar.js
+2
-5
2 additions, 5 deletions
calendar.js
db.js
+5
-11
5 additions, 11 deletions
db.js
with
7 additions
and
17 deletions
bleeding.js
+
0
−
1
View file @
6bb6cc11
...
@@ -11,7 +11,6 @@ import { saveBleeding } from './db'
...
@@ -11,7 +11,6 @@ import { saveBleeding } from './db'
import
{
formatDateForViewHeader
}
from
'
./format
'
import
{
formatDateForViewHeader
}
from
'
./format
'
import
{
bleeding
as
labels
}
from
'
./labels
'
import
{
bleeding
as
labels
}
from
'
./labels
'
import
getCycleDay
from
'
./get-cycle-day
'
import
getCycleDay
from
'
./get-cycle-day
'
import
{
bleedingDaysSortedByDate
}
from
'
./db
'
export
default
class
Bleeding
extends
Component
{
export
default
class
Bleeding
extends
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
...
...
This diff is collapsed.
Click to expand it.
calendar.js
+
2
−
5
View file @
6bb6cc11
...
@@ -16,9 +16,7 @@ export default class DatePickView extends Component {
...
@@ -16,9 +16,7 @@ export default class DatePickView extends Component {
}
}
passDateToDayView
(
result
)
{
passDateToDayView
(
result
)
{
// TODO this also has date as a string, perhaps useful for LocalDateFormat
const
cycleDay
=
getOrCreateCycleDay
(
result
.
dateString
)
const
date
=
new
Date
(
result
.
year
,
result
.
month
-
1
,
result
.
day
)
const
cycleDay
=
getOrCreateCycleDay
(
date
)
const
navigate
=
this
.
props
.
navigation
.
navigate
const
navigate
=
this
.
props
.
navigation
.
navigate
navigate
(
'
dayView
'
,
{
cycleDay
})
navigate
(
'
dayView
'
,
{
cycleDay
})
}
}
...
@@ -39,8 +37,7 @@ export default class DatePickView extends Component {
...
@@ -39,8 +37,7 @@ export default class DatePickView extends Component {
function
getBleedingDaysInCalFormat
(
bleedingDaysSortedByDate
)
{
function
getBleedingDaysInCalFormat
(
bleedingDaysSortedByDate
)
{
const
shadesOfRed
=
[
'
#ffbaba
'
,
'
#ff7b7b
'
,
'
#ff5252
'
,
'
#ff0000
'
]
const
shadesOfRed
=
[
'
#ffbaba
'
,
'
#ff7b7b
'
,
'
#ff5252
'
,
'
#ff0000
'
]
return
bleedingDaysSortedByDate
.
reduce
((
acc
,
day
)
=>
{
return
bleedingDaysSortedByDate
.
reduce
((
acc
,
day
)
=>
{
const
dateString
=
day
.
date
.
toISOString
().
slice
(
0
,
10
)
acc
[
day
.
date
]
=
{
startingDay
:
true
,
endingDay
:
true
,
color
:
shadesOfRed
[
day
.
bleeding
.
value
]
}
acc
[
dateString
]
=
{
startingDay
:
true
,
endingDay
:
true
,
color
:
shadesOfRed
[
day
.
bleeding
.
value
]
}
return
acc
return
acc
},
{})
},
{})
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
db.js
+
5
−
11
View file @
6bb6cc11
import
realm
from
'
realm
'
import
realm
from
'
realm
'
import
{
v4
as
uuid
}
from
'
uuid
'
let
db
let
db
let
cycleDaysSortedbyTempValueView
=
[]
let
cycleDaysSortedbyTempValueView
=
[]
let
cycleDaysSortedbyDate
=
[]
let
bleedingDaysSortedByDate
=
[]
let
bleedingDaysSortedByDate
=
[]
const
TemperatureSchema
=
{
const
TemperatureSchema
=
{
...
@@ -24,10 +22,9 @@ const BleedingSchema = {
...
@@ -24,10 +22,9 @@ const BleedingSchema = {
const
CycleDaySchema
=
{
const
CycleDaySchema
=
{
name
:
'
CycleDay
'
,
name
:
'
CycleDay
'
,
primaryKey
:
'
key
'
,
primaryKey
:
'
date
'
,
properties
:
{
properties
:
{
key
:
'
string
'
,
date
:
'
string
'
,
date
:
'
date
'
,
temperature
:
{
temperature
:
{
type
:
'
Temperature
'
,
type
:
'
Temperature
'
,
optional
:
true
optional
:
true
...
@@ -52,14 +49,12 @@ async function openDatabase() {
...
@@ -52,14 +49,12 @@ async function openDatabase() {
// just for testing purposes, the highest temperature will be topmost
// just for testing purposes, the highest temperature will be topmost
// because I was too layz to make a scroll view
// because I was too layz to make a scroll view
cycleDaysSortedbyTempValueView
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
temperature != null
'
).
sorted
(
'
temperature.value
'
,
true
)
cycleDaysSortedbyTempValueView
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
temperature != null
'
).
sorted
(
'
temperature.value
'
,
true
)
cycleDaysSortedbyDate
=
db
.
objects
(
'
CycleDay
'
).
sorted
(
'
date
'
,
true
)
bleedingDaysSortedByDate
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
bleeding != null
'
).
sorted
(
'
date
'
,
true
)
bleedingDaysSortedByDate
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
bleeding != null
'
).
sorted
(
'
date
'
,
true
)
}
}
function
saveTemperature
(
date
,
temperature
)
{
function
saveTemperature
(
date
,
temperature
)
{
db
.
write
(()
=>
{
db
.
write
(()
=>
{
const
doc
=
{
const
doc
=
{
key
:
uuid
(),
date
,
date
,
temperature
temperature
}
}
...
@@ -73,13 +68,12 @@ function saveBleeding(cycleDay, bleeding) {
...
@@ -73,13 +68,12 @@ function saveBleeding(cycleDay, bleeding) {
})
})
}
}
function
getOrCreateCycleDay
(
d
ate
)
{
function
getOrCreateCycleDay
(
localD
ate
)
{
let
result
=
Array
.
from
(
cycleDaysSortedbyDate
.
filtered
(
'
date = $0
'
,
date
))[
0
]
let
result
=
db
.
objectForPrimaryKey
(
'
CycleDay
'
,
localDate
)
if
(
!
result
)
{
if
(
!
result
)
{
db
.
write
(()
=>
{
db
.
write
(()
=>
{
result
=
db
.
create
(
'
CycleDay
'
,
{
result
=
db
.
create
(
'
CycleDay
'
,
{
key
:
uuid
(),
date
:
localDate
date
})
})
})
})
}
}
...
...
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