leaderboardsgg / leaderboard-backend

The backend for Leaderboards.gg. Also holds public-facing APIs.
https://info.leaderboards.gg
GNU General Public License v3.0
12 stars 16 forks source link

Automatically Set CreatedAt and UpdatedAt #244

Closed TheTedder closed 2 months ago

TheTedder commented 2 months ago

What it says on the tin. Had to mess with the tests a bit to get this working properly. Also removes erroneously overridden Equals and GetHashCode on models (this is a no-no). Closes #237

zysim commented 2 months ago

~Kinda don't like having inheritance on the interfaces themselves. If we do go down with the interfaces approach; I'd rather we do something like this:~ (actually it really doesn't matter. Though I would still prefer if we did the base class, though)

public class Leaderboard : ICreatedAt, IUpdatedAt

Alternatively as I've said in the channel; we just do a base class with all three timestamps, and have classes inherit that

TheTedder commented 2 months ago

~Kinda don't like having inheritance on the interfaces themselves. If we do go down with the interfaces approach; I'd rather we do something like this:~ (actually it really doesn't matter. Though I would still prefer if we did the base class, though)

public class Leaderboard : ICreatedAt, IUpdatedAt

Alternatively as I've said in the channel; we just do a base class with all three timestamps, and have classes inherit that

Having one base class with all three is impossible since some tables have CreatedAt but not UpdatedAt. I couldn't see an easy way to automate DeletedAt so I'm keeping that one manual for now. Would you still like to me get rid of the inheritance?

zysim commented 2 months ago

Yeah nah just keep what you have. Don't have to that class inheritance thing.

zysim commented 2 months ago

How'd you figure out on how to add methods in ApplicationContext like that?

TheTedder commented 2 months ago

How'd you figure out on how to add methods in ApplicationContext like that?

I'm actually a wizard IRL. Also I read this article.

zysim commented 2 months ago

Would IHasUpdateTimestamp trigger on creation as well?

TheTedder commented 2 months ago

Would IHasUpdateTimestamp trigger on creation as well?

I'm not sure but it doesn't really matter either way as far as I'm concerned.