-
Notifications
You must be signed in to change notification settings - Fork 90
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
display the total daily gaps percantage #57
Conversation
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.
src/pages/GapsPage.tsx
Outdated
switch (true) { | ||
case gapsPrecentage === 0: | ||
return ( | ||
<TitleCellPrecentage style={{ color: '#097d09' }}> |
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.
colors can be moved to constants to improve readability and consistency
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.
No problem, I can also add css classes for these colors, so we could use them in other elements if needed. Name of the classes: "great-result" (for green), "average-result" (for yellow), "terrible-result" (for red)
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.
even better!
src/pages/GapsPage.tsx
Outdated
.then(setGaps) | ||
.then((gaps) => { | ||
setGaps(gaps) | ||
const ridesInTime = gaps?.filter((gap) => formatStatus([], gap) === TEXTS.ride_as_planned) |
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.
Let's keep the formatting separated from logic. In the future, the formatting function may wrap the text and apply various modifications, so we probably don't want it to be coupled with this filter
src/pages/GapsPage.tsx
Outdated
|
||
const GapsPage = () => { | ||
const { search, setSearch } = useContext(SearchContext) | ||
const { operatorId, lineNumber, timestamp, routes, routeKey } = search | ||
const [gaps, setGaps] = useState<GapsList>() | ||
const [gapsPrecentage, setGapsPrecentage] = useState<number>() |
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.
please try to keep as few state variables as possible
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.
@NoamGaash I implemented the suggestions. Please, review them again. |
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.
overall, it looks great,
but I think we should reconsider the hard-coded thresholds in you files
what do you think?
src/resources/variables.scss
Outdated
$great-result: #097d09; | ||
$average-result: #b4b407; | ||
$terrible-result: #b90a0a; |
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.
I love these namings!
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.
Thanks
let status = '' | ||
switch (true) { | ||
case gapsPrecentage === 0: | ||
status = 'great' | ||
break | ||
case gapsPrecentage < 20: | ||
status = 'average' | ||
break | ||
case gapsPrecentage >= 20: | ||
status = 'terrible' | ||
break | ||
} |
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.
are you sure about the numbers?
if the gap percentage is 1/10,000, will you consider it "average"?
also, let's try something cleaner
for example -
const statuses = [
{
min: -Infinity,
status: "invalid"
},
{
min: 0,
status: "great"
},
{
min: 10,
status: "average"
},
{
min: 20,
status: "terrible"
},
{
min: 101,
status: "invalid"
},
]
function getStatus(percentage) {
return statuses.findLast(status => status.min < percentage).status
}
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.
This also relates to my coloring method in the new "gaps patterns page", and I think we should be consistent with our coloring \ terms. So maybe, even something like that could be better and used by both pages:
const statuses = [
{
min: -Infinity,
status: "invalid"
},
{
min: 0,
status: "great",
color: "green" // or a more specific color code
},
{
min: 10,
status: "average",
color: "orange"
},
{
min: 20,
status: "terrible",
color: "red"
},
{
min: 101,
status: "invalid"
},
]
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.
@ShayAdler I didn't understand to which page you are referring to because my changes are for the GapsPage as well.
The 'status' variable is for choosing one of these classes
&-great-result {
color: $great-result;
}
&-average-result {
color: $average-result;
}
&-terrible-result {
color: $terrible-result;
}
the variables (in scss file) contain
$great-result: #097d09;
$average-result: #b4b407;
$terrible-result: #b90a0a;
Did you mean to change the colors in the variables? as follows:
$great-result: green;
$average-result: orange;
$terrible-result: red;
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.
if the gap percentage is 1/10,000, will you consider it "average"?
Yes, the green is for TEXTS.all_rides_completed
the average is for missing some rides
and the red is for missing more than 20% of rides.
Make sense and this is also the requirements from the issue
green - "כל הנסיעות בוצעו"
yellow - < 20% miss
red - >20%miss
It make sense because even if one bus will not make the ride as scheduled it can have some bad consequences on a group of people. They can late for work , for a meeting , take their child from school. So yeah, we count on the buses to take us to important places. When one bus will not make it on time we will need to wait another half an hour for the next bus (in some cities)
I prefer your cleaner code. Do you want me to make the boundaries configurable as well? I refer to the 10%,20% ?
I thought about this, and maybe the "average-result" keyword is confusing here. I think to change it to "decent-result". Hmm, what do you think?
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.
agreed, you're right
@NoamGaash @ShayAdler Hi, could you answer to my questions about the comments so I will make the right modifications? |
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.
approved with comments
thank you for your help!!!
let status = '' | ||
switch (true) { | ||
case gapsPrecentage === 0: | ||
status = 'great' | ||
break | ||
case gapsPrecentage < 20: | ||
status = 'average' | ||
break | ||
case gapsPrecentage >= 20: | ||
status = 'terrible' | ||
break | ||
} |
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.
agreed, you're right
I changed the code. To use the findLast() method of an array I had to update the typescript version. @NoamGaash |
do you need help with the conflicts? |
@ArkadiK94 |
Great, thanks , the error is not shown. Could you merge this pr? |
Sure! thank you! |
you change the typescript version in |
Displaying the total daily gaps percentage in the "gaps" page
@ShayAdler @NoamGaash