-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P95 #1008
Draft
k2xl
wants to merge
9
commits into
main
Choose a base branch
from
p95
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
P95 #1008
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
072ba20
wip
k2xl 5b305b8
speed up calcPlayAttempts and also calc p95s
k2xl 661ebee
forgot to commit
k2xl 0424893
Merge branch 'main' into p95
sspenst dc0a98c
merge
sspenst f9b7938
Merge branch 'main' into p95
k2xl 8049a19
should group by user first then do the p95
k2xl 5a34345
tests
k2xl f1e9604
merge
sspenst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import Level from '@root/models/db/level'; | ||
import React, { useState } from 'react'; | ||
import AsyncSelect from 'react-select/async'; | ||
import { debounce } from 'throttle-debounce'; | ||
|
||
interface MultiSelectLevelProps { | ||
controlStyles?: any; | ||
defaultValue?: Level | null; | ||
onSelect?: (selectedList: any, selectedItem: any) => void; | ||
placeholder?: string | ||
} | ||
|
||
export default function MultiSelectLevel({ controlStyles, defaultValue, onSelect, placeholder }: MultiSelectLevelProps) { | ||
const [options, setOptions] = useState([]); | ||
const [value, setValue] = useState(defaultValue); | ||
|
||
const doSearch = async (searchText: any, callback: any) => { | ||
const search = encodeURI(searchText) || ''; | ||
|
||
const res = await fetch('/api/search?search=' + search, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
} | ||
}); | ||
|
||
const data = await res.json(); | ||
|
||
setOptions(data?.levels); | ||
callback(data?.levels); | ||
}; | ||
const debounceDoSearch = debounce(500, doSearch); | ||
|
||
return <AsyncSelect | ||
backspaceRemovesValue={true} | ||
className='text-left text-base' | ||
components={{ | ||
DropdownIndicator: null, | ||
IndicatorSeparator: null, | ||
}} | ||
formatOptionLabel={(option: any) => ( | ||
<>{option.name}</> | ||
)} | ||
getOptionLabel={(option: any) => option.name} | ||
getOptionValue={(option: any) => option._id.toString()} | ||
id='search-author-input-async-select' | ||
instanceId='search-author-input-async-select' | ||
isClearable={true} | ||
loadOptions={debounceDoSearch} | ||
noOptionsMessage={() => 'No levels found'} | ||
onChange={(selectedOption: any, selectedAction: any) => { | ||
setValue(selectedOption); | ||
|
||
if (!selectedAction) { | ||
return; | ||
} | ||
|
||
if (onSelect) { | ||
if (selectedAction.action === 'clear') { | ||
onSelect('', selectedAction); | ||
} else { | ||
onSelect(selectedOption, selectedAction); | ||
} | ||
} | ||
}} | ||
options={options} // Options to display in the dropdown | ||
placeholder={placeholder ? placeholder : 'Search levels...'} | ||
// https://react-select.com/styles | ||
styles={{ | ||
control: (provided: any, state: any) => ({ | ||
...provided, | ||
backgroundColor: 'white', | ||
borderColor: state.isFocused ? 'rgb(37 99 235)' : 'rgb(209 213 219)', | ||
borderRadius: '0.375rem', | ||
borderWidth: '1px', | ||
boxShadow: 'none', | ||
cursor: 'text', | ||
height: '2.5rem', | ||
width: '13rem', | ||
...controlStyles, | ||
}), | ||
dropdownIndicator: (provided: any) => ({ | ||
...provided, | ||
color: 'black', | ||
// change to search icon | ||
'&:hover': { | ||
color: 'gray', | ||
}, | ||
}), | ||
input: (provided: any) => ({ | ||
...provided, | ||
color: 'rgb(55 65 81)', | ||
}), | ||
menu: (provided: any) => ({ | ||
...provided, | ||
borderColor: 'rgb(209 213 219)', | ||
borderRadius: '0.375rem', | ||
borderWidth: '1px', | ||
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)', | ||
marginTop: '2px', | ||
}), | ||
option: (provided: any, state: any) => ({ | ||
...provided, | ||
backgroundColor: state.isSelected ? '#e2e8f0' : 'white', | ||
color: 'black', | ||
'&:hover': { | ||
backgroundColor: '#e2e8f0', | ||
}, | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
whiteSpace: 'nowrap', | ||
}), | ||
placeholder: (provided: any) => ({ | ||
...provided, | ||
color: 'rgb(156 163 175)', | ||
}), | ||
singleValue: (provided: any) => ({ | ||
...provided, | ||
color: 'black', | ||
}), | ||
}} | ||
value={value} | ||
/>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we combine
sumDuration
andsumDurationP95
? Should have all the data forsumDuration
at this pointThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually i realized when trying to do this that this is risky and not actually as straightforward since i do a bunch of groups. probably safer for now to keep it separate