Not making db entry

This commit is contained in:
Ben Arc 2021-10-13 08:35:25 +01:00
parent a0be1a5017
commit 771c7c25c1
5 changed files with 17 additions and 11 deletions

View file

@ -16,7 +16,7 @@ async def create_copilot(
""" """
INSERT INTO copilot.copilots ( INSERT INTO copilot.copilots (
id, id,
"user", user,
lnurl_toggle, lnurl_toggle,
wallet, wallet,
title, title,
@ -70,21 +70,20 @@ async def update_copilot(copilot_id: str, **kwargs) -> Optional[Copilots]:
row = await db.fetchone( row = await db.fetchone(
"SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,) "SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,)
) )
return Copilots.from_row(row) if row else None return Copilots(**row) if row else None
async def get_copilot(copilot_id: str) -> Copilots: async def get_copilot(copilot_id: str) -> Copilots:
row = await db.fetchone( row = await db.fetchone(
"SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,) "SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,)
) )
return Copilots.from_row(row) if row else None return Copilots(**row) if row else None
async def get_copilots(user: str) -> List[Copilots]: async def get_copilots(user: str) -> List[Copilots]:
rows = await db.fetchall( rows = await db.fetchall("SELECT * FROM copilot.copilots WHERE user = ?", (user,))
"""SELECT * FROM copilot.copilots WHERE "user" = ?""", (user,) print(user)
) return [Copilots(**row) for row in rows]
return [Copilots.from_row(row) for row in rows]
async def delete_copilot(copilot_id: str) -> None: async def delete_copilot(copilot_id: str) -> None:

View file

@ -61,7 +61,6 @@
</p> </p>
</q-page> </q-page>
{% endblock %} {% block scripts %} {% endblock %} {% block scripts %}
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
<style> <style>
body.body--dark .q-drawer, body.body--dark .q-drawer,
body.body--dark .q-footer, body.body--dark .q-footer,

View file

@ -390,6 +390,7 @@
var mapCopilot = obj => { var mapCopilot = obj => {
obj._data = _.clone(obj) obj._data = _.clone(obj)
obj.theTime = obj.time * 60 - (Date.now() / 1000 - obj.timestamp) obj.theTime = obj.time * 60 - (Date.now() / 1000 - obj.timestamp)
obj.time = obj.time + 'mins' obj.time = obj.time + 'mins'
@ -488,6 +489,8 @@
self.formDialogCopilot.data self.formDialogCopilot.data
) )
} else { } else {
console.log(self.g.user.wallets[0].adminkey)
console.log(self.formDialogCopilot.data)
this.createCopilot( this.createCopilot(
self.g.user.wallets[0].adminkey, self.g.user.wallets[0].adminkey,
self.formDialogCopilot.data self.formDialogCopilot.data
@ -512,6 +515,9 @@
updatedData[property] = parseInt(data[property]) updatedData[property] = parseInt(data[property])
} }
} }
console.log('updatedData')
console.log(updatedData)
console.log('updatedData')
LNbits.api LNbits.api
.request('POST', '/copilot/api/v1/copilot', wallet, updatedData) .request('POST', '/copilot/api/v1/copilot', wallet, updatedData)
.then(function (response) { .then(function (response) {

View file

@ -97,7 +97,6 @@
</div> </div>
{% endblock %} {% block scripts %} {% endblock %} {% block scripts %}
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
<script> <script>
Vue.component(VueQrcode.name, VueQrcode) Vue.component(VueQrcode.name, VueQrcode)

View file

@ -42,8 +42,10 @@ async def api_copilot_create_or_update(
copilot_id: str = Query(None), copilot_id: str = Query(None),
wallet: WalletTypeInfo = Depends(get_key_type), wallet: WalletTypeInfo = Depends(get_key_type),
): ):
print(data)
if not copilot_id: if not copilot_id:
copilot = await create_copilot(data, user=wallet.wallet.user) copilot = await create_copilot(data, inkey=wallet.wallet.inkey)
return copilot, HTTPStatus.CREATED return copilot, HTTPStatus.CREATED
else: else:
copilot = await update_copilot(data, copilot_id=copilot_id) copilot = await update_copilot(data, copilot_id=copilot_id)
@ -53,7 +55,8 @@ async def api_copilot_create_or_update(
@copilot_ext.get("/api/v1/copilot", response_class=HTMLResponse) @copilot_ext.get("/api/v1/copilot", response_class=HTMLResponse)
async def api_copilots_retrieve(wallet: WalletTypeInfo = Depends(get_key_type)): async def api_copilots_retrieve(wallet: WalletTypeInfo = Depends(get_key_type)):
try: try:
return [{copilot} for copilot in await get_copilots(wallet.wallet.user)] print(wallet.wallet.user)
return [copilot.dict() for copilot in await get_copilots(wallet.wallet.user)]
except: except:
return "" return ""