FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Ackee/src/database/sizes.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
/
sizes.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
77 lines (71 loc) · 3.82 KB
Breadcrumbs
Ackee
/
src
/
database
/
sizes.js
Copy path
File metadata and controls
77 lines (71 loc) · 3.82 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import
aggregateNewRecords
from
'../aggregations/aggregateNewRecords.js'
import
aggregateRecentRecords
from
'../aggregations/aggregateRecentRecords.js'
import
aggregateTopRecords
from
'../aggregations/aggregateTopRecords.js'
import
{
SIZES_TYPE_BROWSER_HEIGHT
,
SIZES_TYPE_BROWSER_RESOLUTION
,
SIZES_TYPE_BROWSER_WIDTH
,
SIZES_TYPE_SCREEN_HEIGHT
,
SIZES_TYPE_SCREEN_RESOLUTION
,
SIZES_TYPE_SCREEN_WIDTH
,
}
from
'../constants/sizes.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
(
sorting
===
SORTINGS_TOP
)
{
if
(
type
===
SIZES_TYPE_BROWSER_WIDTH
)
return
aggregateTopRecords
(
ids
,
[
'browserWidth'
]
,
range
,
limit
,
dateDetails
)
if
(
type
===
SIZES_TYPE_BROWSER_HEIGHT
)
return
aggregateTopRecords
(
ids
,
[
'browserHeight'
]
,
range
,
limit
,
dateDetails
)
if
(
type
===
SIZES_TYPE_BROWSER_RESOLUTION
)
return
aggregateTopRecords
(
ids
,
[
'browserWidth'
,
'browserHeight'
]
,
range
,
limit
,
dateDetails
)
if
(
type
===
SIZES_TYPE_SCREEN_WIDTH
)
return
aggregateTopRecords
(
ids
,
[
'screenWidth'
]
,
range
,
limit
,
dateDetails
)
if
(
type
===
SIZES_TYPE_SCREEN_HEIGHT
)
return
aggregateTopRecords
(
ids
,
[
'screenHeight'
]
,
range
,
limit
,
dateDetails
)
if
(
type
===
SIZES_TYPE_SCREEN_RESOLUTION
)
return
aggregateTopRecords
(
ids
,
[
'screenWidth'
,
'screenHeight'
]
,
range
,
limit
,
dateDetails
)
}
if
(
sorting
===
SORTINGS_NEW
)
{
if
(
type
===
SIZES_TYPE_BROWSER_WIDTH
)
return
aggregateNewRecords
(
ids
,
[
'browserWidth'
]
,
limit
)
if
(
type
===
SIZES_TYPE_BROWSER_HEIGHT
)
return
aggregateNewRecords
(
ids
,
[
'browserHeight'
]
,
limit
)
if
(
type
===
SIZES_TYPE_BROWSER_RESOLUTION
)
return
aggregateNewRecords
(
ids
,
[
'browserWidth'
,
'browserHeight'
]
,
limit
)
if
(
type
===
SIZES_TYPE_SCREEN_WIDTH
)
return
aggregateNewRecords
(
ids
,
[
'screenWidth'
]
,
limit
)
if
(
type
===
SIZES_TYPE_SCREEN_HEIGHT
)
return
aggregateNewRecords
(
ids
,
[
'screenHeight'
]
,
limit
)
if
(
type
===
SIZES_TYPE_SCREEN_RESOLUTION
)
return
aggregateNewRecords
(
ids
,
[
'screenWidth'
,
'screenHeight'
]
,
limit
)
}
if
(
sorting
===
SORTINGS_RECENT
)
{
if
(
type
===
SIZES_TYPE_BROWSER_WIDTH
)
return
aggregateRecentRecords
(
ids
,
[
'browserWidth'
]
,
limit
)
if
(
type
===
SIZES_TYPE_BROWSER_HEIGHT
)
return
aggregateRecentRecords
(
ids
,
[
'browserHeight'
]
,
limit
)
if
(
type
===
SIZES_TYPE_BROWSER_RESOLUTION
)
return
aggregateRecentRecords
(
ids
,
[
'browserWidth'
,
'browserHeight'
]
,
limit
)
if
(
type
===
SIZES_TYPE_SCREEN_WIDTH
)
return
aggregateRecentRecords
(
ids
,
[
'screenWidth'
]
,
limit
)
if
(
type
===
SIZES_TYPE_SCREEN_HEIGHT
)
return
aggregateRecentRecords
(
ids
,
[
'screenHeight'
]
,
limit
)
if
(
type
===
SIZES_TYPE_SCREEN_RESOLUTION
)
return
aggregateRecentRecords
(
ids
,
[
'screenWidth'
,
'screenHeight'
]
,
limit
)
}
}
)
(
)
const
enhanceId
=
(
id
)
=>
{
if
(
type
===
SIZES_TYPE_BROWSER_WIDTH
)
return
`
${
id
.
browserWidth
}
px`
if
(
type
===
SIZES_TYPE_BROWSER_HEIGHT
)
return
`
${
id
.
browserHeight
}
px`
if
(
type
===
SIZES_TYPE_BROWSER_RESOLUTION
)
return
`
${
id
.
browserWidth
}
px x
${
id
.
browserHeight
}
px`
if
(
type
===
SIZES_TYPE_SCREEN_WIDTH
)
return
`
${
id
.
screenWidth
}
px`
if
(
type
===
SIZES_TYPE_SCREEN_HEIGHT
)
return
`
${
id
.
screenHeight
}
px`
if
(
type
===
SIZES_TYPE_SCREEN_RESOLUTION
)
return
`
${
id
.
screenWidth
}
px x
${
id
.
screenHeight
}
px`
}
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