Skip to content

u/dachusa

In this archive from Jan 2012 to Sep 2018

8
posts
79
comments
3
media
616
score

Make sure you aren’t working really hard to solve the problem you think you have. Take a step back and make sure you have the problem correct.

My juniors often run into this problem where they spend a ton of time trying to get something to work a certain way, instead of backing up and going about the solution a different way. If it seems hard and over complicated, there is probably a simpler way to achieve the same result.

1 points

I would see it as a good way to see what needs to be better documented. Pose the question there, when question is answered make sure the answer is a reference to documentation. Then if someone in the future has a close enough question, they are pointed to the correct documentation.

Probably only viable for companies with large departments spread across multiple locations.

Value add does seem pretty minimal.

2 points

I asked one like this for a guy who claimed to be an expert in JavaScript but had pretty much no experience and nothing to back it up. He was a boyfriend of a co-workers sister, so I wanted to make sure he was legit. He failed the question and took a long time to give up, but I had one of my junior devs figure it out to prove I didn’t make it overly obscure.

I do have another question I ask that has jibberish code which mixes multiple languages. I ask the interviewer what is wrong with the code, after making it clear it is intentionally not a valid language. This question helps me to identify the level the developer is most likely at and what may be their specialty. Did they focus on syntax, security, optimization, maintainability, etc...?

1 points

You can use vagrant and have it work with a custom image. I do this with a custom box with the installation setup like my prod box. Vagrant handles my virtual file mapping and makes it easy to share my box with team members who don’t have much knowledge/experience of VMs.

Running with NFS settings in the vagrant file allows the box to run extremely performant, and I have e been able to set it up to run with necessary settings for MacOS, Windows and varieties of Linux.

Folders are extremely deeply nested, lots of node_modules and client uploaded file folders, have never ran into a problem. Also the file permissions are setup to assign the owner and permission sets. For mine I did a simple 755 folders and 644 files, but you can get complex.

2 points

I had a “friend” do the same sort of thing. Had shared my resume with him so he could see the format and style I used. Once I saw his resume he stole my format style and had a lot of the verbiage, skills and experience that I had on my resume. Many of which I knew were not skills or experiences he had.

I cut him off as a friend and let him be, figuring he will either figure it out or fail and get fired (I was hoping for the latter at the time).

8 points

Boolean doesn’t solve it but solves the same problem as datetime with less data. The date information should be stored in an event history table. The Boolean would merely provide a quick way to obtain the status without obscuring detail. The example used above was not a full solution to how order tracking should be done, but merely to serve as an example for what I am talking about.

2 points

I agree with you overall but it is important to either queue the longer queries or ensure they are not accessible by the average user. Weekly/Monthy reports are a great example of a query that will longer queries. Protections just need to be in place to prevent a large amount of these requests from consuming all allowed active connections. This includes dynamic scaling as a solution, but it is something I would be sure to think about in relation to my user stories.

1 points

What about multiple refunds, based on multiple parts to the order?

The full log data would be good to hold the date field information, but I would still go with a boolean in the case of replacing a orderStatus field on an order record, since the original purpose of a column similar to orderStatus would be for quick querying of orders by a particular state or set of states.

1 points

What is the advantage of using one column?

Logs are good and should be kept, but when reporting you don't want to query them on a larger scale (inline with NrdyN8's comment). On a small scale, expect you have 1 million rows for orders. Each of those orders has had on average 5 status changes. Looking for a single set of the order data across 5 million rows, no problem. Querying the log to find all orders where one status existed but another didn't, that is going to eat up a lot more query time.

Remember in db querying, 1 second query time is wayyyyy too long.

1 points

Pts

If you want to get directly to that request, you can use a join call then.

$teamStandings = DB::table('proteam')->join('prostandings', 'proteam.T_ID', '=' 'prostandings.Number')->orderBy('prostandings.Pts', 'DESC')->select('proteam.Name', 'proteam.city', 'prostandings.Pts')->get();

I wouldn't typically use those though. I think the below set should work for you based on everything you have said.

$season_id = 11;
$teams = team::with('standings'=>function($query) use ($season_id) {
        $query->where('Season_ID', $season_id);
    })->get();
$teams = $teams->sortByDesc(function($team, $key){
    return $team->standings->first->Pts;
});



@foreach($teams as $team)
    {{$team->Name}} - {{$team->City}} - {{$team->standings->first->Pts}}
@endforeach
2 points
$divisions =  division::all();

@foreach($divisions as $division)
    <div class="division">
        <h3>{{$divison->name}}</h3>
        <div class="teams">
            @foreach($division->teams->sortByDesc(function($team, $key){ return $team->standings->max('Pts')}) as $team)
                <div class="team">
                    <span class="teamName">{{$team->name}}</span>
                    <div class="teamStandings">
                        @foreach($team->standings->sortByDesc('Pts') as $standing)
                            {{$standing->Pts}}
                        @endforeach
                    </div>
                </div>
            @endforeach
        </div>
    </div>
@endforeach
1 points
$teams = team::whereHas('standings')->with('standings')->orderBy('standings.Pts', 'DESC')->get();

The orderby is going to act a little odd with the way you are wanting it. Essentially what you have going on above is it is sorting the teams based on the standings, but then the teams standings are grouped under them, so the teams are now in decending order of the team who has the most points to the least, but if they have multiple standings, the secondary may be out of order.

Is your standings a HasOne or HasMany relationship?

If it is HasOne, then you should be able to change the blade to:

@foreach($teams as $team)
    {{$team->standings->Pts}}
@endforeach

If you are still struggling, I can help you more by looking at your full code, if you share it via bitbucket (free to share private repos), github or another source code repo.

edit: Referenced original post, I see the standings relationship is HasMany

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.