FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
frontend/article/app/model/KeyEventData.scala at master · devhttps/frontend · GitHub
devhttps
/
frontend
Public
forked from
guardian/frontend
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
frontend
/
article
/
app
/
model
/
KeyEventData.scala
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (21 loc) · 1.1 KB
Breadcrumbs
frontend
/
article
/
app
/
model
/
KeyEventData.scala
Copy path
File metadata and controls
31 lines (21 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package
model
import
model
.
liveblog
.
BodyBlock
.{
KeyEvent
,
SummaryEvent
}
import
model
.
liveblog
.{
Blocks
,
BodyBlock
,
LiveBlogDate
}
import
com
.
github
.
nscala_time
.
time
.
Imports
.
_
object
KeyEventData
{
//
just for convenience for use from the templates
def
apply
(
maybeBlocks
:
Option
[
Blocks
],
timezone
:
DateTimeZone
)
:
Seq
[
KeyEventData
]
=
{
val
blocks
=
maybeBlocks.toSeq.flatMap(blocks
=>
blocks.requestedBodyBlocks.getOrElse(
Canonical
.timeline, blocks.body))
apply(blocks, timezone)
}
def
apply
(
blocks
:
Seq
[
BodyBlock
],
timezone
:
DateTimeZone
)
:
Seq
[
KeyEventData
]
=
{
val
TimelineMaxEntries
=
7
val
latestSummary
=
blocks.find(_.eventType
==
SummaryEvent
)
val
keyEvents
=
blocks.filter(_.eventType
==
KeyEvent
)
val
bodyBlocks
=
(latestSummary.toSeq
++
keyEvents).sortBy(_.lastModifiedDate.getOrElse(
new
DateTime
(
0
)).toInstant.getMillis).reverse.take(
TimelineMaxEntries
)
bodyBlocks.map { bodyBlock
=>
KeyEventData
(bodyBlock.id, bodyBlock.publishedCreatedDate(timezone), bodyBlock.title)
}
}
}
case
class
KeyEventData
(
id
:
String
,
time
:
Option
[
LiveBlogDate
],
title
:
Option
[
String
])
Back
|
FazBrowse Home
|
New Git URL