问:
Active Sidebar in React js
```<code>import React from "react";
import "./sidebar.css";
import { Link, NavLink } from "react-router-dom";
import { MdDashboard } from "react-icons/md";
import {
  FaUserAlt,
  FaListAlt,
} from "react-icons/fa";

const Sidebar = () => {
    return (
      <section className="component-sidebar">
        <div className="component-sidebar-nav">
          <ul>
            <li>
              <Link to="/">
                <div className="component-sidebar-nav-icon">
                  <MdDashboard />
                </div>
                <div>Dashboard</div>
              </Link>
            </li>

            <li>
              <Link to="/my-profile">
                <div className="component-sidebar-nav-icon">
                  <FaUserAlt />
                </div>
                <div>Profile</div>
              </Link>
            </li>

            <li>
              <Link to="/my-courses">
                <div className="component-sidebar-nav-icon">
                  <FaListAlt />
                </div>
                <div>My Courses</div>
              </Link>
            </li>
          </ul>
        </div>
      </section>
    );
}

export default Sidebar;
</code>```

I want to make active side bar, but didn't find any solution. I don't want to use NavLink.I want to make it custom in React js.

If anyone help me. I really appreciate it.  Looking for a solution.
Thanks in Advance.

Title: Active Sidebar in React js

Body:
import React from "react";
import "./sidebar.css";
import { Link, NavLink } from "react-router-dom";
import { MdDashboard } from "react-icons/md";
import {
  FaUserAlt,
  FaListAlt,
} from "react-icons/fa";

const Sidebar = () => {
    return (

              <Link to="/">

                  <MdDashboard />

Dashboard

              </Link>

              <Link to="/my-profile">

                  <FaUserAlt />

Profile

              </Link>

              <Link to="/my-courses">

                  <FaListAlt />

My Courses

              </Link>

    );
}

export default Sidebar;

I want to make active side bar, but didn't find any solution. I don't want to use NavLink.I want to make it custom in React js.

If anyone help me. I really appreciate it.  Looking for a solution.
Thanks in Advance.


来源: stackexchange

问:
Manipulating dat in DB in Ui test
I have test case where i create a templates and as per the test case we need to back date the dates so doing it manually first  i go to db and change my date created to 10 days before and check if email is sent or not.
Is this kind of scnarios good to automate?? Usng selenium. Doing this kind of case is good practice or not.

Please share me your views on this

ContentLicense: CC BY-SA 4.0

Title: Manipulating dat in DB in Ui test


问:
Run ADX script on cluster scope with bicep
I use Azure Devops pipelines. You can run a script on the database level with Bicep, that is listed clearly in the documents. But I want to run a script on cluster level to update the workload_group policy to increase the allowed concurrent queries. But when running the query as part of the bicep deployment (on the database script property) to alter this it results in the following error:
Reason: Not a database-scope command

How can I run this query (that should indeed be run on a cluster level) as part of the bicep deployment? I use the following query, that does work when running it in the query window in Azure Portal.

```<code>.create-or-alter workload_group ['default'] ```
   <<workgroupConfig>>
```.

</code>```

I also know there are tasks for Azure Devops for running scripts against the database, but I would not like to use those since data explorer is in a private network and not accessible publicly.

Body:
I use Azure Devops pipelines. You can run a script on the database level with Bicep, that is listed clearly in the documents. But I want to run a script on cluster level to update the workload_group policy to increase the allowed concurrent queries. But when running the query as part of the bicep deployment (on the database script property) to alter this it results in the following error:
Reason: Not a database-scope command

How can I run this query (that should indeed be run on a cluster level) as part of the bicep deployment? I use the following query, that does work when running it in the query window in Azure Portal.

.create-or-alter workload_group ['default'] ```
   <<workgroupConfig>>
```.

I also know there are tasks for Azure Devops for running scripts against the database, but I would not like to use those since data explorer is in a private network and not accessible publicly.


问:
How to create a PDF file from a non-English (Persian) text using fpdf in Python?
I want to write a Farsi text and create its 'PDF' file. I installed and used the fpdf module, but I got an error.

```<code>from fpdf import FPDF
def export_pdf():
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=15)
    pdf.cell(200, 10, txt='این متن فارسی است.', ln=1, align='R')
    pdf.output('output.pdf')
</code>```

Error is:

```<code>UnicodeEncodeError: 'latin-1' codec can't encode characters in position 51-53: ordinal not in range(256)
</code>```

Do you have any solution?

My code:

Body:
I want to write a Farsi text and create its 'PDF' file. I installed and used the fpdf module, but I got an error.

from fpdf import FPDF
def export_pdf():
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=15)
    pdf.cell(200, 10, txt='این متن فارسی است.', ln=1, align='R')
    pdf.output('output.pdf')

Error is:

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 51-53: ordinal not in range(256)

Do you have any solution?

My code:


问:
matplotlib animate not updating different farg types
Trying to run a matplotlib animate toy example with 3 fargs, where z is an integer, list_ is a list, and bool_ is False. On each frame iteration in animate(), I was expecting each farg to update iteratively, using the result from the previous frame iteration. i.e. on the first frame iteration we would see:

z=4, list_=['hi'] and bool_=True

on the second frame iteration we would then see:

z=25, list_=['hi', 'hi'], and bool_=False

However, I am seeing something like this instead:

Why are the fargs z and bool_ not being updated (it is simply taking z=1 and bool_=False on each iteration as defined outside, disregarding the result from the previous frame iteration), whereas list_ is being updated with the result list_ from the previous frame? I have also tried updating a dictionary in the same manner, and it does update the same way as list_ does.

Code:

```<code>from matplotlib import pyplot as plt
from matplotlib import animation
import random

fig = plt.figure()
ax = plt.axes(xlim=(0, 100), ylim=(0, 300))
line, = ax.plot([], [], lw=2)
line2, = ax.plot([], [], lw=2)

x1 = []
y1 = []
x2 = []
y2 = []

z = 1
list_ = []
bool_ = False

def init():
    line.set_data([], [])
    line2.set_data([], [])
    return line, line2,

def update_z(z):
    return (z+1)**2

def update_bool(bool_):
    return not bool_

def update_list(list_):
    list_.append('hi')
    return list_

def animate(i, z, list_, bool_):
    z = update_z(z)
    list_ = update_list(list_)
    bool_ = update_bool(bool_)
    print(f'i: {i}, z: {z}, list_: {list_}, bool_: {bool_}')

    x1.append(i + 1)
    x2.append(i + 1)
    y1.append(random.randint(1,100))
    y2.append(random.randint(1,100))
    ax.set_xlim(i-50, i)
    line.set_data(x1, y1)
    line2.set_data(x2, y2)
    plt.legend(['line', 'line2'])
    return line, line2,

anim = animation.FuncAnimation(fig, animate, init_func=init, fargs=[z, list_, bool_],
                               frames=200, interval=10, repeat=False)

plt.show()
</code>```

Body:
Trying to run a matplotlib animate toy example with 3 fargs, where z is an integer, list_ is a list, and bool_ is False. On each frame iteration in animate(), I was expecting each farg to update iteratively, using the result from the previous frame iteration. i.e. on the first frame iteration we would see:

z=4, list_=['hi'] and bool_=True

on the second frame iteration we would then see:

z=25, list_=['hi', 'hi'], and bool_=False

However, I am seeing something like this instead:

Why are the fargs z and bool_ not being updated (it is simply taking z=1 and bool_=False on each iteration as defined outside, disregarding the result from the previous frame iteration), whereas list_ is being updated with the result list_ from the previous frame? I have also tried updating a dictionary in the same manner, and it does update the same way as list_ does.

Code:

from matplotlib import pyplot as plt
from matplotlib import animation
import random

fig = plt.figure()
ax = plt.axes(xlim=(0, 100), ylim=(0, 300))
line, = ax.plot([], [], lw=2)
line2, = ax.plot([], [], lw=2)

x1 = []
y1 = []
x2 = []
y2 = []

z = 1
list_ = []
bool_ = False

def init():
    line.set_data([], [])
    line2.set_data([], [])
    return line, line2,

def update_z(z):
    return (z+1)**2

def update_bool(bool_):
    return not bool_

def update_list(list_):
    list_.append('hi')
    return list_

def animate(i, z, list_, bool_):
    z = update_z(z)
    list_ = update_list(list_)
    bool_ = update_bool(bool_)
    print(f'i: {i}, z: {z}, list_: {list_}, bool_: {bool_}')

    x1.append(i + 1)
    x2.append(i + 1)
    y1.append(random.randint(1,100))
    y2.append(random.randint(1,100))
    ax.set_xlim(i-50, i)
    line.set_data(x1, y1)
    line2.set_data(x2, y2)
    plt.legend(['line', 'line2'])
    return line, line2,

anim = animation.FuncAnimation(fig, animate, init_func=init, fargs=[z, list_, bool_],
                               frames=200, interval=10, repeat=False)

plt.show()


问:
Creating batch file from a cmd command
Made a simple batch file that pings google.com and saves/updates the results to a txt file as it is performing the ping command.

cmd command that works:

```<code>ping google.com -t > C:\Scripts\PingTestResults.txt
</code>```

I then copied this to a batch file and it is showing as this when running it,

```<code>ping google.com -t 1>C:\Scipts\PingTestResults.txt
</code>```

This results in the ping timing out

I tried removing spaces in between -t and the > as well as changing location of where the batch file was running from.

Title: Creating batch file from a cmd command

Body:
Made a simple batch file that pings google.com and saves/updates the results to a txt file as it is performing the ping command.

cmd command that works:

ping google.com -t > C:\Scripts\PingTestResults.txt

I then copied this to a batch file and it is showing as this when running it,

ping google.com -t 1>C:\Scipts\PingTestResults.txt

This results in the ping timing out

I tried removing spaces in between -t and the > as well as changing location of where the batch file was running from.


问:
Rstudio customization: how to hide functions in "jump to" menu?
I would like to hide the functions from the menu in the bottom-left corner of the code pane in Rstudio, which I would like to use to only jump to sections (indeed I would like the button to be bigger too, but that is another thing).

It is especially annoying to me because in some codes I define a lot of "ad-hoc" functions inside other function, e.g. inside lapply, so the "jump to" menu becomes a useless collection of "(i)" entries.


问:
Standardize textual data in a python dataframe
I have a data frame df which consists of supplier information (data at the invoice level). Suppliers sometimes have non-standard names, for eg:

Invoice no.
Product name
Supplier Name

1
product 1
Pepsico

2
product 2
Pepsi

3
product 3
Peppsi

4
product 4
Mountain Dew

All of the above rows have the same supplier - Pepsi, but it has been registered with different names. How do I identify such kinds of rows to standardize all such entries?


问:
Replace (whole word only) that works for all possible keyboard-character combinations in a string?
I am trying to find a non-deprecated method of comparing two strings in Typescript and/or Javascript that can handle any string that can be generated using the special characters available on a standard keyboard, because our application is fetching a randomly generated password from the backend then displaying that in our PASSWORD and CONFIRM PASSWORD fields, instead of fetching the encrypted password from the DB and including it in the response, which could possibly be decrypted with enough effort by someone attempting to crack our password hashing algorithm.

It is comparing the PASSWORD to the CONFIRM PASSWORD and checking if they are equal using the 'eval()' function (because the validation condition is loaded from the DB, and could be "FIELD_1 > FIELD_2", not necessarily always equality checking. It does replacements using .replaceAll() on the condition based on form fields' current form value, then evaluates the conditions using eval(). However, replaceAll requires a regex, and regexes can't have certain special characters unescaped or else an error will occur.)

So, to try to find a solution that works for ALL strings/combinations of characters, I added code at the bottom of my question which will generate random strings and compare them for equality 3000 times, and if there are no issues, it will not print any failure messages. I noticed I can escape MOST strings successfully using the following:

```<code> function escapeSpecialCharactersInTestString(str: string) {
      str = str.replace(/\$/g, '$$$$');
      str = str.replace(/[']/g, "\\'");
      return str;
 }
</code>```

However, it is still failing for strings like
\3aeB296Z=DH\D"]Yu[0;MC.dep.UeE8g]&}sz)6N|M?.]q:%/ because of the \3 giving the error Octal escape sequences are not allowed in strict mode. I don't want to have to disable strict mode somehow and shouldn't be required to. However, if I use the deprecated "escape()" function instead, it always works.

```<code> function escapeSpecialCharactersInTestString(str: string) {
      return escape(str)
 }
</code>```

Looking for a solution that can replace any sequence of characters / any string, and I don't want to worry about using deprecated code.

Code that tests 3000 equal, randomly generated strings for equality and stops if it can't compare them:

```<code> const normalCharacters =
   "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 const specialCharacters = "@:;#&-?/%+*[]\\_=^!()|{}\",.";

 function escapeSpecialCharactersInTestString(str: string) {
      // console.log(str)
      // WORKS 100% but is deprecated:
      // str = escape(str)

      str = str.replace(/\$/g, '$$$$');
      str = str.replace(/[']/g, "\\'");
      return str;
 }

 function generateRandomString(length: number) {
   let characterList = normalCharacters + specialCharacters;
   let result = "";
   while (length > 0) {
     let index = Math.floor(Math.random() * characterList.length);
     result += characterList[index];
     length--;
   }
   return result;
 }

 function evaluateConditionWithTrueOrFalseResult(testString: string) {

   let conditionResult = false
   let evalResult;
   try {
     evalResult = eval(testString);
   } catch (e) {
     console.log(e)
   }

   if (evalResult == true) {
     conditionResult = true
   } else if (evalResult == false) {
     conditionResult = false
   } else {
     conditionResult = false
   }
   return conditionResult
 }

 function replaceAll(str: any, find: any, replace: any) {
   //console.log("str: ",str,", find: ",find,", replace: ",replace)

   if(str == null) {
     return str;
   }

   if(find !== undefined && find !== null && find !== '' && find !== true && find !== false && !isDate(find) && isNaN(find)) {
     find = escapeSpecialCharactersInTestString(find)
   }

   if(replace !== undefined && replace !== null && replace !== '' && replace !== true && replace !== false && !isDate(replace) && isNaN(replace)) {
     //console.log("escaping special chars: ",replace)
     replace = escapeSpecialCharactersInTestString(replace)
     //console.log("after: ",replace)
   }

   // replaces whole word only because of the \\b 's
   return str.replace(new RegExp('\\b' + find + '\\b', "g"),replace);
 }

 function isDate(val: any) {
   let isDate = false
   if(val !== undefined && val !== null) {
     if(typeof val === 'object') {
       if(val._isAMomentObject === true) {
         isDate = true
       }
     }
     if(Object.prototype.toString.call(val) === '[object Date]') {
       isDate = true
     }
   }
   // console.log("is ",val," a date: ",isDate)
   return isDate
 }

 let myOrigString = "'PASSWORD' === 'CONFIRM_PASSWORD'";
 for (let i = 0; i < 3000; i++) {
   let formValue = generateRandomString(50)
   let escapedFormValue = escapeSpecialCharactersInTestString(formValue)

   let myReplacedString = replaceAll(myOrigString, 'PASSWORD', escapedFormValue)
   myReplacedString = replaceAll(myReplacedString, 'CONFIRM_PASSWORD', escapedFormValue)

   if (i > 0 && i % 100 == 0) {
     console.log("at iteration: "+i)
   }

   if (evaluateConditionWithTrueOrFalseResult(myReplacedString) === false) {
     console.log(myReplacedString, " failed at iteration: " + i)
     break;
   }

 }

</code>```

Body:
I am trying to find a non-deprecated method of comparing two strings in Typescript and/or Javascript that can handle any string that can be generated using the special characters available on a standard keyboard, because our application is fetching a randomly generated password from the backend then displaying that in our PASSWORD and CONFIRM PASSWORD fields, instead of fetching the encrypted password from the DB and including it in the response, which could possibly be decrypted with enough effort by someone attempting to crack our password hashing algorithm.

It is comparing the PASSWORD to the CONFIRM PASSWORD and checking if they are equal using the 'eval()' function (because the validation condition is loaded from the DB, and could be "FIELD_1 > FIELD_2", not necessarily always equality checking. It does replacements using .replaceAll() on the condition based on form fields' current form value, then evaluates the conditions using eval(). However, replaceAll requires a regex, and regexes can't have certain special characters unescaped or else an error will occur.)

So, to try to find a solution that works for ALL strings/combinations of characters, I added code at the bottom of my question which will generate random strings and compare them for equality 3000 times, and if there are no issues, it will not print any failure messages. I noticed I can escape MOST strings successfully using the following:

 function escapeSpecialCharactersInTestString(str: string) {
      str = str.replace(/\$/g, '$$$$');
      str = str.replace(/[']/g, "\\'");
      return str;
 }

However, it is still failing for strings like
\3aeB296Z=DH\D"]Yu[0;MC.dep.UeE8g]&}sz)6N|M?.]q:%/ because of the \3 giving the error Octal escape sequences are not allowed in strict mode. I don't want to have to disable strict mode somehow and shouldn't be required to. However, if I use the deprecated "escape()" function instead, it always works.

 function escapeSpecialCharactersInTestString(str: string) {
      return escape(str)
 }

Looking for a solution that can replace any sequence of characters / any string, and I don't want to worry about using deprecated code.

Code that tests 3000 equal, randomly generated strings for equality and stops if it can't compare them:

 const normalCharacters =
   "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 const specialCharacters = "@:;#&-?/%+*[]\\_=^!()|{}\",.";

 function escapeSpecialCharactersInTestString(str: string) {
      // console.log(str)
      // WORKS 100% but is deprecated:
      // str = escape(str)

      str = str.replace(/\$/g, '$$$$');
      str = str.replace(/[']/g, "\\'");
      return str;
 }

 function generateRandomString(length: number) {
   let characterList = normalCharacters + specialCharacters;
   let result = "";
   while (length > 0) {
     let index = Math.floor(Math.random() * characterList.length);
     result += characterList[index];
     length--;
   }
   return result;
 }

 function evaluateConditionWithTrueOrFalseResult(testString: string) {

   let conditionResult = false
   let evalResult;
   try {
     evalResult = eval(testString);
   } catch (e) {
     console.log(e)
   }

   if (evalResult == true) {
     conditionResult = true
   } else if (evalResult == false) {
     conditionResult = false
   } else {
     conditionResult = false
   }
   return conditionResult
 }

 function replaceAll(str: any, find: any, replace: any) {
   //console.log("str: ",str,", find: ",find,", replace: ",replace)

   if(str == null) {
     return str;
   }

   if(find !== undefined && find !== null && find !== '' && find !== true && find !== false && !isDate(find) && isNaN(find)) {
     find = escapeSpecialCharactersInTestString(find)
   }

   if(replace !== undefined && replace !== null && replace !== '' && replace !== true && replace !== false && !isDate(replace) && isNaN(replace)) {
     //console.log("escaping special chars: ",replace)
     replace = escapeSpecialCharactersInTestString(replace)
     //console.log("after: ",replace)
   }

   // replaces whole word only because of the \\b 's
   return str.replace(new RegExp('\\b' + find + '\\b', "g"),replace);
 }

 function isDate(val: any) {
   let isDate = false
   if(val !== undefined && val !== null) {
     if(typeof val === 'object') {
       if(val._isAMomentObject === true) {
         isDate = true
       }
     }
     if(Object.prototype.toString.call(val) === '[object Date]') {
       isDate = true
     }
   }
   // console.log("is ",val," a date: ",isDate)
   return isDate
 }

 let myOrigString = "'PASSWORD' === 'CONFIRM_PASSWORD'";
 for (let i = 0; i < 3000; i++) {
   let formValue = generateRandomString(50)
   let escapedFormValue = escapeSpecialCharactersInTestString(formValue)

   let myReplacedString = replaceAll(myOrigString, 'PASSWORD', escapedFormValue)
   myReplacedString = replaceAll(myReplacedString, 'CONFIRM_PASSWORD', escapedFormValue)

   if (i > 0 && i % 100 == 0) {
     console.log("at iteration: "+i)
   }

   if (evaluateConditionWithTrueOrFalseResult(myReplacedString) === false) {
     console.log(myReplacedString, " failed at iteration: " + i)
     break;
   }

 }


问:
Android SurfaceView gets disconnecting from surface, reason connectToSurface(reconnect) using Compose's AndoridView
I am playing around with jetpack compose and surface view and I often land into this issue where in the surfaceview gets randomly disconnected from surface. I've added the stack trace for reference. Can someone help me to fix this?</p>
```<code>java.lang.IllegalArgumentException: detached
    at MobilePlayerViewModel$createSurfaceViewOnAttachStateChangeListener$1.onViewDetachedFromWindow(MobilePlayerViewModel.kt:356)
    at android.view.View.dispatchDetachedFromWindow(View.java:21362)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3949)
    at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:5785)
    at androidx.compose.ui.viewinterop.AndroidViewHolder.setView$ui_release(AndroidViewHolder.android.kt:95)
    at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:310)
    at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:307)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:420)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.onChildRemoved(LayoutNode.kt:314)
    at androidx.compose.ui.node.LayoutNode.removeAt$ui_release(LayoutNode.kt:288)
    at androidx.compose.ui.node.UiApplier.remove(UiApplier.android.kt:35)
    at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
    at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
    at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:808)
    at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:839)
    at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:995)
    at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
    at androidx.compose.runtime.Recomposer$HotReloadable.clearContent(Recomposer.kt:385)
    at androidx.compose.runtime.Recomposer$RecomposerInfoImpl.saveStateAndDisposeForHotReload(Recomposer.kt:369)
    at androidx.compose.runtime.Recomposer$Companion.saveStateAndDisposeForHotReload$runtime_release(Recomposer.kt:1285)
    at androidx.compose.runtime.HotReloader$Companion.saveStateAndDispose(Composition.kt:1136)
    at dalvik.system.VMDebug.nativeAttachAgent(Native Method)
    at dalvik.system.VMDebug.attachAgent(VMDebug.java:656)
    at android.app.ActivityThread.attemptAttachAgent(ActivityThread.java:4220)
    at android.app.ActivityThread.handleAttachAgent(ActivityThread.java:4230)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2296)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7898)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
</code>```

Body:
I am playing around with jetpack compose and surface view and I often land into this issue where in the surfaceview gets randomly disconnected from surface. I've added the stack trace for reference. Can someone help me to fix this?

java.lang.IllegalArgumentException: detached
    at MobilePlayerViewModel$createSurfaceViewOnAttachStateChangeListener$1.onViewDetachedFromWindow(MobilePlayerViewModel.kt:356)
    at android.view.View.dispatchDetachedFromWindow(View.java:21362)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3949)
    at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:5785)
    at androidx.compose.ui.viewinterop.AndroidViewHolder.setView$ui_release(AndroidViewHolder.android.kt:95)
    at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:310)
    at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:307)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:420)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
    at androidx.compose.ui.node.LayoutNode.onChildRemoved(LayoutNode.kt:314)
    at androidx.compose.ui.node.LayoutNode.removeAt$ui_release(LayoutNode.kt:288)
    at androidx.compose.ui.node.UiApplier.remove(UiApplier.android.kt:35)
    at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
    at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
    at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:808)
    at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:839)
    at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:995)
    at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
    at androidx.compose.runtime.Recomposer$HotReloadable.clearContent(Recomposer.kt:385)
    at androidx.compose.runtime.Recomposer$RecomposerInfoImpl.saveStateAndDisposeForHotReload(Recomposer.kt:369)
    at androidx.compose.runtime.Recomposer$Companion.saveStateAndDisposeForHotReload$runtime_release(Recomposer.kt:1285)
    at androidx.compose.runtime.HotReloader$Companion.saveStateAndDispose(Composition.kt:1136)
    at dalvik.system.VMDebug.nativeAttachAgent(Native Method)
    at dalvik.system.VMDebug.attachAgent(VMDebug.java:656)
    at android.app.ActivityThread.attemptAttachAgent(ActivityThread.java:4220)
    at android.app.ActivityThread.handleAttachAgent(ActivityThread.java:4230)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2296)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7898)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)


问:
How to deploy a Quarkus application on openshift with rolling strategy
How to deploy a quarkus application to a openshift namespace using the rolling deployment strategy?
In my case always the the previous pod will be tear down first.

I would expect some property to define the used deployment strategy.

Currently I use maven to deploy the application

```<code>mvn clean package -Dquarkus.kubernetes.deploy=true -Dquarkus.openshift.namespace=my_target_namespace
</code>```

Body:
How to deploy a quarkus application to a openshift namespace using the rolling deployment strategy?
In my case always the the previous pod will be tear down first.

I would expect some property to define the used deployment strategy.

Currently I use maven to deploy the application

mvn clean package -Dquarkus.kubernetes.deploy=true -Dquarkus.openshift.namespace=my_target_namespace


问:
KSQLDB Create Stream Select AS with Headers
Is there a way in KsqlDB to add headers while creating a stream from AS SELECT?

For example, I have a stream DomainOrgs(DomainId INT,OrgId INT,someId INT), now I need to create a stream with all the values in DomainOrgs also DomainId should go to Header

I tried to create like

```<code>CREATE STREAM DomainOrgs_with_header AS
SELECT DomainId,
       OrgId,
       someId,
       DomainId HEADER('DomainId')
  FROM DomainOrgs
    EMIT CHANGES;
</code>```

Also tried

```<code>CREATE STREAM DomainOrgs_with_header
(
   DomainId INT,
   OrgId INT,
   someId INT,
   DomainId_Header Header('DomainId')
)

INSERT INTO DomainOrgs_with_header
SELECT DomainId,OrgId,someId,DomainId FROM DomainOrgs
</code>```

Here, stream will create but INSERT INTO will fail.

Is there any way to select data into the stream with headers?

Body:
Is there a way in KsqlDB to add headers while creating a stream from AS SELECT?

For example, I have a stream DomainOrgs(DomainId INT,OrgId INT,someId INT), now I need to create a stream with all the values in DomainOrgs also DomainId should go to Header

I tried to create like

CREATE STREAM DomainOrgs_with_header AS
SELECT DomainId,
       OrgId,
       someId,
       DomainId HEADER('DomainId')
  FROM DomainOrgs
    EMIT CHANGES;

Also tried

CREATE STREAM DomainOrgs_with_header
(
   DomainId INT,
   OrgId INT,
   someId INT,
   DomainId_Header Header('DomainId')
)

INSERT INTO DomainOrgs_with_header
SELECT DomainId,OrgId,someId,DomainId FROM DomainOrgs

Here, stream will create but INSERT INTO will fail.

Is there any way to select data into the stream with headers?


问:
How to play a sound after a dispatch without user interaction
I'm trying to play a song when an action is being dispatched. There is no user interaction and the action is being triggered by an external API, so the user never needs to do anything, the display of the screen changes automatically.

This is my code :

```<code>    newAppointmentsCalled.forEach((appointment) => {
      const appointmentIsNotYetCalled =
        appointmentsCalled.findIndex((a) => a.id === appointment.id) === -1
      if (appointmentIsNotYetCalled) {
        dispatch({
          type: 'PATIENT_CALLED',
          payload: appointment,
        })
        sound.play()
      }
    })
</code>```

I'm inside a useEffect, I tried to add a setTimeout but this doesn't change anything, I still get the error :

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.

Any help is highly appreciated

Body:
I'm trying to play a song when an action is being dispatched. There is no user interaction and the action is being triggered by an external API, so the user never needs to do anything, the display of the screen changes automatically.

This is my code :

    newAppointmentsCalled.forEach((appointment) => {
      const appointmentIsNotYetCalled =
        appointmentsCalled.findIndex((a) => a.id === appointment.id) === -1
      if (appointmentIsNotYetCalled) {
        dispatch({
          type: 'PATIENT_CALLED',
          payload: appointment,
        })
        sound.play()
      }
    })

I'm inside a useEffect, I tried to add a setTimeout but this doesn't change anything, I still get the error :

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.

Any help is highly appreciated


问:
Strapi on Windows, error EACCES on port 80
```<code>Strapi Version: 4.4.5
Operating System: Windows 2022 Datacenter + Plesk Obsidian 18.0.48
Database: MariaDB 10.6.9
Node Version: 16.16
NPM Version: 8.19.2
Yarn Version: N/A
</code>```

Error : listen EACCES: permission denied 0.0.0.0:80

-> server.js

```<code>module.exports = ({env}) => ({
  host: '0.0.0.0',
  port: 8081,
  app: {
    keys: env.array('APP_KEYS'),
  },
});

</code>```

-> package.json

```<code>  "dependencies": {
    "@strapi/plugin-i18n": "4.4.5",
    "@strapi/plugin-users-permissions": "4.4.5",
    "@strapi/strapi": "4.4.5",
    "better-sqlite3": "7.4.6",
    "cross-env": "^7.0.3",
    "mysql": "^2.18.1"
  },
  "engines": {
    "node": ">=14.19.1 <=18.x.x",
    "npm": ">=6.0.0"
  },

</code>```

Hi,
if use port 8081, application run in localhost:8081, but if use my domain xyz.com:8081, i have this error :

-> localhost : 80

```<code>$ npm run-script start

> plesk-strapi@0.1.0 start
> strapi start

 Project information

┌────────────────────┬──────────────────────────────────────────────────┐
│ Time               │ Tue Jan 10 2023 16:05:06 GMT+0100 (heure normal… │
│ Launched in        │ 1628 ms                                          │
│ Environment        │ development                                      │
│ Process PID        │ 11532                                            │
│ Version            │ 4.4.5 (node v16.19.0)                            │
│ Edition            │ Community                                        │

Actions available

Welcome back!
To manage your project , go to the administration panel at:
http://localhost:8081/admin

To access the server , go to:
http://localhost:8081
</code>```

-> xyz.com : 8081

```<code>HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1002
HTTP reason: Internal Server Error
Application has thrown an uncaught exception and is terminated:
TypeError: process.send is not a function
    at Strapi.stop (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\@strapi\strapi\lib\Strapi.js:321:15)
    at Strapi.stopWithError (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\@strapi\strapi\lib\Strapi.js:314:17)
    at Server.<anonymous> (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\@strapi\strapi\lib\services\server\http-server.js:31:21)
    at Server.emit (node:events:513:28)
    at emitErrorNT (node:net:1490:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
</code>```

if change for port 80,  localhost & online not runing, i have this error :

-> localhost : 80

```<code>$ npm run-script start

> plesk-strapi@0.1.0 start
> strapi start

[2023-01-10 16:02:29.555] error: listen EACCES: permission denied 0.0.0.0:80
Error: listen EACCES: permission denied 0.0.0.0:80
    at Server.setupListenHandle [as _listen2] (node:net:1446:21)
    at listenInCluster (node:net:1511:12)
    at doListen (node:net:1660:7)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)
</code>```

-> xyz.com : 80

```<code>(node:10548) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
</code>```

Body:
Strapi Version: 4.4.5
Operating System: Windows 2022 Datacenter + Plesk Obsidian 18.0.48
Database: MariaDB 10.6.9
Node Version: 16.16
NPM Version: 8.19.2
Yarn Version: N/A

Error : listen EACCES: permission denied 0.0.0.0:80

-> server.js

module.exports = ({env}) => ({
  host: '0.0.0.0',
  port: 8081,
  app: {
    keys: env.array('APP_KEYS'),
  },
});

-> package.json

  "dependencies": {
    "@strapi/plugin-i18n": "4.4.5",
    "@strapi/plugin-users-permissions": "4.4.5",
    "@strapi/strapi": "4.4.5",
    "better-sqlite3": "7.4.6",
    "cross-env": "^7.0.3",
    "mysql": "^2.18.1"
  },
  "engines": {
    "node": ">=14.19.1 <=18.x.x",
    "npm": ">=6.0.0"
  },

Hi,
if use port 8081, application run in localhost:8081, but if use my domain xyz.com:8081, i have this error :

-> localhost : 80

$ npm run-script start

> plesk-strapi@0.1.0 start
> strapi start

 Project information

┌────────────────────┬──────────────────────────────────────────────────┐
│ Time               │ Tue Jan 10 2023 16:05:06 GMT+0100 (heure normal… │
│ Launched in        │ 1628 ms                                          │
│ Environment        │ development                                      │
│ Process PID        │ 11532                                            │
│ Version            │ 4.4.5 (node v16.19.0)                            │
│ Edition            │ Community                                        │

Actions available

Welcome back!
To manage your project , go to the administration panel at:
http://localhost:8081/admin

To access the server , go to:
http://localhost:8081

-> xyz.com : 8081

HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1002
HTTP reason: Internal Server Error
Application has thrown an uncaught exception and is terminated:
TypeError: process.send is not a function
    at Strapi.stop (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\@strapi\strapi\lib\Strapi.js:321:15)
    at Strapi.stopWithError (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\@strapi\strapi\lib\Strapi.js:314:17)
    at Server.<anonymous> (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\@strapi\strapi\lib\services\server\http-server.js:31:21)
    at Server.emit (node:events:513:28)
    at emitErrorNT (node:net:1490:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

if change for port 80,  localhost & online not runing, i have this error :

-> localhost : 80

$ npm run-script start

> plesk-strapi@0.1.0 start
> strapi start

[2023-01-10 16:02:29.555] error: listen EACCES: permission denied 0.0.0.0:80
Error: listen EACCES: permission denied 0.0.0.0:80
    at Server.setupListenHandle [as _listen2] (node:net:1446:21)
    at listenInCluster (node:net:1511:12)
    at doListen (node:net:1660:7)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

-> xyz.com : 80

(node:10548) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)


问:
FragmentStateAdapter to create Tab can be stacked as layer in Kotlin?
I have 3 tabs made with FragmentStateAdapter.

```<code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff">

    <androidx.viewpager2.widget.ViewPager2
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/tabLayout" />

        <com.google.android.material.tabs.TabLayout
            app:tabIconTint="@color/tab_icon_color"
            app:tabTextColor="@color/text_color"
            app:tabBackground="@drawable/tab_background"
            app:tabTextAppearance="@style/TabFont"
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            app:tabMaxWidth="0dp"
            app:tabGravity="fill"
            app:tabIndicatorColor="@color/main_color">

            <com.google.android.material.tabs.TabItem
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="내 일기" />

            <com.google.android.material.tabs.TabItem
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="우리 일기" />

            <com.google.android.material.tabs.TabItem
                android:layout_width="20dp"
                android:layout_height="wrap_content"
                android:icon="@drawable/ic_hamburger" />

        </com.google.android.material.tabs.TabLayout>
</RelativeLayout>
</code>```

I have ViewPager2 over TabLayout with 3 TabItmes.

Each TabItem is liked to 3 Fragment by each.

If I click Tab 2, It slides from Tab1 to Tab2 well.

My question is can I make Tab 2 to 3, then 3 Fragment has transparent screen and it shows previous 2 fragment screen on back.

Which means tab3 fragment should be stacked over tab2 fragment.

Now it just slides from to each, It doesn't have previous screen.

Can I make this idea?

Body:
I have 3 tabs made with FragmentStateAdapter.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff">

    <androidx.viewpager2.widget.ViewPager2
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/tabLayout" />

        <com.google.android.material.tabs.TabLayout
            app:tabIconTint="@color/tab_icon_color"
            app:tabTextColor="@color/text_color"
            app:tabBackground="@drawable/tab_background"
            app:tabTextAppearance="@style/TabFont"
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            app:tabMaxWidth="0dp"
            app:tabGravity="fill"
            app:tabIndicatorColor="@color/main_color">

            <com.google.android.material.tabs.TabItem
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="내 일기" />

            <com.google.android.material.tabs.TabItem
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="우리 일기" />

            <com.google.android.material.tabs.TabItem
                android:layout_width="20dp"
                android:layout_height="wrap_content"
                android:icon="@drawable/ic_hamburger" />

        </com.google.android.material.tabs.TabLayout>
</RelativeLayout>

I have ViewPager2 over TabLayout with 3 TabItmes.

Each TabItem is liked to 3 Fragment by each.

If I click Tab 2, It slides from Tab1 to Tab2 well.

My question is can I make Tab 2 to 3, then 3 Fragment has transparent screen and it shows previous 2 fragment screen on back.

Which means tab3 fragment should be stacked over tab2 fragment.

Now it just slides from to each, It doesn't have previous screen.

Can I make this idea?


问:
PYTHON - Get all URL in Chrome opened tabs
as a python newbie, I haven't found a way (on the Mac) to get all the open URLs in Chrome's tabs, then assign them one by one in a list.
Should I use Selenium? Webdriver? Thank you for your help.

I found that but it seems only works on Windows : Get Chrome tab URL in Python


问:
How to recover a branch on remote that has been deleted mistakenly by someone else in Git
Our team has placed the code repository on the Gitlab. Someone has deleted a branch on remote Gitlab repository by mistake. I was working on that branch and I have this branch locally on my system. Can anyone tell me how i can again restore this branch on remote. Can anyone guide me in this regard.</p>


问:
Why are my googleMaps not stacking like a gallery and lining up next to each other instead?
I want to create a gallery of googlemaps and use previous and next buttons to cycle through them.
However, instead of being in one after the other in a gallery they just appear next to each other in a row.

Html:

```<code><div class="maps-gallery">
        <iframe class ="maps-list active" src= [link] width="750" height="400" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
        <iframe class ="maps-list" src= [link] width="750" height="400" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
        <iframe class ="maps-list" src= [link] width="750" height="400" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
    </div>
<div class="buttons">
    <button disabled="" class="button prev">Prev</button>
    <button class="button next">Next</button>
</div>
</code>```

JavaScript:

```<code>const prevButton = document.querySelector('.prev')
const nextButton = document.querySelector('.next')
const mapsList = document.querySelectorAll('.maps-list')
let currentlySelected = 0;

prevButton.addEventListener('click', function() {
    mapsList[currentlySelected].classList.remove("active");
    currentlySelected--;
    mapsList[currentlySelected].classList.add("active");
    nextButton.disabled = false;
    if (currentlySelected === 0){
        prevButton.disabled=true
    }
});
nextButton.addEventListener('click', function() {
    mapsList[currentlySelected].classList.remove("active");
    currentlySelected++;
    mapsList[currentlySelected].classList.add('active')
    prevButton.disabled = false;
if (mapsList.length === currentlySelected + 1) {
    nextButton.disabled = true
}
</code>```

});

Body:
I want to create a gallery of googlemaps and use previous and next buttons to cycle through them.
However, instead of being in one after the other in a gallery they just appear next to each other in a row.

Html:

    <button disabled="" class="button prev">Prev</button>
    <button class="button next">Next</button>

JavaScript:

const prevButton = document.querySelector('.prev')
const nextButton = document.querySelector('.next')
const mapsList = document.querySelectorAll('.maps-list')
let currentlySelected = 0;

prevButton.addEventListener('click', function() {
    mapsList[currentlySelected].classList.remove("active");
    currentlySelected--;
    mapsList[currentlySelected].classList.add("active");
    nextButton.disabled = false;
    if (currentlySelected === 0){
        prevButton.disabled=true
    }
});
nextButton.addEventListener('click', function() {
    mapsList[currentlySelected].classList.remove("active");
    currentlySelected++;
    mapsList[currentlySelected].classList.add('active')
    prevButton.disabled = false;
if (mapsList.length === currentlySelected + 1) {
    nextButton.disabled = true
}

});


问:
Running OpenCV inside Apptainer with GPU support
I'm trying to run a OpenCV application inside an Apptainer container, in a remote machine, passing the --nv flag for granting GPU support. But then I get this error:

import cv2

ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34` not found (required by /.singularity.d/libs/libGLdispatch.so.0)
```

If I run the same container without the --nv flag, cv2 imports correctly, but then of course I loose the GPU access. The same container runs correctly on my local machine (with NVIDIA GPU) with --nv flag.

So, I suspect --nv flag specifically in my remote machine. It is probably binding incompatible libraries form the host to the container.

I was hoping someone with Apptainer (singularity) experience could help me figure out how to fix this for my remote machine, or at least point me in the right direction.
Thanks!

Body:
I'm trying to run a OpenCV application inside an Apptainer container, in a remote machine, passing the --nv flag for granting GPU support. But then I get this error:

import cv2

ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34` not found (required by /.singularity.d/libs/libGLdispatch.so.0)

If I run the same container without the --nv flag, cv2 imports correctly, but then of course I loose the GPU access. The same container runs correctly on my local machine (with NVIDIA GPU) with --nv flag.

So, I suspect --nv flag specifically in my remote machine. It is probably binding incompatible libraries form the host to the container.

I was hoping someone with Apptainer (singularity) experience could help me figure out how to fix this for my remote machine, or at least point me in the right direction.
Thanks!


问:
android application is exited when override function from custom view
I have a custom view and want to display it, however if I call the method from the custom view (setOnClickListener,...) the application will automatically exit, I don't know why and hope everyone answers.

```<code>public class MotionEventActivity extends AppCompatActivity{

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //MyView myView = new MyView(this);
        setContentView(R.layout.motion_view);
        MyView myView = findViewById(R.id.main);
        myView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

    }
}
</code>```

And here is the code of the custom view:

```<code>public class MyView extends View {
    public  Paint paint = null;
    public  int radius = 82;
    public  List<CoordinateButton> arrButton = new ArrayList<CoordinateButton>();
    MyView(Context context){
        this(context, null);
    }
    public MyView(Context context, AttributeSet attributeSet) {
        super(context);
        arrButton.add(new CoordinateButton("S",(float)46.0 , (float) 37.0,  1, "#F08080", "#DC143C", "#F08080"));
        arrButton.add(new CoordinateButton("H",(float)1866.0 , (float) 699.0,  4, "#F0E68C", "#FFFF00", "#F0E68C"));

        paint = new Paint();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        for(CoordinateButton button : arrButton){
            paint.setColor(Color.parseColor(button.getColorButton()));
            canvas.drawCircle(button.getXButton() + radius, button.getYButton() + radius, radius, paint);
            paint.setColor(Color.BLACK);
            paint.setTextSize(45);
            paint.setTextAlign(Paint.Align.CENTER);
            canvas.drawText(button.getTextButton(),button.getXButton() + radius, button.getYButton() + radius +15, paint);
        }

    }

 }
</code>```

And here is the code of the xml file:

```<code><?xml version="1.0" encoding="utf-8"?>
<com.example.motionevent.MyView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MotionEventActivity">

</com.example.motionevent.MyView>
</code>```

Body:
I have a custom view and want to display it, however if I call the method from the custom view (setOnClickListener,...) the application will automatically exit, I don't know why and hope everyone answers.

public class MotionEventActivity extends AppCompatActivity{

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //MyView myView = new MyView(this);
        setContentView(R.layout.motion_view);
        MyView myView = findViewById(R.id.main);
        myView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

    }
}

And here is the code of the custom view:

public class MyView extends View {
    public  Paint paint = null;
    public  int radius = 82;
    public  List<CoordinateButton> arrButton = new ArrayList<CoordinateButton>();
    MyView(Context context){
        this(context, null);
    }
    public MyView(Context context, AttributeSet attributeSet) {
        super(context);
        arrButton.add(new CoordinateButton("S",(float)46.0 , (float) 37.0,  1, "#F08080", "#DC143C", "#F08080"));
        arrButton.add(new CoordinateButton("H",(float)1866.0 , (float) 699.0,  4, "#F0E68C", "#FFFF00", "#F0E68C"));

        paint = new Paint();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        for(CoordinateButton button : arrButton){
            paint.setColor(Color.parseColor(button.getColorButton()));
            canvas.drawCircle(button.getXButton() + radius, button.getYButton() + radius, radius, paint);
            paint.setColor(Color.BLACK);
            paint.setTextSize(45);
            paint.setTextAlign(Paint.Align.CENTER);
            canvas.drawText(button.getTextButton(),button.getXButton() + radius, button.getYButton() + radius +15, paint);
        }

    }

 }

And here is the code of the xml file:

<?xml version="1.0" encoding="utf-8"?>
<com.example.motionevent.MyView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MotionEventActivity">

</com.example.motionevent.MyView>


问:
extract counting sorting and look-up
I have a dataset with a rowID and a column 'items' that contains numbers delimited with commas.
Each number represents a specific item.
"1" stands for "B" and so on.

For each row, I want to calculate the individual weignt of each item.
To illustrate :
"1,18,18,1" or "18,18,1,1" has an equivalent weight than "18,1", "1,18", etc. with 1 and 18 valuing 50% of the weight.

The goal is to retrieve the final weigh into an output variable that will contain the "B" in wase  100% of the weight of item "1" in row. The 100% is the easiest case. When having 25% of "6" (which stands for "T") , 50 % of "1" (which stands for "B") and 25 % of "5" (which stands for "C") I want to get "TBCB" in the output final variable .

So far, I have created en column 'comp' that counts the numbers ("items") delimited by the commas in the "items" column.

I've created a % column representing the weight of each item.

My difficulty is to handle the final variable  : assembling the percentages so as to create the new sequence.

```<code>library(dplyr)library(stringr)

df = data.frame(
items =c(as.character("1,1,8,16,8,18,18,1,16,2,8,5,1","2,1,2,1,6"),
as.character("18,18,19,18,4"), as.character("1,19,2"),
as.character("2,2,2,4,2,6,1" )  , as.character("6,2,2") ,
ID = seq(1:5)
)
</code>```
```<code>df1 <- df %>%mutate( comp = str_count(items, ",") + 1) %>%
  mutate (percentB = str_count(items , "1") / comp *100) %>%
  mutate (percentM = str_count(items , "2") / comp *100) %>%
  mutate (percentO = str_count(items , "3") / comp *100) %>%
  mutate (percentAC = str_count(items , "4") / comp *100) %>%
  mutate (percentC = str_count(items , "5") / comp *100) %>%
  mutate (percentT = str_count(items , "6") / comp *100) %>%
  mutate (percentPp = str_count(items , "18") / comp *100) %>%
  mutate (percentPt = str_count(items , "19") / comp *100)
</code>```
```<code>df2 <- df1 <- replace (items =case_when(percentPp  < 20  ~   gsub("^,|(?<=,),|,$", "" , str_remove_all(., "18"), perl =T)  %>%
  mutate( comp = str_count(items, ",") + 1) %>%mutate (percentB = str_count(items , "1") / comp *100) %>%
  mutate (percentM = str_count(items , "2") / comp *100) %>%
  mutate (percentO = str_count(items , "3") / comp *100) %>%
  mutate (percentAC = str_count(items , "4") / comp *100) %>%
  mutate (percentC = str_count(items , "5") / comp *100) %>%
  mutate (percentT = str_count(items , "6") / comp *100) %>%
  mutate (percentPp = str_count(items , "18") / comp *100) %>%
  mutate (percentPt = str_count(items , "19") / comp *100))

df3 <- df2 %>%
  mutate (lu =case_when (percentM  == 100 ~ "M",percentB  == 100 ~ "B",percentO  == 100 ~ "O",percentAC == 100 ~ "Ac",percentC  == 100 ~ "C",percentT  == 100 ~ "T",percentPp == 100 ~ "Pp",percentPt == 100 ~ "Pt",(percentB == 40) & (percentM == 40) & (percentT == 20) ~ "BBMMT")  %>%
  mutate( final = ifelse(. !=0 ~ gsub( "pourcent", "", cur_col(.)) , "" )))
</code>```

I d like to automatize the copy (in the "final" column), the % of items by 1) descending of % and  when % are equal, then by 2) alphabetic order of items

Title: extract counting sorting and look-up

Body:
I have a dataset with a rowID and a column 'items' that contains numbers delimited with commas.
Each number represents a specific item.
"1" stands for "B" and so on.

For each row, I want to calculate the individual weignt of each item.
To illustrate :
"1,18,18,1" or "18,18,1,1" has an equivalent weight than "18,1", "1,18", etc. with 1 and 18 valuing 50% of the weight.

The goal is to retrieve the final weigh into an output variable that will contain the "B" in wase  100% of the weight of item "1" in row. The 100% is the easiest case. When having 25% of "6" (which stands for "T") , 50 % of "1" (which stands for "B") and 25 % of "5" (which stands for "C") I want to get "TBCB" in the output final variable .

So far, I have created en column 'comp' that counts the numbers ("items") delimited by the commas in the "items" column.

I've created a % column representing the weight of each item.

My difficulty is to handle the final variable  : assembling the percentages so as to create the new sequence.

library(dplyr)library(stringr)

df = data.frame(
items =c(as.character("1,1,8,16,8,18,18,1,16,2,8,5,1","2,1,2,1,6"),
as.character("18,18,19,18,4"), as.character("1,19,2"),
as.character("2,2,2,4,2,6,1" )  , as.character("6,2,2") ,
ID = seq(1:5)
)

df1 <- df %>%mutate( comp = str_count(items, ",") + 1) %>%
  mutate (percentB = str_count(items , "1") / comp *100) %>%
  mutate (percentM = str_count(items , "2") / comp *100) %>%
  mutate (percentO = str_count(items , "3") / comp *100) %>%
  mutate (percentAC = str_count(items , "4") / comp *100) %>%
  mutate (percentC = str_count(items , "5") / comp *100) %>%
  mutate (percentT = str_count(items , "6") / comp *100) %>%
  mutate (percentPp = str_count(items , "18") / comp *100) %>%
  mutate (percentPt = str_count(items , "19") / comp *100)

df2 <- df1 <- replace (items =case_when(percentPp  < 20  ~   gsub("^,|(?<=,),|,$", "" , str_remove_all(., "18"), perl =T)  %>%
  mutate( comp = str_count(items, ",") + 1) %>%mutate (percentB = str_count(items , "1") / comp *100) %>%
  mutate (percentM = str_count(items , "2") / comp *100) %>%
  mutate (percentO = str_count(items , "3") / comp *100) %>%
  mutate (percentAC = str_count(items , "4") / comp *100) %>%
  mutate (percentC = str_count(items , "5") / comp *100) %>%
  mutate (percentT = str_count(items , "6") / comp *100) %>%
  mutate (percentPp = str_count(items , "18") / comp *100) %>%
  mutate (percentPt = str_count(items , "19") / comp *100))

df3 <- df2 %>%
  mutate (lu =case_when (percentM  == 100 ~ "M",percentB  == 100 ~ "B",percentO  == 100 ~ "O",percentAC == 100 ~ "Ac",percentC  == 100 ~ "C",percentT  == 100 ~ "T",percentPp == 100 ~ "Pp",percentPt == 100 ~ "Pt",(percentB == 40) & (percentM == 40) & (percentT == 20) ~ "BBMMT")  %>%
  mutate( final = ifelse(. !=0 ~ gsub( "pourcent", "", cur_col(.)) , "" )))

I d like to automatize the copy (in the "final" column), the % of items by 1) descending of % and  when % are equal, then by 2) alphabetic order of items


问:
Nominatim: psycopg2.errors.UndefinedTable: missing FROM-clause entry for table "parent" when trying to import
I had created an empty database called nominatim on my DB cluster, pointed the DSN to my database with the dbname, host, port, user and pass and tried to import the map of Portugal with the following params:

```<code>nohup <path/to/file>/build/utils/setup.php \
 --threads 4 \
 --setup-db \
 --import-data \
 --create-functions \
 --enable-diff-updates \
 --enable-debug-statements \
 --create-tables \
 --create-partition-tables \
 --create-partition-functions \
 --import-wikipedia-articles \
 --load-data \
 --import-tiger-data \
 --calculate-postcodes \
 --index \
 --index-noanalyse \
 --create-search-indices \
 --create-country-names \
 --osm-file <path/to/file>/portugal-latest.osm.pbf >> <path/to/file>/logImportPortugal.txt 2>&1
</code>```

But it is giving me the following error:

```<code>WARNING: Starting rank 25
Traceback (most recent call last):
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 370, in <module>
   Indexer(options).run()
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 215, in run
   self.index(RankRunner(self.maxrank))
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 259, in index
   thread = next(next_thread)
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 300, in find_free_thread
   if thread.is_done():
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 178, in is_done
   if self.conn.poll() == psycopg2.extensions.POLL_OK:
psycopg2.errors.UndefinedTable: missing FROM-clause entry for table "parent"
LINE 1: parent.place_id
       ^
QUERY:  parent.place_id
CONTEXT:  PL/pgSQL function find_parent_for_address(text,text,smallint,geometry) line 25 at RAISE
PL/pgSQL function find_parent_for_poi(character,bigint,smallint,geometry,text,text,boolean) line 31 at assignment
PL/pgSQL function placex_update() line 178 at assignment

ERROR: error status 1 running nominatim!
string(33) "error status 1 running nominatim!"
</code>```

The flag --setup-db shouldn't create all the relations? What am I missing?

Below is the full log:

```<code>nohup: ignoring input
2023-01-10 13:00:49 == module path: /srv/nominatim/build/module
2023-01-10 13:00:49 == Setup DB
Postgres version found: 14
Postgis version found: 3.2
 set_config
------------

(1 row)

2023-01-10 13:00:54 == Import data
osm2pgsql version 1.2.0 (64 bit id space)

Mid: loading persistent node cache from /srv/nominatim/flatnode.file
Mid: pgsql, cache=0
Setting up table: planet_osm_nodes
Setting up table: planet_osm_ways
Setting up table: planet_osm_rels
Parsing gazetteer style file '/srv/nominatim/Nominatim-3.5.1/settings/import-full.style'.
Using projection SRS 4326 (Latlong)
NOTICE:  table "place" does not exist, skipping

Reading in file: /home/izadmin/planet_full/portugal-latest.osm.pbf
Using PBF parser.
^MProcessing: Node(50k 50.0k/s) Way(0k 0.00k/s) Relation(0 0.00/s)^MProcessing: Node(150k 75.0k/s) Way(0k 0.00k/s) Relation(0 0.00/s)^MProcessing: Node(310k 103.3k/s) Way(0k 0.00k/s) Relation>Node stats: total(36476942), max(10423206981) in 223s
Way stats: total(3678221), max(1129408209) in 88s
Relation stats: total(75907), max(15101706) in 7s
Stopping table: planet_osm_nodes
Stopped table: planet_osm_nodes in 0s
Stopping table: planet_osm_ways
Stopped table: planet_osm_ways in 0s
Stopping table: planet_osm_rels
Building index on table: planet_osm_rels
Stopped table: planet_osm_rels in 0s

Osm2pgsql took 319s overall
2023-01-10 13:06:14 == Create Functions
2023-01-10 13:06:14 == Create Tables
2023-01-10 13:06:14 == Create Functions
2023-01-10 13:06:14 == Create Tables
2023-01-10 13:06:15 == Create Partition Tables
2023-01-10 13:06:16 == Create Partition Functions
2023-01-10 13:06:16 == Importing wikipedia articles and redirects
2023-01-10 13:08:08 == Drop old Data
...............................................................................................................................................................................................>2023-01-10 13:08:13 == Loading word list
 count
--------
 318141
(1 row)

 count
-------
 14556
(1 row)

2023-01-10 13:09:01 == Load Data

2023-01-10 13:43:34 == Reanalysing database
Latest data imported from 2023-01-09T21:15:53Z.
2023-01-10 13:43:37 == Import Tiger data
2023-01-10 13:43:37 == Found 0 SQL files in path /srv/nominatim/Nominatim-3.5.1/data/tiger
2023-01-10 13:43:37 == WARNING: Tiger data import selected but no files found in path /srv/nominatim/Nominatim-3.5.1/data/tiger
2023-01-10 13:43:37 == Calculate Postcodes
2023-01-10 13:44:47 == Index ranks 0 - 4
'/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py' --database nominatim --port 5432 --threads 4 -v --host '127.0.0.1' --user postgres --maxrank 4WARNING: Starting indexing rank (0 to 4) >WARNING: Starting rank 0
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 0

WARNING: Starting rank 1
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 1

WARNING: Starting rank 2
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 2

WARNING: Starting rank 3
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 3

WARNING: Starting rank 4
WARNING: Done 2/2 in 0 @ 3.477 per second - FINISHED rank 4

2023-01-10 13:44:47 == Index ranks 5 - 25
WARNING: Starting indexing rank (5 to 25) using 4 threads
WARNING: Starting rank 5
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 5

WARNING: Starting rank 6
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 6
WARNING: Starting rank 7
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 7

WARNING: Starting rank 8
WARNING: Done 2/2 in 0 @ 7.341 per second - FINISHED rank 8

WARNING: Starting rank 9
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 9

WARNING: Starting rank 10
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 10

WARNING: Starting rank 11
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 11

WARNING: Starting rank 12
WARNING: Done 37/37 in 0 @ 139.460 per second - FINISHED rank 12

WARNING: Starting rank 13
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 13

WARNING: Starting rank 14
INFO: Done 100 in 0 @ 389.785 per second - rank 14 ETA (seconds): 0.53
WARNING: Done 308/308 in 0 @ 321.383 per second - FINISHED rank 14

WARNING: Starting rank 15
WARNING: Done 1/1 in 0 @ 661.813 per second - FINISHED rank 15

WARNING: Starting rank 16
INFO: Done 100 in 0 @ 587.337 per second - rank 16 ETA (seconds): 5.38
INFO: Done 687 in 1 @ 516.197 per second - rank 16 ETA (seconds): 4.99
INFO: Done 1203 in 2 @ 507.508 per second - rank 16 ETA (seconds): 4.06
INFO: Done 1710 in 3 @ 488.050 per second - rank 16 ETA (seconds): 3.18
INFO: Done 2198 in 4 @ 455.463 per second - rank 16 ETA (seconds): 2.34
INFO: Done 2653 in 5 @ 450.394 per second - rank 16 ETA (seconds): 1.35
INFO: Done 3103 in 7 @ 425.337 per second - rank 16 ETA (seconds): 0.37
WARNING: Done 3262/3262 in 8 @ 388.872 per second - FINISHED rank 16

WARNING: Starting rank 17
INFO: Done 100 in 0 @ 1959.248 per second - rank 17 ETA (seconds): 0.01
WARNING: Done 127/127 in 0 @ 1647.831 per second - FINISHED rank 17
WARNING: Starting rank 18
INFO: Done 100 in 0 @ 1458.789 per second - rank 18 ETA (seconds): 2.29
INFO: Done 1558 in 0 @ 1776.158 per second - rank 18 ETA (seconds): 1.06
INFO: Done 3334 in 1 @ 1774.513 per second - rank 18 ETA (seconds): 0.06
WARNING: Done 3447/3447 in 1 @ 1777.266 per second - FINISHED rank 18

WARNING: Starting rank 19
INFO: Done 100 in 0 @ 3007.609 per second - rank 19 ETA (seconds): 1.98
INFO: Done 3107 in 1 @ 2444.868 per second - rank 19 ETA (seconds): 1.20
INFO: Done 5551 in 2 @ 2570.094 per second - rank 19 ETA (seconds): 0.19
WARNING: Done 6053/6052 in 2 @ 2644.112 per second - FINISHED rank 19

WARNING: Starting rank 20
INFO: Done 100 in 0 @ 2110.150 per second - rank 20 ETA (seconds): 13.73
INFO: Done 2210 in 0 @ 2969.273 per second - rank 20 ETA (seconds): 9.04
INFO: Done 5179 in 2 @ 2321.562 per second - rank 20 ETA (seconds): 10.29
INFO: Done 7500 in 3 @ 2142.735 per second - rank 20 ETA (seconds): 10.07
INFO: Done 9642 in 4 @ 2055.257 per second - rank 20 ETA (seconds): 9.45
INFO: Done 11697 in 5 @ 2019.092 per second - rank 20 ETA (seconds): 8.60
INFO: Done 13716 in 6 @ 1998.935 per second - rank 20 ETA (seconds): 7.68
INFO: Done 15714 in 7 @ 1993.985 per second - rank 20 ETA (seconds): 6.70
INFO: Done 17707 in 8 @ 1990.804 per second - rank 20 ETA (seconds): 5.71
INFO: Done 19697 in 9 @ 1978.861 per second - rank 20 ETA (seconds): 4.74
INFO: Done 21675 in 11 @ 1960.704 per second - rank 20 ETA (seconds): 3.77
INFO: Done 23635 in 12 @ 1936.453 per second - rank 20 ETA (seconds): 2.81
INFO: Done 25571 in 13 @ 1929.992 per second - rank 20 ETA (seconds): 1.81
INFO: Done 27500 in 14 @ 1939.698 per second - rank 20 ETA (seconds): 0.81
WARNING: Done 29070/29067 in 14 @ 1942.903 per second - FINISHED rank 20

WARNING: Starting rank 21
INFO: Done 100 in 0 @ 2234.986 per second - rank 21 ETA (seconds): 0.48
WARNING: Done 1167/1167 in 0 @ 1538.119 per second - FINISHED rank 21

WARNING: Starting rank 22
INFO: Done 100 in 0 @ 1638.646 per second - rank 22 ETA (seconds): 18.97
INFO: Done 1738 in 0 @ 1982.608 per second - rank 22 ETA (seconds): 14.85
INFO: Done 3720 in 2 @ 1732.995 per second - rank 22 ETA (seconds): 15.85
INFO: Done 5452 in 3 @ 1742.091 per second - rank 22 ETA (seconds): 14.77
INFO: Done 7194 in 4 @ 1723.857 per second - rank 22 ETA (seconds): 13.92
INFO: Done 8917 in 5 @ 1717.254 per second - rank 22 ETA (seconds): 12.97
INFO: Done 10634 in 6 @ 1712.904 per second - rank 22 ETA (seconds): 12.00
INFO: Done 12346 in 7 @ 1716.312 per second - rank 22 ETA (seconds): 10.98
INFO: Done 14062 in 8 @ 1718.356 per second - rank 22 ETA (seconds): 9.96
INFO: Done 15780 in 9 @ 1720.232 per second - rank 22 ETA (seconds): 8.95
INFO: Done 17500 in 10 @ 1727.692 per second - rank 22 ETA (seconds): 7.92
INFO: Done 19227 in 11 @ 1727.651 per second - rank 22 ETA (seconds): 6.92
INFO: Done 20954 in 12 @ 1723.779 per second - rank 22 ETA (seconds): 5.93
INFO: Done 22677 in 13 @ 1715.023 per second - rank 22 ETA (seconds): 4.96
INFO: Done 24392 in 14 @ 1717.552 per second - rank 22 ETA (seconds): 3.95
INFO: Done 26109 in 15 @ 1697.694 per second - rank 22 ETA (seconds): 2.99
INFO: Done 27806 in 16 @ 1659.334 per second - rank 22 ETA (seconds): 2.04
INFO: Done 29465 in 17 @ 1662.434 per second - rank 22 ETA (seconds): 1.03
INFO: Done 31127 in 18 @ 1667.951 per second - rank 22 ETA (seconds): 0.03
WARNING: Done 31184/31183 in 18 @ 1668.224 per second - FINISHED rank 22

WARNING: Starting rank 23
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 23

WARNING: Starting rank 24
INFO: Done 100 in 0 @ 2041.400 per second - rank 24 ETA (seconds): 2.52
INFO: Done 2141 in 1 @ 1956.016 per second - rank 24 ETA (seconds): 1.59
INFO: Done 4097 in 2 @ 1911.586 per second - rank 24 ETA (seconds): 0.60
WARNING: Done 5248/5245 in 2 @ 1908.391 per second - FINISHED rank 24

WARNING: Starting rank 25
Traceback (most recent call last):
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 370, in <module>
    Indexer(options).run()
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 215, in run
    self.index(RankRunner(self.maxrank))
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 259, in index
    thread = next(next_thread)
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 300, in find_free_thread
    if thread.is_done():
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 178, in is_done
    if self.conn.poll() == psycopg2.extensions.POLL_OK:
    psycopg2.errors.UndefinedTable: missing FROM-clause entry for table "parent"
LINE 1: parent.place_id
        ^
QUERY:  parent.place_id
CONTEXT:  PL/pgSQL function find_parent_for_address(text,text,smallint,geometry) line 25 at RAISE
PL/pgSQL function find_parent_for_poi(character,bigint,smallint,geometry,text,text,boolean) line 31 at assignment
PL/pgSQL function placex_update() line 178 at assignment

ERROR: error status 1 running nominatim!
string(33) "error status 1 running nominatim!"
</code>```

I am using Nominatim 3.5.1

Body:
I had created an empty database called nominatim on my DB cluster, pointed the DSN to my database with the dbname, host, port, user and pass and tried to import the map of Portugal with the following params:

nohup <path/to/file>/build/utils/setup.php \
 --threads 4 \
 --setup-db \
 --import-data \
 --create-functions \
 --enable-diff-updates \
 --enable-debug-statements \
 --create-tables \
 --create-partition-tables \
 --create-partition-functions \
 --import-wikipedia-articles \
 --load-data \
 --import-tiger-data \
 --calculate-postcodes \
 --index \
 --index-noanalyse \
 --create-search-indices \
 --create-country-names \
 --osm-file <path/to/file>/portugal-latest.osm.pbf >> <path/to/file>/logImportPortugal.txt 2>&1

But it is giving me the following error:

WARNING: Starting rank 25
Traceback (most recent call last):
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 370, in <module>
   Indexer(options).run()
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 215, in run
   self.index(RankRunner(self.maxrank))
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 259, in index
   thread = next(next_thread)
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 300, in find_free_thread
   if thread.is_done():
 File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 178, in is_done
   if self.conn.poll() == psycopg2.extensions.POLL_OK:
psycopg2.errors.UndefinedTable: missing FROM-clause entry for table "parent"
LINE 1: parent.place_id
       ^
QUERY:  parent.place_id
CONTEXT:  PL/pgSQL function find_parent_for_address(text,text,smallint,geometry) line 25 at RAISE
PL/pgSQL function find_parent_for_poi(character,bigint,smallint,geometry,text,text,boolean) line 31 at assignment
PL/pgSQL function placex_update() line 178 at assignment

ERROR: error status 1 running nominatim!
string(33) "error status 1 running nominatim!"

The flag --setup-db shouldn't create all the relations? What am I missing?

Below is the full log:

nohup: ignoring input
2023-01-10 13:00:49 == module path: /srv/nominatim/build/module
2023-01-10 13:00:49 == Setup DB
Postgres version found: 14
Postgis version found: 3.2
 set_config
------------

(1 row)

2023-01-10 13:00:54 == Import data
osm2pgsql version 1.2.0 (64 bit id space)

Mid: loading persistent node cache from /srv/nominatim/flatnode.file
Mid: pgsql, cache=0
Setting up table: planet_osm_nodes
Setting up table: planet_osm_ways
Setting up table: planet_osm_rels
Parsing gazetteer style file '/srv/nominatim/Nominatim-3.5.1/settings/import-full.style'.
Using projection SRS 4326 (Latlong)
NOTICE:  table "place" does not exist, skipping

Reading in file: /home/izadmin/planet_full/portugal-latest.osm.pbf
Using PBF parser.
^MProcessing: Node(50k 50.0k/s) Way(0k 0.00k/s) Relation(0 0.00/s)^MProcessing: Node(150k 75.0k/s) Way(0k 0.00k/s) Relation(0 0.00/s)^MProcessing: Node(310k 103.3k/s) Way(0k 0.00k/s) Relation>Node stats: total(36476942), max(10423206981) in 223s
Way stats: total(3678221), max(1129408209) in 88s
Relation stats: total(75907), max(15101706) in 7s
Stopping table: planet_osm_nodes
Stopped table: planet_osm_nodes in 0s
Stopping table: planet_osm_ways
Stopped table: planet_osm_ways in 0s
Stopping table: planet_osm_rels
Building index on table: planet_osm_rels
Stopped table: planet_osm_rels in 0s

Osm2pgsql took 319s overall
2023-01-10 13:06:14 == Create Functions
2023-01-10 13:06:14 == Create Tables
2023-01-10 13:06:14 == Create Functions
2023-01-10 13:06:14 == Create Tables
2023-01-10 13:06:15 == Create Partition Tables
2023-01-10 13:06:16 == Create Partition Functions
2023-01-10 13:06:16 == Importing wikipedia articles and redirects
2023-01-10 13:08:08 == Drop old Data
...............................................................................................................................................................................................>2023-01-10 13:08:13 == Loading word list
 count
--------
 318141
(1 row)

 count
-------
 14556
(1 row)

2023-01-10 13:09:01 == Load Data

2023-01-10 13:43:34 == Reanalysing database
Latest data imported from 2023-01-09T21:15:53Z.
2023-01-10 13:43:37 == Import Tiger data
2023-01-10 13:43:37 == Found 0 SQL files in path /srv/nominatim/Nominatim-3.5.1/data/tiger
2023-01-10 13:43:37 == WARNING: Tiger data import selected but no files found in path /srv/nominatim/Nominatim-3.5.1/data/tiger
2023-01-10 13:43:37 == Calculate Postcodes
2023-01-10 13:44:47 == Index ranks 0 - 4
'/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py' --database nominatim --port 5432 --threads 4 -v --host '127.0.0.1' --user postgres --maxrank 4WARNING: Starting indexing rank (0 to 4) >WARNING: Starting rank 0
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 0

WARNING: Starting rank 1
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 1

WARNING: Starting rank 2
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 2

WARNING: Starting rank 3
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 3

WARNING: Starting rank 4
WARNING: Done 2/2 in 0 @ 3.477 per second - FINISHED rank 4

2023-01-10 13:44:47 == Index ranks 5 - 25
WARNING: Starting indexing rank (5 to 25) using 4 threads
WARNING: Starting rank 5
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 5

WARNING: Starting rank 6
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 6
WARNING: Starting rank 7
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 7

WARNING: Starting rank 8
WARNING: Done 2/2 in 0 @ 7.341 per second - FINISHED rank 8

WARNING: Starting rank 9
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 9

WARNING: Starting rank 10
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 10

WARNING: Starting rank 11
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 11

WARNING: Starting rank 12
WARNING: Done 37/37 in 0 @ 139.460 per second - FINISHED rank 12

WARNING: Starting rank 13
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 13

WARNING: Starting rank 14
INFO: Done 100 in 0 @ 389.785 per second - rank 14 ETA (seconds): 0.53
WARNING: Done 308/308 in 0 @ 321.383 per second - FINISHED rank 14

WARNING: Starting rank 15
WARNING: Done 1/1 in 0 @ 661.813 per second - FINISHED rank 15

WARNING: Starting rank 16
INFO: Done 100 in 0 @ 587.337 per second - rank 16 ETA (seconds): 5.38
INFO: Done 687 in 1 @ 516.197 per second - rank 16 ETA (seconds): 4.99
INFO: Done 1203 in 2 @ 507.508 per second - rank 16 ETA (seconds): 4.06
INFO: Done 1710 in 3 @ 488.050 per second - rank 16 ETA (seconds): 3.18
INFO: Done 2198 in 4 @ 455.463 per second - rank 16 ETA (seconds): 2.34
INFO: Done 2653 in 5 @ 450.394 per second - rank 16 ETA (seconds): 1.35
INFO: Done 3103 in 7 @ 425.337 per second - rank 16 ETA (seconds): 0.37
WARNING: Done 3262/3262 in 8 @ 388.872 per second - FINISHED rank 16

WARNING: Starting rank 17
INFO: Done 100 in 0 @ 1959.248 per second - rank 17 ETA (seconds): 0.01
WARNING: Done 127/127 in 0 @ 1647.831 per second - FINISHED rank 17
WARNING: Starting rank 18
INFO: Done 100 in 0 @ 1458.789 per second - rank 18 ETA (seconds): 2.29
INFO: Done 1558 in 0 @ 1776.158 per second - rank 18 ETA (seconds): 1.06
INFO: Done 3334 in 1 @ 1774.513 per second - rank 18 ETA (seconds): 0.06
WARNING: Done 3447/3447 in 1 @ 1777.266 per second - FINISHED rank 18

WARNING: Starting rank 19
INFO: Done 100 in 0 @ 3007.609 per second - rank 19 ETA (seconds): 1.98
INFO: Done 3107 in 1 @ 2444.868 per second - rank 19 ETA (seconds): 1.20
INFO: Done 5551 in 2 @ 2570.094 per second - rank 19 ETA (seconds): 0.19
WARNING: Done 6053/6052 in 2 @ 2644.112 per second - FINISHED rank 19

WARNING: Starting rank 20
INFO: Done 100 in 0 @ 2110.150 per second - rank 20 ETA (seconds): 13.73
INFO: Done 2210 in 0 @ 2969.273 per second - rank 20 ETA (seconds): 9.04
INFO: Done 5179 in 2 @ 2321.562 per second - rank 20 ETA (seconds): 10.29
INFO: Done 7500 in 3 @ 2142.735 per second - rank 20 ETA (seconds): 10.07
INFO: Done 9642 in 4 @ 2055.257 per second - rank 20 ETA (seconds): 9.45
INFO: Done 11697 in 5 @ 2019.092 per second - rank 20 ETA (seconds): 8.60
INFO: Done 13716 in 6 @ 1998.935 per second - rank 20 ETA (seconds): 7.68
INFO: Done 15714 in 7 @ 1993.985 per second - rank 20 ETA (seconds): 6.70
INFO: Done 17707 in 8 @ 1990.804 per second - rank 20 ETA (seconds): 5.71
INFO: Done 19697 in 9 @ 1978.861 per second - rank 20 ETA (seconds): 4.74
INFO: Done 21675 in 11 @ 1960.704 per second - rank 20 ETA (seconds): 3.77
INFO: Done 23635 in 12 @ 1936.453 per second - rank 20 ETA (seconds): 2.81
INFO: Done 25571 in 13 @ 1929.992 per second - rank 20 ETA (seconds): 1.81
INFO: Done 27500 in 14 @ 1939.698 per second - rank 20 ETA (seconds): 0.81
WARNING: Done 29070/29067 in 14 @ 1942.903 per second - FINISHED rank 20

WARNING: Starting rank 21
INFO: Done 100 in 0 @ 2234.986 per second - rank 21 ETA (seconds): 0.48
WARNING: Done 1167/1167 in 0 @ 1538.119 per second - FINISHED rank 21

WARNING: Starting rank 22
INFO: Done 100 in 0 @ 1638.646 per second - rank 22 ETA (seconds): 18.97
INFO: Done 1738 in 0 @ 1982.608 per second - rank 22 ETA (seconds): 14.85
INFO: Done 3720 in 2 @ 1732.995 per second - rank 22 ETA (seconds): 15.85
INFO: Done 5452 in 3 @ 1742.091 per second - rank 22 ETA (seconds): 14.77
INFO: Done 7194 in 4 @ 1723.857 per second - rank 22 ETA (seconds): 13.92
INFO: Done 8917 in 5 @ 1717.254 per second - rank 22 ETA (seconds): 12.97
INFO: Done 10634 in 6 @ 1712.904 per second - rank 22 ETA (seconds): 12.00
INFO: Done 12346 in 7 @ 1716.312 per second - rank 22 ETA (seconds): 10.98
INFO: Done 14062 in 8 @ 1718.356 per second - rank 22 ETA (seconds): 9.96
INFO: Done 15780 in 9 @ 1720.232 per second - rank 22 ETA (seconds): 8.95
INFO: Done 17500 in 10 @ 1727.692 per second - rank 22 ETA (seconds): 7.92
INFO: Done 19227 in 11 @ 1727.651 per second - rank 22 ETA (seconds): 6.92
INFO: Done 20954 in 12 @ 1723.779 per second - rank 22 ETA (seconds): 5.93
INFO: Done 22677 in 13 @ 1715.023 per second - rank 22 ETA (seconds): 4.96
INFO: Done 24392 in 14 @ 1717.552 per second - rank 22 ETA (seconds): 3.95
INFO: Done 26109 in 15 @ 1697.694 per second - rank 22 ETA (seconds): 2.99
INFO: Done 27806 in 16 @ 1659.334 per second - rank 22 ETA (seconds): 2.04
INFO: Done 29465 in 17 @ 1662.434 per second - rank 22 ETA (seconds): 1.03
INFO: Done 31127 in 18 @ 1667.951 per second - rank 22 ETA (seconds): 0.03
WARNING: Done 31184/31183 in 18 @ 1668.224 per second - FINISHED rank 22

WARNING: Starting rank 23
WARNING: Done 0/0 in 0 @ 0.000 per second - FINISHED rank 23

WARNING: Starting rank 24
INFO: Done 100 in 0 @ 2041.400 per second - rank 24 ETA (seconds): 2.52
INFO: Done 2141 in 1 @ 1956.016 per second - rank 24 ETA (seconds): 1.59
INFO: Done 4097 in 2 @ 1911.586 per second - rank 24 ETA (seconds): 0.60
WARNING: Done 5248/5245 in 2 @ 1908.391 per second - FINISHED rank 24

WARNING: Starting rank 25
Traceback (most recent call last):
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 370, in <module>
    Indexer(options).run()
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 215, in run
    self.index(RankRunner(self.maxrank))
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 259, in index
    thread = next(next_thread)
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 300, in find_free_thread
    if thread.is_done():
  File "/srv/nominatim/Nominatim-3.5.1/nominatim/nominatim.py", line 178, in is_done
    if self.conn.poll() == psycopg2.extensions.POLL_OK:
    psycopg2.errors.UndefinedTable: missing FROM-clause entry for table "parent"
LINE 1: parent.place_id
        ^
QUERY:  parent.place_id
CONTEXT:  PL/pgSQL function find_parent_for_address(text,text,smallint,geometry) line 25 at RAISE
PL/pgSQL function find_parent_for_poi(character,bigint,smallint,geometry,text,text,boolean) line 31 at assignment
PL/pgSQL function placex_update() line 178 at assignment

ERROR: error status 1 running nominatim!
string(33) "error status 1 running nominatim!"

I am using Nominatim 3.5.1


问:
How to create an OS Agnostic HTML link with ":" (colon) in the local URL?
I have a HTML file (index.html) that I want to insert a local link to. The link location relative to index.html is "folder/link:A.jpg".

This link will be accessed by both MacOS users and Windows Users. How can I create this link in a way that the ":" symbol is properly processed by both OS's?

I can't use the colon HTML tag, that link is broken in both systems, only works on my linux testing VM.

I can copy how the path is encoded in Windows into the link, but then that link is broken on MacOS, and the same thing if I copy the link from MacOS, it will be broken on Windows.

Unfortunately I have other software that uses the exact format of "link:A.jpg" as input, so changing the colon in the image is not an option.

Is there a way I can  dynamically code the colon so it will show up as it natively does in either system?


问:
Spying on a ByteArrayOutputStream causes the object to lose context in java-17
We recently upgraded our JDK from 11 to 17. Part of this upgrade included an upgrade from mockito from version 3.3.3 to mockito version 4.11.0.

One of our existing tests which used to work in the past broke because of this. In this test we spy on a ByteArrayOutputStream object to verify that it does not get closed. This test fails because of the error given below.

```<code>@Test
void encryptionDoesNotCloseOutputStream() throws Throwable {
    byte[] key = new byte[32];
    RANDOM.nextBytes(key);
    byte[] data = new byte[101];
    RANDOM.nextBytes(data);
    ByteArrayInputStream in = spy(new ByteArrayInputStream(data));
    ByteArrayOutputStream out = spy(new ByteArrayOutputStream());

    ...

    // Write the IV at the beginning of the file (first 12 Bytes)
    out.write(buffers.iv);

    ...

    verify(in, never()).close();
    verify(out, never()).close();
}
</code>```

This results in the following error.

```<code>[ERROR] Errors:
[ERROR]   CryptoUtilsTest.encryptionDoesNotCloseOutputStream:47 » NullPointer Cannot read the array length because "this.buf" is null
</code>```

As discussed in a related issue, How to properly spy on an input stream, I tried to change our mockito dependency from mockito-core to mockito-inline but this did not change anything.

We did not yet verify whether or not this issue also occurs in a java-11 environment when upgrading mockito. It does happen when just updating java to java-17 without touching mockito at all.

Body:
We recently upgraded our JDK from 11 to 17. Part of this upgrade included an upgrade from mockito from version 3.3.3 to mockito version 4.11.0.

One of our existing tests which used to work in the past broke because of this. In this test we spy on a ByteArrayOutputStream object to verify that it does not get closed. This test fails because of the error given below.

@Test
void encryptionDoesNotCloseOutputStream() throws Throwable {
    byte[] key = new byte[32];
    RANDOM.nextBytes(key);
    byte[] data = new byte[101];
    RANDOM.nextBytes(data);
    ByteArrayInputStream in = spy(new ByteArrayInputStream(data));
    ByteArrayOutputStream out = spy(new ByteArrayOutputStream());

    ...

    // Write the IV at the beginning of the file (first 12 Bytes)
    out.write(buffers.iv);

    ...

    verify(in, never()).close();
    verify(out, never()).close();
}

This results in the following error.

[ERROR] Errors:
[ERROR]   CryptoUtilsTest.encryptionDoesNotCloseOutputStream:47 » NullPointer Cannot read the array length because "this.buf" is null

As discussed in a related issue, How to properly spy on an input stream, I tried to change our mockito dependency from mockito-core to mockito-inline but this did not change anything.

We did not yet verify whether or not this issue also occurs in a java-11 environment when upgrading mockito. It does happen when just updating java to java-17 without touching mockito at all.


问:
Unable to remove authentication ask from firebase storage
I have connected this app with my firebase console. I am trying to upload videos from the app to firebase storage so that another app connect to same console (which has authentication) can display it

I am getting this error when I upload:

```<code>W/System  (10365): Ignoring header X-Firebase-Locale because its value was null.
</code>```

I went through this question(W/System: Ignoring header X-Firebase-Locale because its value was null) on stack overflow but I am unable to remove the authentication requirement still

My firebase storage rules are:

```<code>service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if
          true;
    }
  }
}
</code>```

I don't understand why I am still unable to upload without authentication.(App is connected to internet too and has permission)

Body:
I have connected this app with my firebase console. I am trying to upload videos from the app to firebase storage so that another app connect to same console (which has authentication) can display it

I am getting this error when I upload:

W/System  (10365): Ignoring header X-Firebase-Locale because its value was null.

I went through this question(W/System: Ignoring header X-Firebase-Locale because its value was null) on stack overflow but I am unable to remove the authentication requirement still

My firebase storage rules are:

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if
          true;
    }
  }
}

I don't understand why I am still unable to upload without authentication.(App is connected to internet too and has permission)


问:
Invalid python interpreter when using virtualenv --system-site-packages in VSCode
Ideally I would like to use Loading an Lmod module using VSCode with Remote-SSH
however the soultion to use that directly does not seem to work. On the other hand virtualenvs ought to be supported by the Python VSCode extension.

Thus I figured the following steps should work instead.

Set-up the virtualenvironment in the remote environment

$ module load Python
$ virtualenv --system-site-packages my_python
```
<ol start="2">
<li>Connect via "Remote - SSH" plugin</li>
<li>In the terminal source your virtual environment from 1 and get the path to the python binary softlink:</li>
</ol>
```$ source my_python/bin/activate
$ which python
/path/to/my_python/bin/python
```

Copy the path to the python binary and paste it into the path to the Python intepreter that VSCode asks for.

And they do, but not always. The first time I tried this it worked and now everytime I try this for the same host it works directly. However, whenever I change to another host with the same parallel file system and redo step 4 it doesn't and instead says

Invalid python interpreter selected

This is the same error message as when you try to directly point to the python that the is loaded with Lmod (and built with EasyBuild if that makes a difference).

Now I'm stuck because the error message is not very helpful, I haven't found a stacktrace or any log-files that include this error. If I could find that or the code that handles the logic for what is a valid interpreter, that would be really helpful.

In summary:

virtualenv --system-site-packages symlinked Python doesn't work reliably as interpreter when system site Python is not a valid Python interpreter.

How to get this to work reliably?

Alternatively, what is the logic that determines a valid interpreter?

Body:
Ideally I would like to use Loading an Lmod module using VSCode with Remote-SSH
however the soultion to use that directly does not seem to work. On the other hand virtualenvs ought to be supported by the Python VSCode extension.

Thus I figured the following steps should work instead.

Set-up the virtualenvironment in the remote environment

$ module load Python
$ virtualenv --system-site-packages my_python

Connect via "Remote - SSH" plugin

In the terminal source your virtual environment from 1 and get the path to the python binary softlink:

$ source my_python/bin/activate
$ which python
/path/to/my_python/bin/python

Copy the path to the python binary and paste it into the path to the Python intepreter that VSCode asks for.

And they do, but not always. The first time I tried this it worked and now everytime I try this for the same host it works directly. However, whenever I change to another host with the same parallel file system and redo step 4 it doesn't and instead says

Invalid python interpreter selected

This is the same error message as when you try to directly point to the python that the is loaded with Lmod (and built with EasyBuild if that makes a difference).

Now I'm stuck because the error message is not very helpful, I haven't found a stacktrace or any log-files that include this error. If I could find that or the code that handles the logic for what is a valid interpreter, that would be really helpful.

In summary:

virtualenv --system-site-packages symlinked Python doesn't work reliably as interpreter when system site Python is not a valid Python interpreter.

How to get this to work reliably?

Alternatively, what is the logic that determines a valid interpreter?


问:
Comma within a field of csv file. Exporting the data on regular basis
We will be exporting the data through command line data loader
I have a CSV file - it has many values with comma as a part of them. The commas within the fields will mislead and making it seem like the row has more columns than previously.

Name,Amount,Address

Me,20,000,My Home,India

you,23,300,Your Home,Where

What are my options here as it will be automated process.


问:
login form in flutter with sembast
New to flutter, could someone explain to me how I could make a login form in flutter where I can access with a username and password saved in sembast, that is to say that when I log in I can only access with the email and password that I have saved in sembast

I have seen sembast tutorials but I don't know how to register the password and the user in sembast but I don't know how to do it or how to make the condition in the uqe form you can only enter with the username and password that is in the database data

Title: login form in flutter with sembast


问:
nestjs + graphql + typeorm, how to transform a lazy relation (promise) into solid array for the model
I am using nestjs with graphql (apollo) and typeorm. My entity has a lazy relation roles and the model represents it as an array. The issue is that it cannot seem to "magically" transform the Promise<[]> into []. Here's in more detail,

I have the UserModel which looks like this

```<code>@ObjectType({ description: 'User' })
export class UserModel {
  @Field()
  id: string;

  @Field(() => [UserRolesModel], { nullable: true })
  roles?: UserRolesModel[]
}
</code>```

and the UserEntity which looks like that

```<code>@Entity({ name: 'user' })
export class UserEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @OneToMany(() => UserRolesEntity, (userRoles) => userRoles.userId)
  roles: Promise<UserRolesEntity[]>;
}
</code>```

typescript complains that the Promise<UserRolesEntity[]> is not compatible with UserRolesModel[].

```<code>TS2322: Type 'UserEntity[]' is not assignable to type 'UserModel[]'.
Type 'UserEntity' is not assignable to type 'UserModel'.
Types of property 'roles' are incompatible.
Type 'Promise<UserRolesEntity[]>' is missing the following properties from type 'UserRolesModel[]': length, pop, push, concat, and 29 more.
</code>```

I suspect there is some trivial way of doing that with nestjs and the class-transformer?
What is the recommended way of solving this?

Body:
I am using nestjs with graphql (apollo) and typeorm. My entity has a lazy relation roles and the model represents it as an array. The issue is that it cannot seem to "magically" transform the Promise<[]> into []. Here's in more detail,

I have the UserModel which looks like this

@ObjectType({ description: 'User' })
export class UserModel {
  @Field()
  id: string;

  @Field(() => [UserRolesModel], { nullable: true })
  roles?: UserRolesModel[]
}

and the UserEntity which looks like that

@Entity({ name: 'user' })
export class UserEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @OneToMany(() => UserRolesEntity, (userRoles) => userRoles.userId)
  roles: Promise<UserRolesEntity[]>;
}

typescript complains that the Promise<UserRolesEntity[]> is not compatible with UserRolesModel[].

TS2322: Type 'UserEntity[]' is not assignable to type 'UserModel[]'.
Type 'UserEntity' is not assignable to type 'UserModel'.
Types of property 'roles' are incompatible.
Type 'Promise<UserRolesEntity[]>' is missing the following properties from type 'UserRolesModel[]': length, pop, push, concat, and 29 more.

I suspect there is some trivial way of doing that with nestjs and the class-transformer?
What is the recommended way of solving this?