Please help me understand the ordering of stories related to an epic

Hi,

Back in November I raised a feature request [FR] Refactor the ordering of User Stories that are attached to an Epic, for example by Status · Issue #210 · taigaio/taiga-back · GitHub where I was trying to understand how stories are ordered when they are ‘related’ to an epic.

As noted there: I can see that you can manually drag/drop related stories in an epic to change their order.

What I don’t understand is what I’m seeing in the database when I do that, in terms of what happens to the order column.

It seems it starts out as a timestamp (probably the timestamp of when the story got ‘related’ to that epic), yet moving stories also affects the surrounding stories’ order column value, and sometimes even sets it to 0.

Putting aside how it currently works, I wanted to ask a more simple question: if I were to write a script that periodically orders by the stories by their story status, meaning that I explicitly change the order column to be a simple 1, 2, 3 ,4 sequence (not ‘timestamps’), is that safe? (that is, that ‘order’ column has no other semantic meaning despite (sometimes? but not always?) appearing to be a timestamp? It won’t affect ‘dates’ associated with the stories in any way?

My plan is to use the API to join the story IDs to get their status (e.g Complete, In Progress etc) and then order those story IDs according to a company policy (we want ‘Complete’ stories at the top of the epic so we can jump to the bottom to look at the ‘In Progress’ ones, for example). I’ll run that script periodically on epics via cron or similar means.

1 Like

Hi folks! Just wanted to bump this question.. @Charlie any thoughts?

If I can get some reassurance that I can manipulate the ‘order’ column of an epic’s ‘related stories’ in any arbitrary sequence that makes sense to me, without it causing ramifications anywhere else, then I have what I need to move forward :slight_smile:

Thanks again!

Hi, @mig5,

Sorry for the long delay, we have not forgotten about you. This is something where I needed to check the code in detail before giving you an answer and did not have the bandwidth before.

So, yes, basically that timestamp in the order field is treated just as a numerical value, not a date. You can change it to a sequential series of numbers (1, 2, 3, 4…) and it would work just fine.

Two things to take into account, though:

  • Always do it at the service (code, management command, plugin, etc) or API level, so that signals, webhooks, etc are triggered, not directly from the BBDD.
  • Carefull with concurrency if you run it as a cron job, because if another user is modifying it as well, the last write wins. You can retry in your script or run it at quiet times.

Best!