History log and custom fields
Moderators: Developer, Contributor
History log and custom fields
Hi, everyone!
I have a question (i'm kinda of a apprentice on mantis, sorry about that)
i have created a custom field that count the days since that bug has been opened, but i want to update that custom field each time i change the bug status (Open -> Acknowledged, for example)
i haven't configure it to show the text field of that custom field because it updates automaticaly, but the change doesn't appear in history log.
There is a way to put the change in history log without needing the custom field text field?
sorry for my bad english and thanks for the help!
I have a question (i'm kinda of a apprentice on mantis, sorry about that)
i have created a custom field that count the days since that bug has been opened, but i want to update that custom field each time i change the bug status (Open -> Acknowledged, for example)
i haven't configure it to show the text field of that custom field because it updates automaticaly, but the change doesn't appear in history log.
There is a way to put the change in history log without needing the custom field text field?
sorry for my bad english and thanks for the help!
Re: History log and custom fields
Oh, and my mantis version is 1.2.19
Re: History log and custom fields
Hi. How to do update value of that custom field? DB trigger?
Mantis Statistics Plugin: https://www.mantisstats.org
Re: History log and custom fields
i have created a function that update the custom field in DB
each time i call it, it updates the custom field.
each time i call it, it updates the custom field.
Re: History log and custom fields
If you went in the direction of creating function writing to DB, then you can also write to history table, I guess. The structure of history table is very simple.
Mantis Statistics Plugin: https://www.mantisstats.org
Re: History log and custom fields
aavagyan wrote:If you went in the direction of creating function writing to DB, then you can also write to history table, I guess. The structure of history table is very simple.
I thought that too, but when i get the old_value, it returns 0, not the same value if i execute the query directly on MySQL
Re: History log and custom fields
Well, I see two options, I must say:
- digging in PHP until you find what is wrong - why are you getting 0.
- Redoing as DB trigger whole thing - in the case you are strong at DB end (update on bugs table triggers read + calculate + write back + write to history table). You will also need trigger on delete... and on insert probably.
I must say I don't like whole approach because you time will get updated only on action happening with bug. If no action it will show outdated value...
- digging in PHP until you find what is wrong - why are you getting 0.
- Redoing as DB trigger whole thing - in the case you are strong at DB end (update on bugs table triggers read + calculate + write back + write to history table). You will also need trigger on delete... and on insert probably.
I must say I don't like whole approach because you time will get updated only on action happening with bug. If no action it will show outdated value...
Mantis Statistics Plugin: https://www.mantisstats.org
Re: History log and custom fields
I have called that function in view_all_bug_page.php, view.php, and my_view_page.php before just to give a "dynamic" update, but i'm trying updating by changing status just to see if its possible or notaavagyan wrote: I must say I don't like whole approach because you time will get updated only on action happening with bug. If no action it will show outdated value...
Re: History log and custom fields
I see. This should work, although doesn't sound like elegant solution. One question - why do you want to record time updates in history log?
Mantis Statistics Plugin: https://www.mantisstats.org
Re: History log and custom fields
Well, i have turned off that dynamic update, i can only update by changing the bug statusaavagyan wrote:I see. This should work, although doesn't sound like elegant solution. One question - why do you want to record time updates in history log?
I need that old_value because i want to "turn back" the days depending on the status
A example:
The bug is Acknowledged at day 20
if i change the status to "Resolved", for example, it was on day 30, so it goes 20 ---> 30, right?
if i change back to "Acknowledged", i want to turn back the day count from 30 to 20
do you understand?
Re: History log and custom fields
OK, I understand. So you will need to iterate through status changes from the history table and depending on old/new status add/subtract corresponding dates. Please have a look at core/history_api.php --> it has plenty of useful functions. For example history_get_events_array, history_get_raw_events_array.
Mantis Statistics Plugin: https://www.mantisstats.org
Re: History log and custom fields
i'll try thataavagyan wrote:OK, I understand. So you will need to iterate through status changes from the history table and depending on old/new status add/subtract corresponding dates. Please have a look at core/history_api.php --> it has plenty of useful functions. For example history_get_events_array, history_get_raw_events_array.
i have tried custom_field_api and bug_api, i still don't have a look at history_api
Re: History log and custom fields
i'm thinking about searching for the last history update, get its date_modified value (which is in unix timestamp), convert into days and putting as old_value of the new history update
what do you think?
what do you think?
Re: History log and custom fields
To answer without guessing, I need to understand clearly what you need to ger. Is it time that issue was in 'assigned' state, or in all 'open' states, or in selected particular states? Do you need to see same for issues, which are 'new'? If issue is resolved, but then reopened, do you continue incrementing time? Etc. You need to put all situations on the paper before attempting to find solution.
In most of these cases you need to know all status changes with their dates - because, for example, imagine the case what issue was resolved in the middle and then reopened. Once you have array of states+times you can have plus-minus depending on what you need exactly. I don't think getting the last only is any useful. Functions I mentioned should give you this array.
P.S. If you have the simplest case to see time from issue creation to now, then you don't need history table at all. Just have 'now() - submitted_date' and store it in your custom field.
In most of these cases you need to know all status changes with their dates - because, for example, imagine the case what issue was resolved in the middle and then reopened. Once you have array of states+times you can have plus-minus depending on what you need exactly. I don't think getting the last only is any useful. Functions I mentioned should give you this array.
P.S. If you have the simplest case to see time from issue creation to now, then you don't need history table at all. Just have 'now() - submitted_date' and store it in your custom field.
Mantis Statistics Plugin: https://www.mantisstats.org
Re: History log and custom fields
well, we have particular status where we'll stop counting the days, like closed, for exampleaavagyan wrote:To answer without guessing, I need to understand clearly what you need to ger. Is it time that issue was in 'assigned' state, or in all 'open' states, or in selected particular states? Do you need to see same for issues, which are 'new'? If issue is resolved, but then reopened, do you continue incrementing time? Etc. You need to put all situations on the paper before attempting to find solution.
we don't continue incrementing time, we'll kinda "go back" to the last time that issue was reopened
that's how i done it before, it has worked, but i'm trying in a diferent wayaavagyan wrote:P.S. If you have the simplest case to see time from issue creation to now, then you don't need history table at all. Just have 'now() - submitted_date' and store it in your custom field.
I tried a condition in history_api in function mantis_log_event_direct were i can insert a new history if the custom field name = 'days'
but it's getting a fatal error because it's not inserting the new_value
PS: all the custom field checkboxes are off in configurations