OpenTechStrategies / torque

A flexible web-based open source system for collaboratively evaluating proposals.
1 stars 2 forks source link

Editing records via TorqueDataConnect #32

Closed Nolski closed 4 years ago

Nolski commented 4 years ago

Overview

We would like to be able to edit the contents of submissions & store those edits separately from the original submissions. The main constraints are:

Then on top of that things that might be feature requests would be:

Further Context

Best guess for entry point it is replacing calls to "cull_invalid_columns" to something that culls and then puts in overlays int he torquedata python server. In that response, return not only the column value, but also some kind of html that javascript acts on.

Then, I would add a call to the python server of "get column X of proposal Y in sheet Z" for the popup, and another call of saving the edit.

kfogel commented 4 years ago

In our discussion today, we decided that the edit buttons would be controlled from the template, that the overlay table will live in memory (pace issue #26), that data writes will be atomic, and that these are the fields needed in the overlay table:

kfogel commented 4 years ago

As discussed in today's meeting, we will:

Nolski commented 4 years ago

I think for the sake of our current implementation and communication on this ticket, I'm going to refrain from mentioning tables until we are committed to switching to a database. Currently our documents are stored in a dictionary formatted similarly to the following

data = {
    "proposals": {
        "1": {"Application #": "1", "Name": "foo"},
        "2": {"Application #": "2", "Name": "bar"}
    }
}

Our edit document will copy the above document when it is loaded and modify it to look like the following:

edits = {
    "proposals": {
        "1": [
            {
                "Application #": {
                    "new_value": "2",
                    "orig_value": "1", # or a hash?
                    "edit message": "",
                    "approver": "",
                    "edit_timestamp": "",
                    "approval_timestamp": "",
                },
                "Name": { ... },
            },
            { ...} # edits will be ordered in recency (most recent last)
        ],
        "2": { ... }
    }
}
kfogel commented 4 years ago

@Nolski, as we discussed, I created a branch in this repository for the editability feature work: 32-editability-feature. On that branch, I added the above data structure to the DESIGN.md file (see commit 3f36624e7dee).

I haven't ported over the changes from the torque-edit2 branch in your clone repository, because I figured you might want to squash/reorder things anyway. Feel free to to do so, including my commit above. It's a dev branch: any rebasing you want to do is fine. We only need things to remain stable once they're on the mainline or are on a designated stable branch (such as a release maintenance branch, for projects that are using those).

kfogel commented 4 years ago

Notes from our first preliminary walk-through of the feature with LFC:

Nolski commented 4 years ago

If we make an edit, API users will get that edit as the data they see, right?

@kfogel This is currently not how it is set up as I assume mediawiki render endpoint is different from our API endpoint. Do we want it this way?

frankduncan commented 4 years ago

@Nolski The endpoint should be the same, but the format is different. We don't have a json format for the single object return, just mwiki. Edited records should show up under the sheet endpooint (/api/<sheet_name>.fmt), and also for the sheet_toc and search enpoint, in case the TOC or Search templates include edited columns.

kfogel commented 4 years ago

There definitely has to be one, consistent, up-to-date data set that people get, whether they come in via a wiki page or via API. That principle should hold for everything.

@frankduncan I couldn't tell from your response whether this principle will hold, currently. Will it?

frankduncan commented 4 years ago

@kfogel It should

Nolski commented 4 years ago

@kfogel it does :)

Nolski commented 4 years ago

Review notes here: https://github.com/OpenTechStrategies/torque/wiki/Meeting-Notes#2020-08-14-mikekarl-editability-feature-and-browser-compatibility

kfogel commented 4 years ago

@Nolski and @frankduncan, here's a list of all the editability issues we've discussed in recent check-in meetings (1, 2, 3). The purpose of this comment is to be a checklist we can go over to make sure we've covered every point:

kfogel commented 4 years ago

@Nolski , what branch are your commits on? (Is it different from 32-editability-feature?)

I noticed that they all seem to have the same commit message, unless the GitHub UI is fooling me somehow. If your plan is to go back and give them more-specific commit messages later (and squash, reorder, whatever) as part of a giant rebase, that's fine -- I just want to know whether others should be looking at them yet.

We might want to make a convention for commits that are public-but-not-yet-intended-for-review, like "WIP/NR: " ("Work In Progress / Not Reviewable") or something like that.

Nolski commented 4 years ago

@kfogel apologies I keep my commits 1 per fix, feature, etc. That combined with having to commit any changes I want to test causes lots of amended commits and force pushes

kfogel commented 4 years ago

@Nolski No problem -- and no apology needed, that's all fine. I think it implicitly answers the two questions I asked, then:

1) You're on some other dev branch, not 32-editability-feature. 2) Others should not be looking at these commits yet.

If you're planning to amend a bunch of stuff later anyway, then there are a couple of routes we can go to avoid confusion in the issue: simply don't put the issue number in the commit messages right now (that way there won't be any noise in the issue, and you can add the issue number later when you're amending), or keep the issue number in and put a "WIP/NR: " prefix on the commit message, so others know that the noise just means "progress is happening" and not "please give feedback on this".

Of the two, I mildly lean toward the second way (and if you choose it, I'll document where our commit message conventions are documented), but either way is fine.

Nolski commented 4 years ago

@kfogel 32-editability-feature is the latest progress so I'll amend my latest commit to say wip that sounds like a good plan to me :)

kfogel commented 4 years ago

@Nolski:

Oh, oh oh oh OOOOOOH!

NOW I understand what's going on!

This issue shows a very long series of recent commits that all have the same commit message: "Resolves #32 by allowing edits to torque fields". I forgot that the GitHub UI doesn't do any kind of detection of replaced commits (i.e., of the typical kind of force push). That apparent series of commits is really all one commit, that you just keep amending.

When you said "I'll amend my latest commit" (singular), that's when the clue fell on me.

So, yes, this is fine: add the prefix and otherwise keep doing what you're doing and everything's good.