#TJ-Bot first issue
1 messages Ā· Page 1 of 1 (latest)
<@&987246924425994290> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
this is the one im talking about
i have already created an sql file to add a column to reminder table as suggested. Im not sure if it should have a default value or not
this is what it look like atm
don't feel like it should have a default value tho, since the column contains no of times the /reminder command failed basically
Another question
Zabu mentioned RemindRoutine.java is responsible for sending reminders
im assuming this method is the one that handles that part inside RemindRoutine.java file
depending on the design, the default could be 0 (retryAttempts) or 3 (retryAttemptsLeft)
correct. that sendReminderViaRoute does it
it figures out where to send it to (channel or DM) and then sends it there with that method
so sendReminderViaRoute mainly does the job of sending that message back to db
yes
any ideas how should i go about it? try to wrap it in try-catch block or use some sort of conditional along with boolean
don't think it would throw an exception if it misses the call
its a restaction
when u do .queue(...) it has a failure callback there
as second argument
that way u can react to failures
ah, i'll try something out see how it goes
for testing, just throw an exception within the reminder and it triggers lol
where were we supposed to put our bot token š
from what i remember someone suggested earlier to do that in a file i think
was wondering if there's a better way or more standard
in tjbot it's read via the config file
apart from putting token in config.json.template file, is there anthying else i need to add? tried doing a run but test-bot in my server seems ded
the template file is just a template
ur supposed to create the actual config. u can use the template for copy pasta
but the bot will read the actual config.json
not a template
by default the config file is autocreated on first launch based on the template in the working directory
u can probably find it somewhere there
alternatively, the bot accepts the first parameter in main (run config) as path to the config file
u can check the wiki, those config steps should be covered there - with images
oh thanks, it shouldnt affect the functionality then
its an optional feature. hence it's a warning, not an error
it actually has an explanation text right above it iirc
or below
i guess it could be adjusted to sth like "... You can ignore this warning if you are not interested in this feature"
write is used to write to db, but i don't understand if this snippet is used to send reminder from db to user or saving it to db
sending from DB to user
saving to DB is done in the slash command
the code u shared does:
- get hands on all entries in the DB
- filter by reminders that due to now (remind at < now)
- for each of them
- sendReminder (to user)
- delete it from DB
oh since we are deleteing entries that's why we chose the write command
otherwise read would have been enough
as for my logic to increment the counter and retry should fit here?
yes, but it would be better to put it in a separate method
also why do you extract the consumer parameter?
that was done by me
its the current code
but yeah. it will become complex enough to justify its own method at that point
but yes, it would go inside there
the idea is that (as the original entry is deleted from the DB), u reinsert it. with increased timer and and instant that is overdue as well - or scheduled in like 1 min
so that the next routine-run will naturally pick it up
i was thinking of maybe a for loop
which runs 3 times for now
and in every iteration we add an onFailure call to the completable future, and assign that to the old variable
or we could use rest action too if possible
would make it easy if we were to increase the number of attempts
dont do that, then u would schedule immediately again
the idea is to wait for a few seconds or minutes
cause failure usually is caused by network issues or rate limits
if u retry immediately, chances are high that it fails again
i feel like its easier to just use the existing routine-run system
i.e. just reinserting into the DB and it will naturally be executed again
that way its just like 4 lines of code or so
ok thanks for the direction, ill try to implement this in a separate method. Is there a way to replicate the fail while using the command.
so use a sheduled exectuor inside the rest action?
or u can use RestAction#queueAfter
no. just db.insert(reminder(...remindAt.plusMinutes(1), retry + 1)
kinda
not sure if im doing it right, im trynna grab teh values with counter b/w 0 and 3 and then update the column in db and then finally do the sendReminder thingy again. Not final implementation obv, wanted to know what im doing wrong before i proceed further.
not sure what in looking at, but it looks wrong
im not sure what's unclear. the failure action is to insert the record again (with an increased counter)
nothing else
this is like one line of code
and then u would add if-else to instead log if it was the last failure
makes 3 lines of code
š
i have a few questions, should i pass down the parameters along the method chain? or am i doing it wrong
is there a way that i can grab the previous record instead of passing all these params
this method will be the caller of reminderFailureAction for context
u will have to send it along the path
from where it was read from the db down to that method
the general approach now looks better 
ah thank god, took me a while looking at code and figuring out the purpose of most of it
how should i go about this? tempted to make db field static but jjst wanted to know if that would break things or fine
as a rule of thumb, never make anything static
in this case, the method shouldnt be static
as simple as that
it was only made static bc it never needed access to fields
if that changes now, it shouldnt be static anymore
Makes sense, I'll go with that
i think im stuck in static/non-static hell hole, now it wants me to either make the caller static or instance of database static so that i can call my method
if u make this method non-static u also have to make the caller non-static
the caller likely also was made static only bc it didnt need access to fields yet
that was my initial thought as well, just wanted to check with you just incase the methods were made static with something else in mind and me changing that messes it up furtherš
is there a way to simulate failure of reminder command? or would need to write a test for this
just literally put a throw new RuntimeException("haha") into the code
or if (Math.random() > 0.5) throw new RuntimeException("haha")
thats the easiest way to test out these things
ok thanks
In that case if the error handling is done incorrectly, won't the test pass on a certain attempt, but fail on another?
That does not seem right.
yes. this is not meant as unit test. it's for manual testing
tried throwing exception in both the methods sendReminder and sendReminderRoute, the flow never reaches to consumer for failure. Tried putting a bunch of sysouts in between so im sure it's not hitting those.
console only throws this exception repeatedly
u need to throw it in the rest action queue
action.onSuccess(() -> throw...)...queue()
or in a method used in one of the map/flatMap calls
so that it happens within the queue
for example in createReminderEmbed
onSuccess seems to be working
am i reading the field of PENDING_REMINDERS table correctly? used map instead of long version and it's not working out
i hope it's not coz of this thingy, i had to typecast it equals only supported integer 
if u have to cast, things are most certainly wrong
there's one more thing, regarding default values in REMINDER_FAILURE_COUNTER column, i earlier didnt initialize with a default value so it did null
but if change it with default 0 or INT 0, it throws an error doesnt even begin the application
get a db viewer like "Sqlite Browser" and patch the column with it
dbeaver -_- @cobalt ruin
you mean i need dbeaver to change the table ?
i mean, dbeaver is pretty much the best db viewer imo
at least better than sqlite viewer
as long as it gets the job done honestly i don't mind
seems like there's some sort of mechanism in place to prevent restructuring of db once it's initialised
if u want to have the migration script get executed again, u have to decrement the version
there some special table in the DB holding the current version
wrt the migration script
worst case, u just delete the DB and it gets build fresh - but empty
that sounds complicated, what if i just deleted the db file and rebuild? would that work
worst case, u just delete the DB and it gets build fresh - but empty
oh lol thought it was related to script
Closed the thread due to inactivity.
If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you š
..
did a few tweaks and no more typecasting id, anyway is this the correct way to read a certain column from table?
using get just for now, ik it's bad practice will change that later
im sure it can be improved. but i dont see any red flags
ok then i think there's another problem in here, the code never really returns a value
basically im getting a null value
could it be because by the time the action is successful the table is empty
Blame him
blame who?
?_?
This guy is a troll
?
Itās funny, when u cause a massive problem and refuse to accept fault to say itās everyone else who is the villian @viral urchin
right keep it to #chit-chat pls
Ok we will bring this to there @viral urchin
it's definitely the block calling for getFailureCounter() is throwing an exception
Update: i realised what's actually happening here, my getFailureCounter() is failing because when i insert the same record again it's done with a new ID whereas in my method im trynna pull record based on older ID
thoughts on how to go about this? should i forcefully set the ID same as it had before getting removed from DB
or while trynna pull a record from DB which failed, instead of ID should use something else?
Update: It kinda worked out setting same ID as failed record but had to throw in another one arguement for getting counter, since when i tried to pull the record from DB even with same ID it was already deleted by that time. So i had to grab that counter in sendReminder method and pass it along the chain
as expected it inserts the record back into DB with same ID, and one min delay on next one
now just gotta setup the isLastFailureAttempt method
i have set up most of the stuff, i ran the tests but it's failing this one particular test
Closed the thread due to inactivity.
If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you š
..
yeah, kinda expected
the feature was fully unit tested, including its behavior on failure
since u made it resilient now, this particular test fails
for obvious reasons
since we kinda consider tests in this project secondary, u can decide whether u want to add tests for it as well or whether u would just delete this unit test for now
should i do a PR or a draft for review
sonarLint suggesting to not have more than 7 params inside a method, how should i go about this?
there's no general way out of this. but u can observe that most of ur arguments are just ur reminder data. so maybe create a record called Reminder or similiar and encapsulate it with that
Closed the thread due to inactivity.
If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you š
Right, I'll try that
just send the entire pendingreminder object
so like store that by reading an entire row and use that later
also i figured out how to setup sonarLint but idk how to do spotlessly
in intellij
just run ./gradlew spotlessApply
it should automatically run that on every commit
for windows it should be without the ./
i think ill create a Record for this stuff
since im already creating a record, thinking about refactoring this method as well
note that pendingReminder itself is already sth like a record that u could perhaps just continue using
this si what i did
now i only have to pass this reminder record all along
i tried that command taz mentioned earlier for spotlessly but it showed a few errors on terminal window
for now all my solarLint errors are gone, just need to check with spotlessly
or should i just pass pendingReminder all along ?
if thats possible, imo that would be easier lol
im not sure if that's possible i could give it a try
is this bad tho? what im already trynna do
also kinda confused how to do that spotlessly thing, do i have to declare it as a gradle task? i have checked the wiki, still not sure how to go about it
spotless is setup as pre commit hook. that means that its supposed to auto-run when u commit.
I'm not sure how u commit, but u somehow managed to deactivate this feature
it's usually really hard to commit unformatted code lol
that said, u can also always manually run it by just executing gradle spotlessApply or whatever we called it
i honestly don't know, synced the fork from parent and then pulled from my remote repo and then finally pushed it after commiting ofc
this error popped up
stacktrace looks ugly
unsupported major version
sounds like u have wrong java versions setup
ensure its jdk 18
it's 18 just different vendor
well. something in ur chain compiled java 19
63 is 19
so there's now bytecode from 19, which ur jdk 18 doesnt understand
these are the two settings where i configured 18 specifically
i checked the version for java on terminal, it does say 19. Could it be that gradlew spotlessApply uses that java version instead of the one configured in project structure?
imma try setting up the jdk in gradle.properites file
didn't work out
had to find the task from gradle's task likst
that worked out
does this mean i can commit now, did it work or would do stuff when i commit
if spotless runs through fine, that check would likely be green on the PR
already did PR, not sure if checks need to manually redone
i mean i updated my remote repo, i think it updates the PR as well
it says needs to be done by a maintainer
yeah bc u have no contributor permissions yet
isnt that a life savor lol
u get that after ur first successfull PR being merged
omg wow les go
so if these tests pass that means im not gonna break the bot
said it too early
this doesnt make sense, it was supposed to be of type Temporal
it doesnt really do anything else than just running spotless and the unit tests (and some sonar checks).
technically u can run all of those commands locally as well
but yeah, if they pass, its good
i have ruined the second attempt as well
spotlessApply still doesnt make sense, i have ran it twice and it says build successful, let me pull up a screenshot
this is from check build task
ran all of these and none displayed any error, so im confused atm
@shell kindle here, see for yourself
can u just do gradle spotlessApply in terminal
idk what those ide features are
the problem with terminal is, it runs on java 19 version
ik i just like to pretend i don't
see thats y i dont use ide, u don't know how to use ur tools u just know how to use ur ide
i don't even know anything about gradle, so im not really complaining about IDE atm but isnt that how you run build tasks
is this need to be done anywhere inside your project? or like has to be specific file
already shared this zabu, he told me that i had java verison 19 then it made sense since terminal refers to version 19 when executing gradle command
what u want to do is use a lower version of java
theres so many ways of doing that
changing the java version globally
or just in the project
i believe there is also just for this command
the only task you have to run (if you don't have pre-commit hook installed for some reason) is spotlessApply
tell us what's the result of that task
also make sure everything compiles, and make sure you actually pushed the latest changes
not familiar with pre-commit hook so don't think i would configure any of that
it could be that i haven't compiled after the changes maybe that's why build passes
is there a way around this instead of deleting the entire db? this is because i changed the sql file to add column
interesting, i only used flyway repair. Ill try all of em
quick question, after the spotless check runs does it like "changes code style" on completion or just lets you know that your code failed?
not sure if this worked or not but says successful like the last time i think
i think i might have successfully ran spotlessApply, i do see difference in code format in my local machine vs remote repo like it's all aligned and stuff
yea it actually works, i tried by putting extra tabs inside code and it changed it back to proper format after running task
Just did a review request, this should be packup i think most stuff is fixed hopefully
the way is to just delete big stupid database and rebuild it
i forgot the exact commands but it is one simple google search away
i had to do it twice that took a lot of time configuring stuff
a lot of suggestions online recommended running flyway repair task
but that didn't work out
it's prolly one of the flyway tasks maybe clean or something
i might have officially broken a record for longest thread ever in Together-Java
but therefore u learned a lot of stuff. and we did as well, by helping u with the problems
glad u figured out most of it now
im too scared to jump to conclusions now, let's just run the tests whenever you have timeš¶
appreciate the help btw without your guidance wouldnt have figured out what's going on with the project for sure
error message when the retry cycle ends
is the log message also in there, if u scroll up?
have you pushed latest changes? 
RemindRoutineTest > Skips a pending reminder if sending it out resulted in an error FAILED
org.togetherjava.tjbot.db.DatabaseException at RemindRoutineTest.java:44
Caused by: org.jooq.exception.DataAccessException at RemindRoutineTest.java:44
Caused by: org.sqlite.SQLiteException at RemindRoutineTest.java:44
this test is failing in your PR
also, feel free to ping me whenever you want me to run the checks again for you 
(makes sense just from reading the log, because test has a nice display name
)
wow the log was hidden in one liner in the crowd
not yet, thought this was another problem false alarm
quick questions before i commit
our latest commit should have the message it intend to solve?
not sure what you mean
our contributing has a nice guide on commits and commit messages
i mean i have done several commits in my repo
so does the commit message stays the same or updates, since it's not merged yet so it technically still solves the same problem
like i started with initial commit, modified it again after request, modified it again and so on
so in this final commit, teh commit message would still be what it should have been in the Original PR
like fixing the slash reminder thingy
easiest way is to show your commit history
you don't have to worry about commit history that much, we will squash in the end anyway
oh
having a good commit message here and there is helpful tho
this is just like two out of so many commits
it's just bad history
from now onwards should i update it as i progress or like you said it's gonna get squashed in the end?
it's getting squashed anyway
it's good for our project because it's beginner friendly
oh btw this is what i came up with i mean the message, looks alright?
we don't have to force poor newbies to clean up their git history 
yeah
it's important that you have all the changes, and nothing is broken ^^
just try to have few descriptive commit messages here and there, because i will use that as a final message when i squash
prolly that's why they suggest to have the PR to handle smallest responsibility
yeh, depends on the workflow
with squashing, that's definitely the goal
since you are destroying a lot of history otherwise
ill try to commit and write a message then do a push
will check if develop is updated already before that
it's contrary to the intentions behind git commits
you know, smallest possible and self-contained changes
so you can revert a single bad change, find the commit the introduced the bug, read diffs to understand specific changes, bisect, cherry pick.. etc
if you have whole system in one single commit, kinda removes a lot of version control aspects, the control part
ye makes sense
what to do with testcases? should i just remove em?
i mean that specific one
seems like it, or adjust it to make sense with the changes you made
think i found the flyway thingy to work with changes
nvm it's disabled using a property
this is the one
so there's tiny one unit space that i wanted to remove from my sql script, but flyway checks are killing me
there has to be a civilized way around this, deleting DB or started everything from scratch doesn't sound productive
u would have to connect to the DB externally and modify it
for example manually changing its version to the previous version
for now worked around it, imma remember this one for future reference
about testcases, i don't think i can modify it right away maybe in a later issue.
we can't merge with tests failing
from the name of the test, it seems like you can safely remove it
should i comment it out for later to be worked upon or just remove it
can check the code later
because skipping reminder if errored out is not expected behaviour anymore, we are retrying
remove it
alright ill remove the test and add it in my commit message
and yeah, zabu confirmed the removal 
the test was specifically put there to test that failed reminders are dead
but now u repeat them
so the test makes no sense anymore
remove it (and later someone can add a new test which covers the repeat-functionality)
pushed it
all checks passed, good job 
awesome stuff
it's time to bury this thread in the darkness
Before that thanks to everyone who chipped in
Closed the thread.
in before https://i.imgur.com/1VRGyvQ.png
he thought it's over 
classic mistake
you still need 2 passing reviews before we can merge 
wait what
hehe
common guys im your friendly neighborhood BEE
not sure if i can do that, the write command is creating a new record
so it kinda expects other values
at least doubt it works with newRecord
ill try and run it
works alright, not sure about these warnings seeing em for first time
kinda delayed pings as well
was it caused by the new code?
actually, i do see a problem with the databases writeLock not being locked that way
so at least do:
database.write(context -> {
pendingReminder.set...
pendingReminder.set...
pendingReminder.insert();
});
i.e. within the database.write method
it was temp, everything worked fine this time
okay cool. but u still have to put it within the database.write
otherwise we write to the DB without lock
which can cause race conditions
im actually surprised how simple it is to accidentally bypass our DB lock lol
tested the changes now
pushed local repo just now