Skip to content

Commit

Permalink
Merge pull request #9 from KipSigei/fix-ona-sync-bug
Browse files Browse the repository at this point in the history
Fix ona sync logic
  • Loading branch information
KipSigei authored Jan 22, 2025
2 parents b674d53 + 1d48fac commit cfd286d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions afpolgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2344,6 +2344,8 @@ def ona_fetch_data_sync_enabled(self):
self.dlg.onaOkButton.setEnabled(False)
api_url = self.dlg.onadata_api_url.text()
formID = self.dlg.comboOnaForms.currentData()
form_str = self.dlg.comboOnaForms.currentText()
cleaned_form_str = "_".join(form_str.split(" "))
username = self.dlg.onadata_username.text()
password = self.dlg.onaMLineEdit.text()
page_size = int(self.dlg.onaPageSize.value())
Expand Down Expand Up @@ -2381,8 +2383,11 @@ def ona_fetch_data_sync_enabled(self):

if formID:
if hasattr(self, "vlayers"):
if self.vlayers.get(f"{formID}_{geo_field}"):
self.vlayers[f"{formID}_{geo_field}"]["syncData"] = True
if self.vlayers.get(f"{cleaned_form_str}_{geo_field}"):
self.vlayers[f"{cleaned_form_str}_{geo_field}"] = {
"syncData": True,
"vlayer": self.vlayers.get(f"{cleaned_form_str}_{geo_field}").get("vlayer")
}

self.ona_worker = OnaRequestThread(
url,
Expand Down Expand Up @@ -3057,8 +3062,6 @@ def load_data_to_qgis(self, geojson_data, formID, geo_field):
and self.vlayers.get(layer_name).get("syncData")
and existing_layer
):
if self.vlayers.get(layer_name):
self.vlayers[layer_name] = {"syncData": True, "vlayer": vlayer}
self.update_layer_data(layer_name, geojson_data, vlayer)
elif (
not self.vlayers.get(layer_name)
Expand Down

0 comments on commit cfd286d

Please sign in to comment.