The SIO2 project
  1. The SIO2 project
  2. SIO-1345

Serialized scores lexical ordering shall match __cmp__ ordering

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Current Version
    • Fix Version/s: None
    • Component/s: OIOIOI
    • Labels:
      None

      Description

      ex. now IntegerScore is serialized ex. as int:99 or int:100,
      so string ordering does not correspond to natural one.

      Then, ordering in admin could be added.

        Issue Links

          Activity

          Hide
          Maciej Matraszek added a comment -
          It might not always be straightforward. With normal descending sorting you only need to zero-fill the value, but in ACM-style contests we use ordering like: ORDER BY accepted_solutions DESC, total_time ASC.
          Take a look at AcmScore.to_repr here: https://gerrit.sio2project.mimuw.edu.pl/#/c/1744/12/oioioi/acm/score.py
          I have tried to implement such ordering there (but forgot the ASC sorting).

          One solution I can think of is to digit-negate the time (00123 -> 99876), but that's ugly ugly.


          Show
          Maciej Matraszek added a comment - It might not always be straightforward. With normal descending sorting you only need to zero-fill the value, but in ACM-style contests we use ordering like: ORDER BY accepted_solutions DESC, total_time ASC. Take a look at AcmScore.to_repr here: https://gerrit.sio2project.mimuw.edu.pl/#/c/1744/12/oioioi/acm/score.py I have tried to implement such ordering there (but forgot the ASC sorting). One solution I can think of is to digit-negate the time (00123 -> 99876), but that's ugly ugly.
          Hide
          Szymon Acedański added a comment -
          Yes, seems ugly, but maybe not that much so, if you express "digit-negate" as "subtract from 99999". :)

          Another idea may be a slightly extended proposal of Maciek Dębski (SIO-1329). I'd express it as having an additional ScoreOrderField class, which would be a "friend class" to ScoreField. They together would be able to implement the needed functionality, most notably appropriately forbidding various lookups in their get_prep_lookups, and allowing assignments only to the ScoreField. Still, I don't like it because of redundancy in the DB and quite unexpected consequences of someone inadvertently changing only one of the columns...
          Show
          Szymon Acedański added a comment - Yes, seems ugly, but maybe not that much so, if you express "digit-negate" as "subtract from 99999". :) Another idea may be a slightly extended proposal of Maciek Dębski ( SIO-1329 ). I'd express it as having an additional ScoreOrderField class, which would be a "friend class" to ScoreField. They together would be able to implement the needed functionality, most notably appropriately forbidding various lookups in their get_prep_lookups, and allowing assignments only to the ScoreField. Still, I don't like it because of redundancy in the DB and quite unexpected consequences of someone inadvertently changing only one of the columns...
          Hide
          Maciej Dębski added a comment -
          I believe we shall implement it nevertheless. I mean, use some ugly representation first for ordering, then include time in normal representation. We do not have to negate digits, we cam just compute 2**64 - total_time, or even 2**64 * problems - total_time.
          Show
          Maciej Dębski added a comment - I believe we shall implement it nevertheless. I mean, use some ugly representation first for ordering, then include time in normal representation. We do not have to negate digits, we cam just compute 2**64 - total_time, or even 2**64 * problems - total_time.
          Hide
          Szymon Acedański added a comment -
          Why? As far as I see now:

          1. If we care about being able to do something in the raw database manually, then we should not have an uncomputable value there.
          2. If we don't care, then why should we care about how the score looks in the DB.

          The only reason I can see to have the two columns is when we would like to store some extra information in the score, which does not affect order. Is this your reasoning or something else?

          I also think that we should not have the 64-bit limit (see AE, where we have to store the histogram of scores for comparison), we should rather use strings.
          Show
          Szymon Acedański added a comment - Why? As far as I see now: 1. If we care about being able to do something in the raw database manually, then we should not have an uncomputable value there. 2. If we don't care, then why should we care about how the score looks in the DB. The only reason I can see to have the two columns is when we would like to store some extra information in the score, which does not affect order. Is this your reasoning or something else? I also think that we should not have the 64-bit limit (see AE, where we have to store the histogram of scores for comparison), we should rather use strings.
          Hide
          Maciej Dębski added a comment -
          My comment was a reply to matrach's comment, not yours :)
          I posted it before I saw yours.

          So, summing up, i think we should represent acm score as string only, in format like 'acm:data_mangled_for_ordering:problems_solved:total_time:penalties_count'.
          And mangled data shall be sth like '%10d' % (LIMIT*problems_solved - total_time), anyway we need to set some upper limit for total_time.
          Show
          Maciej Dębski added a comment - My comment was a reply to matrach's comment, not yours :) I posted it before I saw yours. So, summing up, i think we should represent acm score as string only, in format like 'acm:data_mangled_for_ordering:problems_solved:total_time:penalties_count'. And mangled data shall be sth like '%10d' % (LIMIT*problems_solved - total_time), anyway we need to set some upper limit for total_time.
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 1
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 1 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 2
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 2 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 3
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 3 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 4
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 4 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 5
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 5 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 6
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 6 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 7
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 7 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 8
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 8 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Hide
          Gerrit Gerrit added a comment -
          Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 9
          https://gerrit.sio2project.mimuw.edu.pl/1857

          SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering

          Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4
          Show
          Gerrit Gerrit added a comment - Change I5bc7d5a69480f4b69043e0003c97d7363322e5b4, patchset 9 https://gerrit.sio2project.mimuw.edu.pl/1857 SIO-1345 Serialized scores lexical ordering shall match __cmp__ ordering Change-Id: I5bc7d5a69480f4b69043e0003c97d7363322e5b4

            People

            • Assignee:
              Szymon Acedański
              Reporter:
              Maciej Dębski
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: