FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Ackee/src/database/browsers.js at develop · electerious/Ackee · GitHub
electerious
/
Ackee
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
386
Star
4.7k
Code
Issues
33
Pull requests
5
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
Ackee
/
src
/
database
/
browsers.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (39 loc) · 1.89 KB
Breadcrumbs
Ackee
/
src
/
database
/
browsers.js
Copy path
File metadata and controls
45 lines (39 loc) · 1.89 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import
aggregateNewRecords
from
'../aggregations/aggregateNewRecords.js'
import
aggregateRecentRecords
from
'../aggregations/aggregateRecentRecords.js'
import
aggregateTopRecords
from
'../aggregations/aggregateTopRecords.js'
import
{
BROWSERS_TYPE_NO_VERSION
,
BROWSERS_TYPE_WITH_VERSION
}
from
'../constants/browsers.js'
import
{
SORTINGS_NEW
,
SORTINGS_RECENT
,
SORTINGS_TOP
}
from
'../constants/sortings.js'
import
Record
from
'../models/Record.js'
import
recursiveId
from
'../utils/recursiveId.js'
const
get
=
async
(
ids
,
sorting
,
type
,
range
,
limit
,
dateDetails
)
=>
{
const
aggregation
=
(
(
)
=>
{
if
(
type
===
BROWSERS_TYPE_NO_VERSION
)
{
if
(
sorting
===
SORTINGS_TOP
)
return
aggregateTopRecords
(
ids
,
[
'browserName'
]
,
range
,
limit
,
dateDetails
)
if
(
sorting
===
SORTINGS_NEW
)
return
aggregateNewRecords
(
ids
,
[
'browserName'
]
,
limit
)
if
(
sorting
===
SORTINGS_RECENT
)
return
aggregateRecentRecords
(
ids
,
[
'browserName'
]
,
limit
)
}
if
(
type
===
BROWSERS_TYPE_WITH_VERSION
)
{
if
(
sorting
===
SORTINGS_TOP
)
return
aggregateTopRecords
(
ids
,
[
'browserName'
,
'browserVersion'
]
,
range
,
limit
,
dateDetails
)
if
(
sorting
===
SORTINGS_NEW
)
return
aggregateNewRecords
(
ids
,
[
'browserName'
,
'browserVersion'
]
,
limit
)
if
(
sorting
===
SORTINGS_RECENT
)
return
aggregateRecentRecords
(
ids
,
[
'browserName'
,
'browserVersion'
]
,
limit
)
}
}
)
(
)
const
enhanceId
=
(
id
)
=>
{
if
(
type
===
BROWSERS_TYPE_NO_VERSION
)
return
`
${
id
.
browserName
}
`
if
(
type
===
BROWSERS_TYPE_WITH_VERSION
)
return
`
${
id
.
browserName
}
${
id
.
browserVersion
}
`
}
const
enhance
=
(
entries
)
=>
{
return
entries
.
map
(
(
entry
)
=>
{
const
value
=
enhanceId
(
entry
.
_id
)
return
{
id
:
recursiveId
(
[
value
,
sorting
,
type
,
range
,
...
ids
]
)
,
value
,
count
:
entry
.
count
,
created
:
entry
.
created
,
}
}
)
}
return
enhance
(
await
Record
.
aggregate
(
aggregation
)
)
}
export
default
get
Back
|
FazBrowse Home
|
New Git URL